From 93f475a30ffce30486979a71b6073be0ee492df8 Mon Sep 17 00:00:00 2001 From: charithag Date: Tue, 5 Jan 2016 14:57:44 +0530 Subject: [PATCH] Remove appending device id from device name --- .../iot/arduino/service/ArduinoService.java | 13 ++++---- .../api/DigitalDisplayManagerService.java | 31 ++++++++++--------- .../droneanalyzer/service/DroneService.java | 18 +++++------ .../service/RaspberryPiService.java | 15 +++++---- .../service/VirtualFireAlarmService.java | 19 ++++++------ 5 files changed, 46 insertions(+), 50 deletions(-) diff --git a/components/device-mgt-iot-arduino/org.wso2.carbon.device.mgt.iot.arduino.mgt.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/ArduinoService.java b/components/device-mgt-iot-arduino/org.wso2.carbon.device.mgt.iot.arduino.mgt.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/ArduinoService.java index 46c8a90a57..d20540209a 100644 --- a/components/device-mgt-iot-arduino/org.wso2.carbon.device.mgt.iot.arduino.mgt.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/ArduinoService.java +++ b/components/device-mgt-iot-arduino/org.wso2.carbon.device.mgt.iot.arduino.mgt.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/ArduinoService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * 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 @@ -361,18 +361,18 @@ public class ArduinoService { /** * @param owner - * @param customDeviceName + * @param deviceName * @param sketchType * @return */ @Path("manager/device/{sketch_type}/generate_link") @GET public Response generateSketchLink(@QueryParam("owner") String owner, - @QueryParam("deviceName") String customDeviceName, + @QueryParam("deviceName") String deviceName, @PathParam("sketch_type") String sketchType) { try { - ZipArchive zipFile = createDownloadFile(owner, customDeviceName, sketchType); + ZipArchive zipFile = createDownloadFile(owner, deviceName, sketchType); Response.ResponseBuilder rb = Response.ok(zipFile.getDeviceId()); return rb.build(); } catch (IllegalArgumentException ex) { @@ -389,14 +389,14 @@ public class ArduinoService { /** * @param owner - * @param customDeviceName + * @param deviceName * @param sketchType * @return * @throws DeviceManagementException * @throws AccessTokenException * @throws DeviceControllerException */ - private ZipArchive createDownloadFile(String owner, String customDeviceName, String sketchType) + private ZipArchive createDownloadFile(String owner, String deviceName, String sketchType) throws DeviceManagementException, AccessTokenException, DeviceControllerException { if (owner == null) { throw new IllegalArgumentException("Error on createDownloadFile() Owner is null!"); @@ -415,7 +415,6 @@ public class ArduinoService { String refreshToken = accessTokenInfo.getRefresh_token(); //Register the device with CDMF - String deviceName = customDeviceName + "_" + deviceId; boolean status = register(deviceId, deviceName, owner); if (!status) { diff --git a/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay.mgt.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/api/DigitalDisplayManagerService.java b/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay.mgt.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/api/DigitalDisplayManagerService.java index 9ae0445f2a..aab8a662d4 100644 --- a/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay.mgt.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/api/DigitalDisplayManagerService.java +++ b/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay.mgt.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/api/DigitalDisplayManagerService.java @@ -1,17 +1,19 @@ /* - * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * 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. + * + * 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.device.mgt.iot.digitaldisplay.api; @@ -197,7 +199,7 @@ public class DigitalDisplayManagerService { @GET @Produces("application/octet-stream") public Response downloadSketch(@QueryParam("owner") String owner, - @QueryParam("deviceName") String customDeviceName, + @QueryParam("deviceName") String deviceName, @PathParam("sketch_type") String sketchType) { @@ -213,8 +215,7 @@ public class DigitalDisplayManagerService { String refreshToken = UUID.randomUUID().toString(); //adding registering data - String deviceName = customDeviceName + "_" + deviceId; - boolean status = register(deviceId, customDeviceName, owner); + boolean status = register(deviceId, deviceName, owner); if (!status) { return Response.status(500).entity( "Error occurred while registering the device with " + "id: " + deviceId @@ -225,7 +226,7 @@ public class DigitalDisplayManagerService { ZipUtil ziputil = new ZipUtil(); ZipArchive zipFile = null; try { - zipFile = ziputil.createZipFile(owner, SUPER_TENANT, sketchType, deviceId, customDeviceName, token, + zipFile = ziputil.createZipFile(owner, SUPER_TENANT, sketchType, deviceId, deviceName, token, refreshToken); } catch (DeviceManagementException ex) { return Response.status(500).entity("Error occurred while creating zip file").build(); diff --git a/components/device-mgt-iot-droneanalyzer/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/DroneService.java b/components/device-mgt-iot-droneanalyzer/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/DroneService.java index 7b22645fee..96ea3bce4d 100644 --- a/components/device-mgt-iot-droneanalyzer/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/DroneService.java +++ b/components/device-mgt-iot-droneanalyzer/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/DroneService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * 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 @@ -223,7 +223,7 @@ public class DroneService { @Path("manager/device/{sketch_type}/download") @GET @Produces("application/octet-stream") - public Response downloadSketch(@QueryParam("owner") String owner, @QueryParam("deviceName") String customDeviceName, + public Response downloadSketch(@QueryParam("owner") String owner, @QueryParam("deviceName") String deviceName, @PathParam("sketch_type") String sketchType) { if (owner == null) { return Response.status(400).build();//bad request @@ -237,8 +237,7 @@ public class DroneService { String refreshToken = UUID.randomUUID().toString(); //adding registering data - String deviceName = customDeviceName + "_" + deviceId; - boolean status = register(deviceId, customDeviceName, owner); + boolean status = register(deviceId, deviceName, owner); if (!status) { return Response.status(500).entity( "Error occurred while registering the device with " + "id: " + deviceId @@ -247,9 +246,9 @@ public class DroneService { } ZipUtil ziputil = new ZipUtil(); - ZipArchive zipFile = null; + ZipArchive zipFile; try { - zipFile = ziputil.createZipFile(owner, SUPER_TENANT, sketchType, deviceId, customDeviceName, token, + zipFile = ziputil.createZipFile(owner, SUPER_TENANT, sketchType, deviceId, deviceName, token, refreshToken); } catch (DeviceManagementException ex) { return Response.status(500).entity("Error occurred while creating zip file").build(); @@ -263,10 +262,10 @@ public class DroneService { @Path("manager/device/{sketch_type}/generate_link") @GET public Response generateSketchLink(@QueryParam("owner") String owner, - @QueryParam("deviceName") String customDeviceName, + @QueryParam("deviceName") String deviceName, @PathParam("sketch_type") String sketchType) { try { - ZipArchive zipFile = createDownloadFile(owner, customDeviceName, sketchType); + ZipArchive zipFile = createDownloadFile(owner, deviceName, sketchType); Response.ResponseBuilder rb = Response.ok(zipFile.getDeviceId()); return rb.build(); } catch (IllegalArgumentException ex) { @@ -280,7 +279,7 @@ public class DroneService { } } - private ZipArchive createDownloadFile(String owner, String customDeviceName, String sketchType) + private ZipArchive createDownloadFile(String owner, String deviceName, String sketchType) throws DeviceManagementException, AccessTokenException, DeviceControllerException { if (owner == null) { throw new IllegalArgumentException("Error on createDownloadFile() Owner is null!"); @@ -318,7 +317,6 @@ public class DroneService { } } //Register the device with CDMF - String deviceName = customDeviceName + "_" + deviceId; status = register(deviceId, deviceName, owner); if (!status) { String msg = "Error occurred while registering the device with " + "id: " + deviceId diff --git a/components/device-mgt-iot-raspberrypi/org.wso2.carbon.device.mgt.iot.raspberrypi.mgt.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/RaspberryPiService.java b/components/device-mgt-iot-raspberrypi/org.wso2.carbon.device.mgt.iot.raspberrypi.mgt.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/RaspberryPiService.java index adf2a5e1a3..484b0ce8e8 100644 --- a/components/device-mgt-iot-raspberrypi/org.wso2.carbon.device.mgt.iot.raspberrypi.mgt.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/RaspberryPiService.java +++ b/components/device-mgt-iot-raspberrypi/org.wso2.carbon.device.mgt.iot.raspberrypi.mgt.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/RaspberryPiService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * 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 @@ -11,7 +11,7 @@ * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -277,12 +277,12 @@ public class RaspberryPiService { @GET @Produces(MediaType.APPLICATION_JSON) public Response downloadSketch(@QueryParam("owner") String owner, - @QueryParam("deviceName") String customDeviceName, + @QueryParam("deviceName") String deviceName, @PathParam("sketch_type") String sketchType) { try { - ZipArchive zipFile = createDownloadFile(owner, customDeviceName, sketchType); + ZipArchive zipFile = createDownloadFile(owner, deviceName, sketchType); Response.ResponseBuilder response = Response.ok(FileUtils.readFileToByteArray(zipFile.getZipFile())); response.type("application/zip"); response.header("Content-Disposition", "attachment; filename=\"" + zipFile.getFileName() + "\""); @@ -305,11 +305,11 @@ public class RaspberryPiService { @Path("manager/device/{sketch_type}/generate_link") @GET public Response generateSketchLink(@QueryParam("owner") String owner, - @QueryParam("deviceName") String customDeviceName, + @QueryParam("deviceName") String deviceName, @PathParam("sketch_type") String sketchType) { try { - ZipArchive zipFile = createDownloadFile(owner, customDeviceName, sketchType); + ZipArchive zipFile = createDownloadFile(owner, deviceName, sketchType); Response.ResponseBuilder rb = Response.ok(zipFile.getDeviceId()); return rb.build(); } catch (IllegalArgumentException ex) { @@ -324,7 +324,7 @@ public class RaspberryPiService { } - private ZipArchive createDownloadFile(String owner, String customDeviceName, String sketchType) + private ZipArchive createDownloadFile(String owner, String deviceName, String sketchType) throws DeviceManagementException, AccessTokenException, DeviceControllerException { if (owner == null) { throw new IllegalArgumentException("Error on createDownloadFile() Owner is null!"); @@ -366,7 +366,6 @@ public class RaspberryPiService { } //Register the device with CDMF - String deviceName = customDeviceName + "_" + deviceId; status = register(deviceId, deviceName, owner); if (!status) { diff --git a/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.mgt.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/VirtualFireAlarmService.java b/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.mgt.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/VirtualFireAlarmService.java index 05c0e95e9a..92440237b3 100644 --- a/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.mgt.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/VirtualFireAlarmService.java +++ b/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.mgt.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/VirtualFireAlarmService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * 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 @@ -264,7 +264,7 @@ public class VirtualFireAlarmService { /** * @param owner - * @param customDeviceName + * @param deviceName * @param sketchType * @return */ @@ -273,10 +273,10 @@ public class VirtualFireAlarmService { @GET @Produces(MediaType.APPLICATION_JSON) public Response downloadSketch(@QueryParam("owner") String owner, - @QueryParam("deviceName") String customDeviceName, + @QueryParam("deviceName") String deviceName, @PathParam("sketch_type") String sketchType) { try { - ZipArchive zipFile = createDownloadFile(owner, customDeviceName, sketchType); + ZipArchive zipFile = createDownloadFile(owner, deviceName, sketchType); Response.ResponseBuilder response = Response.ok(FileUtils.readFileToByteArray(zipFile.getZipFile())); response.type("application/zip"); response.header("Content-Disposition", "attachment; filename=\"" + zipFile.getFileName() + "\""); @@ -297,18 +297,18 @@ public class VirtualFireAlarmService { /** * @param owner - * @param customDeviceName + * @param deviceName * @param sketchType * @return */ @Path("manager/device/{sketch_type}/generate_link") @GET public Response generateSketchLink(@QueryParam("owner") String owner, - @QueryParam("deviceName") String customDeviceName, + @QueryParam("deviceName") String deviceName, @PathParam("sketch_type") String sketchType) { try { - ZipArchive zipFile = createDownloadFile(owner, customDeviceName, sketchType); + ZipArchive zipFile = createDownloadFile(owner, deviceName, sketchType); Response.ResponseBuilder rb = Response.ok(zipFile.getDeviceId()); return rb.build(); } catch (IllegalArgumentException ex) { @@ -324,14 +324,14 @@ public class VirtualFireAlarmService { /** * @param owner - * @param customDeviceName + * @param deviceName * @param sketchType * @return * @throws DeviceManagementException * @throws AccessTokenException * @throws DeviceControllerException */ - private ZipArchive createDownloadFile(String owner, String customDeviceName, String sketchType) + private ZipArchive createDownloadFile(String owner, String deviceName, String sketchType) throws DeviceManagementException, AccessTokenException, DeviceControllerException { if (owner == null) { throw new IllegalArgumentException("Error on createDownloadFile() Owner is null!"); @@ -373,7 +373,6 @@ public class VirtualFireAlarmService { } //Register the device with CDMF - String deviceName = customDeviceName + "_" + deviceId; status = register(deviceId, deviceName, owner); if (!status) {