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,
* 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) {

@ -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();

@ -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

@ -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) {

@ -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) {

Loading…
Cancel
Save