wso2wso2-iot

wso2 emm mdm-admin Rest webservices


Good day all,

I am having problems adding Rest Services to mdm-admin

I had some troubles with mdm-android-* I created the service and reference in the permission.xml file

Creating a rest service in mdm-admin it has sefinitin as below

@GET
@Path("{type}/{id}/logs")
public List<? extends Application> getDeviceLogs(

    @PathParam("type") String type,
    @PathParam("id") String id)
        throws MDMAPIException {

        List<Application> applications;
        ApplicationManagementProviderService appManagerConnector;
        DeviceIdentifier deviceIdentifier = new DeviceIdentifier();

        try {

            deviceIdentifier.setType(type);
            deviceIdentifier.setId(id);
            appManagerConnector = MDMAPIUtils.getAppManagementService();

            applications = appManagerConnector.getApplicationListForDevice(deviceIdentifier);

        } catch (ApplicationManagementException e) {

            String msg = "Error occurred while fetching the apps of the device.";
            log.error(msg, e);
            throw new MDMAPIException(msg, e);
        }
        return applications;
    }
}

It is a clone of the get list of application method with just the path and function name changed.

When I deploy it. my webapp returns a 404 error status Code. when I try to call the function

To replicate this, Download v2.0.1 Open with Netbeans, Modify WSO2 MDM - Mobile Device Management Admin Services Copy and paste one of the rest functions, rename the function Deploy and call that new function

How can I resolve this?


Solution

  • Your code snippet is working for me without any issue. You need to add permission entry in permission.xml as follows to make this work

    <Permission>
        <name>log device</name>
        <path>/device-mgt/emm-admin/devices/logs</path>
        <url>/operations/*/*/logs</url>
        <method>GET</method>
    </Permission>
    

    The curl command I used is as below. don't forget to add a content type as application/json.

    curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer 3c28103c1992c9e57d7091fb9f38732e" -k -v https://localhost:9443/mdm-admin/operations/android/000000000000000/logs