Remove appending device id from device name

charithag 9 years ago
parent 8106b42c0f
commit 93f475a30f

@ -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, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
@ -361,18 +361,18 @@ public class ArduinoService {
/** /**
* @param owner * @param owner
* @param customDeviceName * @param deviceName
* @param sketchType * @param sketchType
* @return * @return
*/ */
@Path("manager/device/{sketch_type}/generate_link") @Path("manager/device/{sketch_type}/generate_link")
@GET @GET
public Response generateSketchLink(@QueryParam("owner") String owner, public Response generateSketchLink(@QueryParam("owner") String owner,
@QueryParam("deviceName") String customDeviceName, @QueryParam("deviceName") String deviceName,
@PathParam("sketch_type") String sketchType) { @PathParam("sketch_type") String sketchType) {
try { try {
ZipArchive zipFile = createDownloadFile(owner, customDeviceName, sketchType); ZipArchive zipFile = createDownloadFile(owner, deviceName, sketchType);
Response.ResponseBuilder rb = Response.ok(zipFile.getDeviceId()); Response.ResponseBuilder rb = Response.ok(zipFile.getDeviceId());
return rb.build(); return rb.build();
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
@ -389,14 +389,14 @@ public class ArduinoService {
/** /**
* @param owner * @param owner
* @param customDeviceName * @param deviceName
* @param sketchType * @param sketchType
* @return * @return
* @throws DeviceManagementException * @throws DeviceManagementException
* @throws AccessTokenException * @throws AccessTokenException
* @throws DeviceControllerException * @throws DeviceControllerException
*/ */
private ZipArchive createDownloadFile(String owner, String customDeviceName, String sketchType) private ZipArchive createDownloadFile(String owner, String deviceName, String sketchType)
throws DeviceManagementException, AccessTokenException, DeviceControllerException { throws DeviceManagementException, AccessTokenException, DeviceControllerException {
if (owner == null) { if (owner == null) {
throw new IllegalArgumentException("Error on createDownloadFile() Owner is null!"); throw new IllegalArgumentException("Error on createDownloadFile() Owner is null!");
@ -415,7 +415,6 @@ public class ArduinoService {
String refreshToken = accessTokenInfo.getRefresh_token(); String refreshToken = accessTokenInfo.getRefresh_token();
//Register the device with CDMF //Register the device with CDMF
String deviceName = customDeviceName + "_" + deviceId;
boolean status = register(deviceId, deviceName, owner); boolean status = register(deviceId, deviceName, owner);
if (!status) { if (!status) {

@ -1,17 +1,19 @@
/* /*
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * WSO2 Inc. licenses this file to you under the Apache License,
* you may not use this file except in compliance with the 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 * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing,
* distributed under the License is distributed on an "AS IS" BASIS, * software distributed under the License is distributed on an
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* See the License for the specific language governing permissions and * KIND, either express or implied. See the License for the
* limitations under the License. * specific language governing permissions and limitations
* under the License.
*/ */
package org.wso2.carbon.device.mgt.iot.digitaldisplay.api; package org.wso2.carbon.device.mgt.iot.digitaldisplay.api;
@ -197,7 +199,7 @@ public class DigitalDisplayManagerService {
@GET @GET
@Produces("application/octet-stream") @Produces("application/octet-stream")
public Response downloadSketch(@QueryParam("owner") String owner, public Response downloadSketch(@QueryParam("owner") String owner,
@QueryParam("deviceName") String customDeviceName, @QueryParam("deviceName") String deviceName,
@PathParam("sketch_type") String @PathParam("sketch_type") String
sketchType) { sketchType) {
@ -213,8 +215,7 @@ public class DigitalDisplayManagerService {
String refreshToken = UUID.randomUUID().toString(); String refreshToken = UUID.randomUUID().toString();
//adding registering data //adding registering data
String deviceName = customDeviceName + "_" + deviceId; boolean status = register(deviceId, deviceName, owner);
boolean status = register(deviceId, customDeviceName, owner);
if (!status) { if (!status) {
return Response.status(500).entity( return Response.status(500).entity(
"Error occurred while registering the device with " + "id: " + deviceId "Error occurred while registering the device with " + "id: " + deviceId
@ -225,7 +226,7 @@ public class DigitalDisplayManagerService {
ZipUtil ziputil = new ZipUtil(); ZipUtil ziputil = new ZipUtil();
ZipArchive zipFile = null; ZipArchive zipFile = null;
try { try {
zipFile = ziputil.createZipFile(owner, SUPER_TENANT, sketchType, deviceId, customDeviceName, token, zipFile = ziputil.createZipFile(owner, SUPER_TENANT, sketchType, deviceId, deviceName, token,
refreshToken); refreshToken);
} catch (DeviceManagementException ex) { } catch (DeviceManagementException ex) {
return Response.status(500).entity("Error occurred while creating zip file").build(); return Response.status(500).entity("Error occurred while creating zip file").build();

@ -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, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * 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") @Path("manager/device/{sketch_type}/download")
@GET @GET
@Produces("application/octet-stream") @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) { @PathParam("sketch_type") String sketchType) {
if (owner == null) { if (owner == null) {
return Response.status(400).build();//bad request return Response.status(400).build();//bad request
@ -237,8 +237,7 @@ public class DroneService {
String refreshToken = UUID.randomUUID().toString(); String refreshToken = UUID.randomUUID().toString();
//adding registering data //adding registering data
String deviceName = customDeviceName + "_" + deviceId; boolean status = register(deviceId, deviceName, owner);
boolean status = register(deviceId, customDeviceName, owner);
if (!status) { if (!status) {
return Response.status(500).entity( return Response.status(500).entity(
"Error occurred while registering the device with " + "id: " + deviceId "Error occurred while registering the device with " + "id: " + deviceId
@ -247,9 +246,9 @@ public class DroneService {
} }
ZipUtil ziputil = new ZipUtil(); ZipUtil ziputil = new ZipUtil();
ZipArchive zipFile = null; ZipArchive zipFile;
try { try {
zipFile = ziputil.createZipFile(owner, SUPER_TENANT, sketchType, deviceId, customDeviceName, token, zipFile = ziputil.createZipFile(owner, SUPER_TENANT, sketchType, deviceId, deviceName, token,
refreshToken); refreshToken);
} catch (DeviceManagementException ex) { } catch (DeviceManagementException ex) {
return Response.status(500).entity("Error occurred while creating zip file").build(); 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") @Path("manager/device/{sketch_type}/generate_link")
@GET @GET
public Response generateSketchLink(@QueryParam("owner") String owner, public Response generateSketchLink(@QueryParam("owner") String owner,
@QueryParam("deviceName") String customDeviceName, @QueryParam("deviceName") String deviceName,
@PathParam("sketch_type") String sketchType) { @PathParam("sketch_type") String sketchType) {
try { try {
ZipArchive zipFile = createDownloadFile(owner, customDeviceName, sketchType); ZipArchive zipFile = createDownloadFile(owner, deviceName, sketchType);
Response.ResponseBuilder rb = Response.ok(zipFile.getDeviceId()); Response.ResponseBuilder rb = Response.ok(zipFile.getDeviceId());
return rb.build(); return rb.build();
} catch (IllegalArgumentException ex) { } 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 { throws DeviceManagementException, AccessTokenException, DeviceControllerException {
if (owner == null) { if (owner == null) {
throw new IllegalArgumentException("Error on createDownloadFile() Owner is null!"); throw new IllegalArgumentException("Error on createDownloadFile() Owner is null!");
@ -318,7 +317,6 @@ public class DroneService {
} }
} }
//Register the device with CDMF //Register the device with CDMF
String deviceName = customDeviceName + "_" + deviceId;
status = register(deviceId, deviceName, owner); status = register(deviceId, deviceName, owner);
if (!status) { if (!status) {
String msg = "Error occurred while registering the device with " + "id: " + deviceId String msg = "Error occurred while registering the device with " + "id: " + deviceId

@ -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, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
@ -277,12 +277,12 @@ public class RaspberryPiService {
@GET @GET
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public Response downloadSketch(@QueryParam("owner") String owner, public Response downloadSketch(@QueryParam("owner") String owner,
@QueryParam("deviceName") String customDeviceName, @QueryParam("deviceName") String deviceName,
@PathParam("sketch_type") String @PathParam("sketch_type") String
sketchType) { sketchType) {
try { try {
ZipArchive zipFile = createDownloadFile(owner, customDeviceName, sketchType); ZipArchive zipFile = createDownloadFile(owner, deviceName, sketchType);
Response.ResponseBuilder response = Response.ok(FileUtils.readFileToByteArray(zipFile.getZipFile())); Response.ResponseBuilder response = Response.ok(FileUtils.readFileToByteArray(zipFile.getZipFile()));
response.type("application/zip"); response.type("application/zip");
response.header("Content-Disposition", "attachment; filename=\"" + zipFile.getFileName() + "\""); response.header("Content-Disposition", "attachment; filename=\"" + zipFile.getFileName() + "\"");
@ -305,11 +305,11 @@ public class RaspberryPiService {
@Path("manager/device/{sketch_type}/generate_link") @Path("manager/device/{sketch_type}/generate_link")
@GET @GET
public Response generateSketchLink(@QueryParam("owner") String owner, public Response generateSketchLink(@QueryParam("owner") String owner,
@QueryParam("deviceName") String customDeviceName, @QueryParam("deviceName") String deviceName,
@PathParam("sketch_type") String sketchType) { @PathParam("sketch_type") String sketchType) {
try { try {
ZipArchive zipFile = createDownloadFile(owner, customDeviceName, sketchType); ZipArchive zipFile = createDownloadFile(owner, deviceName, sketchType);
Response.ResponseBuilder rb = Response.ok(zipFile.getDeviceId()); Response.ResponseBuilder rb = Response.ok(zipFile.getDeviceId());
return rb.build(); return rb.build();
} catch (IllegalArgumentException ex) { } 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 { throws DeviceManagementException, AccessTokenException, DeviceControllerException {
if (owner == null) { if (owner == null) {
throw new IllegalArgumentException("Error on createDownloadFile() Owner is null!"); throw new IllegalArgumentException("Error on createDownloadFile() Owner is null!");
@ -366,7 +366,6 @@ public class RaspberryPiService {
} }
//Register the device with CDMF //Register the device with CDMF
String deviceName = customDeviceName + "_" + deviceId;
status = register(deviceId, deviceName, owner); status = register(deviceId, deviceName, owner);
if (!status) { if (!status) {

@ -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, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
@ -264,7 +264,7 @@ public class VirtualFireAlarmService {
/** /**
* @param owner * @param owner
* @param customDeviceName * @param deviceName
* @param sketchType * @param sketchType
* @return * @return
*/ */
@ -273,10 +273,10 @@ public class VirtualFireAlarmService {
@GET @GET
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public Response downloadSketch(@QueryParam("owner") String owner, public Response downloadSketch(@QueryParam("owner") String owner,
@QueryParam("deviceName") String customDeviceName, @QueryParam("deviceName") String deviceName,
@PathParam("sketch_type") String sketchType) { @PathParam("sketch_type") String sketchType) {
try { try {
ZipArchive zipFile = createDownloadFile(owner, customDeviceName, sketchType); ZipArchive zipFile = createDownloadFile(owner, deviceName, sketchType);
Response.ResponseBuilder response = Response.ok(FileUtils.readFileToByteArray(zipFile.getZipFile())); Response.ResponseBuilder response = Response.ok(FileUtils.readFileToByteArray(zipFile.getZipFile()));
response.type("application/zip"); response.type("application/zip");
response.header("Content-Disposition", "attachment; filename=\"" + zipFile.getFileName() + "\""); response.header("Content-Disposition", "attachment; filename=\"" + zipFile.getFileName() + "\"");
@ -297,18 +297,18 @@ public class VirtualFireAlarmService {
/** /**
* @param owner * @param owner
* @param customDeviceName * @param deviceName
* @param sketchType * @param sketchType
* @return * @return
*/ */
@Path("manager/device/{sketch_type}/generate_link") @Path("manager/device/{sketch_type}/generate_link")
@GET @GET
public Response generateSketchLink(@QueryParam("owner") String owner, public Response generateSketchLink(@QueryParam("owner") String owner,
@QueryParam("deviceName") String customDeviceName, @QueryParam("deviceName") String deviceName,
@PathParam("sketch_type") String sketchType) { @PathParam("sketch_type") String sketchType) {
try { try {
ZipArchive zipFile = createDownloadFile(owner, customDeviceName, sketchType); ZipArchive zipFile = createDownloadFile(owner, deviceName, sketchType);
Response.ResponseBuilder rb = Response.ok(zipFile.getDeviceId()); Response.ResponseBuilder rb = Response.ok(zipFile.getDeviceId());
return rb.build(); return rb.build();
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
@ -324,14 +324,14 @@ public class VirtualFireAlarmService {
/** /**
* @param owner * @param owner
* @param customDeviceName * @param deviceName
* @param sketchType * @param sketchType
* @return * @return
* @throws DeviceManagementException * @throws DeviceManagementException
* @throws AccessTokenException * @throws AccessTokenException
* @throws DeviceControllerException * @throws DeviceControllerException
*/ */
private ZipArchive createDownloadFile(String owner, String customDeviceName, String sketchType) private ZipArchive createDownloadFile(String owner, String deviceName, String sketchType)
throws DeviceManagementException, AccessTokenException, DeviceControllerException { throws DeviceManagementException, AccessTokenException, DeviceControllerException {
if (owner == null) { if (owner == null) {
throw new IllegalArgumentException("Error on createDownloadFile() Owner is null!"); throw new IllegalArgumentException("Error on createDownloadFile() Owner is null!");
@ -373,7 +373,6 @@ public class VirtualFireAlarmService {
} }
//Register the device with CDMF //Register the device with CDMF
String deviceName = customDeviceName + "_" + deviceId;
status = register(deviceId, deviceName, owner); status = register(deviceId, deviceName, owner);
if (!status) { if (!status) {

Loading…
Cancel
Save