mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Add enrollment invitations API EP for android
This commit is contained in:
parent
da3f350b01
commit
0c2465d03e
@ -33,6 +33,7 @@ import io.swagger.annotations.ApiResponses;
|
|||||||
import io.swagger.annotations.ResponseHeader;
|
import io.swagger.annotations.ResponseHeader;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
|
import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication;
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice;
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice;
|
||||||
|
|
||||||
@ -198,6 +199,57 @@ public interface DeviceManagementService {
|
|||||||
value = "Properties to update the device operations and their status.")
|
value = "Properties to update the device operations and their status.")
|
||||||
List<? extends Operation> resultOperations);
|
List<? extends Operation> resultOperations);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/invite")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Send enrollment invitation for android device",
|
||||||
|
tags = "Android Device Management",
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(
|
||||||
|
value="permission",
|
||||||
|
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/invite/android",
|
||||||
|
description = "Send device enrollment invitation") }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 201,
|
||||||
|
message = "Invited. \n Successfully sent invitations.",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "Content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests.")}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 303,
|
||||||
|
message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Location",
|
||||||
|
description = "The Source URL of the document.")}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request. \n Invalid request or validation error."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 415,
|
||||||
|
message = "Unsupported media type. \n The format of the requested entity was not supported.\n"),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n " +
|
||||||
|
"Server error occurred while adding a new device.")
|
||||||
|
})
|
||||||
|
Response sendEnrollmentInvitation(@ApiParam(
|
||||||
|
name = "EmailConfig",
|
||||||
|
value = "The properties required to send device enrollment invitation.")
|
||||||
|
@Valid EmailMetaInfo metaInfo);
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@ApiOperation(
|
@ApiOperation(
|
||||||
produces = MediaType.APPLICATION_JSON,
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
|||||||
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
|
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication;
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice;
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice;
|
||||||
@ -46,7 +47,15 @@ import javax.validation.Valid;
|
|||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Pattern;
|
import javax.validation.constraints.Pattern;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.DELETE;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.HeaderParam;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.PUT;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -164,6 +173,24 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
return Response.status(Response.Status.CREATED).entity(pendingOperations).build();
|
return Response.status(Response.Status.CREATED).entity(pendingOperations).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/invite")
|
||||||
|
@Override
|
||||||
|
public Response sendEnrollmentInvitation(EmailMetaInfo metaInfo) {
|
||||||
|
try {
|
||||||
|
AndroidAPIUtils.getDeviceManagementService()
|
||||||
|
.sendEnrolmentInvitation("android-enrollment-invitation", metaInfo);
|
||||||
|
Message responseMessage = new Message();
|
||||||
|
responseMessage.setResponseCode(Response.Status.OK.toString());
|
||||||
|
responseMessage.setResponseMessage("Enrollment invitations sent.");
|
||||||
|
return Response.status(Response.Status.OK).entity(responseMessage).build();
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(e.getMessage()).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateOperations(String deviceId, List<? extends Operation> operations)
|
private void updateOperations(String deviceId, List<? extends Operation> operations)
|
||||||
throws OperationManagementException, PolicyComplianceException,
|
throws OperationManagementException, PolicyComplianceException,
|
||||||
ApplicationManagementException, NotificationManagementException, DeviceManagementException {
|
ApplicationManagementException, NotificationManagementException, DeviceManagementException {
|
||||||
|
|||||||
@ -0,0 +1,72 @@
|
|||||||
|
#*
|
||||||
|
Copyright (c) 2016, 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.
|
||||||
|
*#
|
||||||
|
<EmailConfig>
|
||||||
|
<Subject>You have been invited to enroll your Android device in WSO2 IoT</Subject>
|
||||||
|
<Body>
|
||||||
|
<![CDATA[
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>WSO2 IoT Server</title>
|
||||||
|
</head>
|
||||||
|
<body style="color: #666666; background-color:#cdcdcd; padding: 0px; margin: 0px;">
|
||||||
|
<div style="background-color:#cdcdcd; font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; padding: 20px 0px; margin: 0px;">
|
||||||
|
<div style="width: 86%; max-width: 650px; padding: 2%; background-color: #ffffff; margin: auto; border-radius: 14px;">
|
||||||
|
<div style="background-color: #49c8f5; line-height: 0px; border-top-left-radius: 10px; border-top-right-radius: 10px; padding: 0px 10px 0px 0px;">
|
||||||
|
<div style="display: inline-block; line-height: 0px;">
|
||||||
|
<img src="http://b.content.wso2.com/sites/all/2015-june-theme/navigation/wso2-nav-logo.png"
|
||||||
|
alt="WSO2" style="margin: 0px 20px 0px 25px; width: 100%; max-width: 251px;"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="background-color: #ffffff; line-height: 170%; color: #666666; padding: 20px 25px;">
|
||||||
|
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px 20px;">
|
||||||
|
Hi $first-name,
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||||
|
You have been invited to enrol your android device in WSO2 IoT Server.
|
||||||
|
Click <a href="$base-url-https/android-web-agent/enroll">here</a> to begin device enrolment from
|
||||||
|
your Android device.</p>
|
||||||
|
|
||||||
|
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||||
|
Should you need assistance, please contact your administrator.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 20px 0px 5px;">
|
||||||
|
Regards,
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||||
|
WSO2 IoT Administrator
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div style="background-color: #333333; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px;">
|
||||||
|
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||||
|
<tr>
|
||||||
|
<td style="padding: 0px 20px 0px 0px;"><img
|
||||||
|
src="http://b.content.wso2.com/newsletter/images/wso2-logo-cloud-footer.png" alt="WSO2"
|
||||||
|
style="margin: 15px 0px 15px 25px; width: 100%; max-width: 258px;"/></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
]]>
|
||||||
|
</Body>
|
||||||
|
</EmailConfig>
|
||||||
@ -11,6 +11,7 @@ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../data
|
|||||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/devicetypes/);\
|
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/devicetypes/);\
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\
|
||||||
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/email/templates,target:${installFolder}/../../../repository/resources/email-templates,overwrite:true);\
|
||||||
|
|
||||||
instructions.unconfigure = \
|
instructions.unconfigure = \
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/mdm-android-agent.war);\
|
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/mdm-android-agent.war);\
|
||||||
@ -26,7 +27,7 @@ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../dep
|
|||||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.date-range-picker);\
|
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.date-range-picker);\
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.leaflet);\
|
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.leaflet);\
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod);\
|
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod);\
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.qr-modal);\
|
org.eclipse.equinox.p2.touchpoint.natives.remove(path:$${installFolder}/../../../repository/resources/email-templates/android-enrollment-invitation.vm);\
|
||||||
|
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/android);\
|
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/android);\
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/WSO2MobileAndroid_DB.h2.db);\
|
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/WSO2MobileAndroid_DB.h2.db);\
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user