From 6697dbcc5941e9830cc331f07c19b4ba268de4ed Mon Sep 17 00:00:00 2001 From: Ace Date: Mon, 19 Dec 2016 11:38:12 +0530 Subject: [PATCH 1/5] upgrading to latest version of identity --- .../pom.xml | 4 +-- .../pom.xml | 4 +-- .../pom.xml | 2 +- .../pom.xml | 4 +-- .../pom.xml | 2 +- pom.xml | 30 +++++++++++++------ 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml index 04b039ca5a..8d46401496 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml @@ -57,7 +57,7 @@ json-path - org.wso2.carbon.identity + org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth.stub @@ -139,4 +139,4 @@ - \ No newline at end of file + diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml index 1103ae546a..9ad069387f 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml @@ -69,7 +69,7 @@ json-path - org.wso2.carbon.identity + org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth.stub @@ -138,4 +138,4 @@ - \ No newline at end of file + diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml index d69cd4e821..31a8a818d5 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml @@ -72,7 +72,7 @@ httpclient - org.wso2.carbon.identity + org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth.stub diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml index 484fcff080..ab8b1227d6 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml @@ -281,12 +281,12 @@ - org.wso2.carbon.identity + org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth.stub provided - org.wso2.carbon.identity + org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth provided diff --git a/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml index 2fffe50511..e01dbe96a1 100644 --- a/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml +++ b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml @@ -185,7 +185,7 @@ org.igniterealtime.smack.wso2:smackx:${smackx.wso2.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.oauth.stub:${identity.inbound.auth.oauth.version} + org.wso2.carbon.identity.inbound.auth.oauth2:org.wso2.carbon.identity.oauth.stub:${identity.inbound.auth.oauth.version} com.jayway.jsonpath:json-path diff --git a/pom.xml b/pom.xml index 520eb0a09a..7a710c3480 100644 --- a/pom.xml +++ b/pom.xml @@ -417,6 +417,11 @@ org.wso2.carbon.device.mgt.input.adapter.xmpp ${carbon.devicemgt.plugins.version} + + com.jayway.jsonpath + json-path + ${jsonpath.version} + org.wso2.carbon.devicemgt-plugins org.wso2.carbon.device.mgt.iot.api @@ -1069,13 +1074,13 @@ ${googlecode.plist.version} - org.wso2.carbon.identity + org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth.stub ${identity.inbound.auth.oauth.version} provided - org.wso2.carbon.identity + org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth ${identity.inbound.auth.oauth.version} provided @@ -1105,6 +1110,12 @@ org.wso2.carbon.user.mgt ${carbon.commons.version} + + junit + junit + test + ${junit.version} + com.jayway.jsonpath json-path @@ -1243,7 +1254,7 @@ [2.0.0, 3.0.0) - 1.2.8 + 1.2.8-SNAPSHOT 3.0.4-SNAPSHOT @@ -1255,22 +1266,22 @@ 4.7.2 - 5.2.2 - 5.1.3 - 5.1.1 + 5.6.17 + 5.2.7 + 5.2.2 [5.2.2, 6.0.0) 4.6.1 - 4.5.8 + 4.6.0 - 4.6.5 + 4.7.0 - 6.0.5 + 6.1.2 3.0.4.wso2v1 @@ -1301,6 +1312,7 @@ 2.4 1.0.8 1.8 + 0.9.1 2.2 From 488c2abafaebb40b2d9c93d51d0994ef1436a524 Mon Sep 17 00:00:00 2001 From: Ace Date: Mon, 19 Dec 2016 15:24:02 +0530 Subject: [PATCH 2/5] removing slf4j from packing in the android devicemgt jaxrs --- .../org.wso2.carbon.device.mgt.mobile.android.api/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml index 8b6f4d71c8..a5388f0062 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml @@ -147,6 +147,12 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.core provided + + + org.slf4j + slf4j-api + + org.wso2.carbon.devicemgt From 0c2465d03e1b8224c7177dc165cbeb91a9c19493 Mon Sep 17 00:00:00 2001 From: charitha Date: Tue, 20 Dec 2016 23:48:21 +0530 Subject: [PATCH 3/5] Add enrollment invitations API EP for android --- .../services/DeviceManagementService.java | 52 ++++++++++++++ .../impl/DeviceManagementServiceImpl.java | 29 +++++++- .../android-enrollment-invitation.vm | 72 +++++++++++++++++++ .../src/main/resources/p2.inf | 3 +- 4 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/email/templates/android-enrollment-invitation.vm diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java index 5bf5fef24b..04fcb46774 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java @@ -33,6 +33,7 @@ import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ResponseHeader; 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.AndroidDevice; @@ -198,6 +199,57 @@ public interface DeviceManagementService { value = "Properties to update the device operations and their status.") List 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 @ApiOperation( produces = MediaType.APPLICATION_JSON, diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java index 4ca9b9b44d..815210af90 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java @@ -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.operation.mgt.Operation; 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.wrapper.AndroidApplication; 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.Pattern; 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.Response; import java.util.ArrayList; @@ -164,6 +173,24 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { 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 operations) throws OperationManagementException, PolicyComplianceException, ApplicationManagementException, NotificationManagementException, DeviceManagementException { diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/email/templates/android-enrollment-invitation.vm b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/email/templates/android-enrollment-invitation.vm new file mode 100644 index 0000000000..48d23fcb4f --- /dev/null +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/email/templates/android-enrollment-invitation.vm @@ -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. +*# + + You have been invited to enroll your Android device in WSO2 IoT + + + + WSO2 IoT Server + + +
+
+
+
+ WSO2 +
+
+
+

+ Hi $first-name, +

+ +

+ You have been invited to enrol your android device in WSO2 IoT Server. + Click here to begin device enrolment from + your Android device.

+ +

+ Should you need assistance, please contact your administrator. +

+ +

+ Regards, +

+ +

+ WSO2 IoT Administrator +

+
+
+ + + + +
WSO2
+
+
+
+ + + ]]> + +
diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf index 3ef1823484..ffd5fd2c6c 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf @@ -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.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}/email/templates,target:${installFolder}/../../../repository/resources/email-templates,overwrite:true);\ instructions.unconfigure = \ 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.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.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}/../../database/WSO2MobileAndroid_DB.h2.db);\ From 77b5d2422c5dcefdb5faa22433fa317d14db30ab Mon Sep 17 00:00:00 2001 From: madhawap Date: Thu, 22 Dec 2016 17:53:47 +0530 Subject: [PATCH 4/5] Task operation config related changes --- .../main/resources/devicetypes/android.xml | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml index 271dcd78b1..f3a949c116 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml @@ -24,16 +24,32 @@ en_US 1.0.0 - This End User License Agreement ("Agreement") is a legal agreement between you ("You") and WSO2, Inc., regarding the enrollment of Your personal mobile device ("Device") in SoR's mobile device management program, and the loading to and removal from Your Device and Your use of certain applications and any associated software and user documentation, whether provided in "online" or electronic format, used in connection with the operation of or provision of services to WSO2, Inc., BY SELECTING "I ACCEPT" DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE, AND THEREBY AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS DESCRIBED IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1) THIS IS A BINDING CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT. + This End User License Agreement ("Agreement") is a legal agreement between you ("You") and WSO2, + Inc., regarding the enrollment of Your personal mobile device ("Device") in SoR's mobile device + management program, and the loading to and removal from Your Device and Your use of certain + applications and any associated software and user documentation, whether provided in "online" or + electronic format, used in connection with the operation of or provision of services to WSO2, + Inc., BY SELECTING "I ACCEPT" DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE, AND THEREBY + AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS DESCRIBED + IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1) THIS IS A BINDING + CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT. IF YOU DO NOT ACCEPT THESE TERMS, DO NOT ENROLL YOUR DEVICE AND DO NOT PROCEED ANY FURTHER. - You agree that: (1) You understand and agree to be bound by the terms and conditions contained in this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter into this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right, without prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of Your Device, or (iii) the functioning of the Apps in the event of a violation of this Agreement or the cessation of Your relationship with SoR (including termination of Your employment if You are an employee or expiration or termination of Your applicable franchise or supply agreement if You are a franchisee of or supplier to the WSO2 WSO2, Inc., system). SoR expressly reserves all rights not expressly granted herein. + You agree that: (1) You understand and agree to be bound by the terms and conditions contained in + this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter into + this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right, without + prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of Your Device, or + (iii) the functioning of the Apps in the event of a violation of this Agreement or the cessation + of Your relationship with SoR (including termination of Your employment if You are an employee or + expiration or termination of Your applicable franchise or supply agreement if You are a franchisee + of or supplier to the WSO2 WSO2, Inc., system). SoR expressly reserves all rights not expressly + granted herein. - false + true @@ -314,13 +330,13 @@ Unlock the device - + //Name needs to be decided true - 60000 + 60000 //Name needs to be decided DEVICE_INFO - 1 + 1 //Name needs to be decided APPLICATION_LIST From a4841d87ba5739c4fb75a9ee1a7f792ac7c8c5ab Mon Sep 17 00:00:00 2001 From: charitha Date: Thu, 22 Dec 2016 18:31:05 +0530 Subject: [PATCH 5/5] Add custom email template for android --- .../services/DeviceManagementService.java | 77 ++++--------------- .../impl/DeviceManagementServiceImpl.java | 19 ----- .../android/util/AndroidAPIUtils.java | 14 +++- .../android-enrollment-invitation.vm | 6 +- 4 files changed, 30 insertions(+), 86 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java index 04fcb46774..4bf71b564a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java @@ -18,22 +18,20 @@ */ package org.wso2.carbon.mdm.services.android.services; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Extension; -import io.swagger.annotations.Tag; import io.swagger.annotations.Api; -import io.swagger.annotations.AuthorizationScope; -import io.swagger.annotations.Authorization; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.Authorization; +import io.swagger.annotations.AuthorizationScope; +import io.swagger.annotations.Extension; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Info; import io.swagger.annotations.ResponseHeader; - +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Tag; 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.AndroidDevice; @@ -41,7 +39,15 @@ import javax.validation.Valid; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; 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.Response; import java.util.List; @@ -199,57 +205,6 @@ public interface DeviceManagementService { value = "Properties to update the device operations and their status.") List 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 @ApiOperation( produces = MediaType.APPLICATION_JSON, diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java index 815210af90..409dcd758a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java @@ -29,7 +29,6 @@ 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.operation.mgt.Operation; 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.wrapper.AndroidApplication; import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice; @@ -173,24 +172,6 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { 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 operations) throws OperationManagementException, PolicyComplianceException, ApplicationManagementException, NotificationManagementException, DeviceManagementException { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java index 9e8d1306bd..9399eb9965 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java @@ -18,19 +18,27 @@ package org.wso2.carbon.mdm.services.android.util; -import com.google.gson.*; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.analytics.api.AnalyticsDataAPI; +import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse; import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry; -import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; import org.wso2.carbon.analytics.datasource.commons.Record; import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; -import org.wso2.carbon.device.mgt.common.*; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/email/templates/android-enrollment-invitation.vm b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/email/templates/android-enrollment-invitation.vm index 48d23fcb4f..206f74cc88 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/email/templates/android-enrollment-invitation.vm +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/email/templates/android-enrollment-invitation.vm @@ -34,12 +34,12 @@

- Hi $first-name, + Hi,

- You have been invited to enrol your android device in WSO2 IoT Server. - Click here to begin device enrolment from + You have been invited by $first-name to enrol your android device in WSO2 IoT Server. + Click here to begin device enrolment from your Android device.