|
|
|
@ -11,9 +11,7 @@ import org.wso2.carbon.device.mgt.iot.digitaldisplay.constants.DigitalDisplayCon
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.ws.rs.*;
|
|
|
|
|
import javax.ws.rs.core.Context;
|
|
|
|
|
import javax.ws.rs.core.MediaType;
|
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created by nuwan on 11/13/15.
|
|
|
|
@ -48,15 +46,15 @@ public class DigitalDisplayControllerService {
|
|
|
|
|
*/
|
|
|
|
|
@Path("/restart-browser")
|
|
|
|
|
@POST
|
|
|
|
|
public void restartBrowser(@QueryParam("deviceId") String deviceId ,
|
|
|
|
|
@QueryParam("owner") String owner,
|
|
|
|
|
@QueryParam("sessionId") String sessionId,
|
|
|
|
|
public void restartBrowser(@FormParam("deviceId") String deviceId ,
|
|
|
|
|
@FormParam("owner") String owner,
|
|
|
|
|
@FormParam("sessionId") String sessionId,
|
|
|
|
|
@Context HttpServletResponse response){
|
|
|
|
|
|
|
|
|
|
log.info("Restrat Browser : " + deviceId);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId +":" + DigitalDisplayConstants.RESTART_BROWSER_CONSTANT,"");
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId +"::" + DigitalDisplayConstants.RESTART_BROWSER_CONSTANT + ":","");
|
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
log.error(e);
|
|
|
|
@ -79,15 +77,15 @@ public class DigitalDisplayControllerService {
|
|
|
|
|
*/
|
|
|
|
|
@Path("/close-browser")
|
|
|
|
|
@POST
|
|
|
|
|
public void closeBrowser(@QueryParam("deviceId") String deviceId,
|
|
|
|
|
@QueryParam("owner") String owner,
|
|
|
|
|
@QueryParam("sessionId") String sessionId,
|
|
|
|
|
public void closeBrowser(@FormParam("deviceId") String deviceId,
|
|
|
|
|
@FormParam("owner") String owner,
|
|
|
|
|
@FormParam("sessionId") String sessionId,
|
|
|
|
|
@Context HttpServletResponse response){
|
|
|
|
|
|
|
|
|
|
log.info("Close Browser : " + deviceId);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId +":" + DigitalDisplayConstants.CLOSE_BROWSER_CONSTANT ,"");
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId +"::" + DigitalDisplayConstants.CLOSE_BROWSER_CONSTANT + ":" ,"");
|
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
log.error(e);
|
|
|
|
@ -109,15 +107,15 @@ public class DigitalDisplayControllerService {
|
|
|
|
|
*/
|
|
|
|
|
@Path("/terminate-display")
|
|
|
|
|
@POST
|
|
|
|
|
public void terminateDisplay(@QueryParam("deviceId") String deviceId,
|
|
|
|
|
@QueryParam("owner") String owner,
|
|
|
|
|
@QueryParam("sessionId") String sessionId,
|
|
|
|
|
public void terminateDisplay(@FormParam("deviceId") String deviceId,
|
|
|
|
|
@FormParam("owner") String owner,
|
|
|
|
|
@FormParam("sessionId") String sessionId,
|
|
|
|
|
@Context HttpServletResponse response){
|
|
|
|
|
|
|
|
|
|
log.info("Terminate Display : " + deviceId);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId +":" + DigitalDisplayConstants.TERMINATE_DISPLAY_CONSTANT,"");
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId +"::" + DigitalDisplayConstants.TERMINATE_DISPLAY_CONSTANT +":" ,"");
|
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
log.error(e);
|
|
|
|
@ -139,15 +137,15 @@ public class DigitalDisplayControllerService {
|
|
|
|
|
*/
|
|
|
|
|
@Path("/restart-display")
|
|
|
|
|
@POST
|
|
|
|
|
public void restartDisplay(@QueryParam("deviceId") String deviceId,
|
|
|
|
|
@QueryParam("owner") String owner,
|
|
|
|
|
@QueryParam("sessionId") String sessionId,
|
|
|
|
|
public void restartDisplay(@FormParam("deviceId") String deviceId,
|
|
|
|
|
@FormParam("owner") String owner,
|
|
|
|
|
@FormParam("sessionId") String sessionId,
|
|
|
|
|
@Context HttpServletResponse response){
|
|
|
|
|
|
|
|
|
|
log.info("Restrat Display : " + deviceId);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId +":" + DigitalDisplayConstants.RESTART_DISPLAY_CONSTANT ,"");
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId +"::" + DigitalDisplayConstants.RESTART_DISPLAY_CONSTANT + ":" ,"");
|
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
log.error(e);
|
|
|
|
@ -171,21 +169,20 @@ public class DigitalDisplayControllerService {
|
|
|
|
|
* @param newValue page is used to replace path
|
|
|
|
|
*/
|
|
|
|
|
@Path("/edit-content")
|
|
|
|
|
@PUT
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public void editContent(@QueryParam("deviceId") String deviceId,
|
|
|
|
|
@QueryParam("owner") String owner,
|
|
|
|
|
@QueryParam("path") String path,
|
|
|
|
|
@QueryParam("attribute") String attribute,
|
|
|
|
|
@QueryParam("new-value") String newValue,
|
|
|
|
|
@QueryParam("sessionId") String sessionId,
|
|
|
|
|
@POST
|
|
|
|
|
public void editContent(@FormParam("deviceId") String deviceId,
|
|
|
|
|
@FormParam("owner") String owner,
|
|
|
|
|
@FormParam("path") String path,
|
|
|
|
|
@FormParam("attribute") String attribute,
|
|
|
|
|
@FormParam("new-value") String newValue,
|
|
|
|
|
@FormParam("sessionId") String sessionId,
|
|
|
|
|
@Context HttpServletResponse response){
|
|
|
|
|
|
|
|
|
|
log.info("Edit Content Display Id - " + deviceId + " by " + owner);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String params = path + File.separator + attribute + File.separator + newValue;
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + ":" + DigitalDisplayConstants.EDIT_SEQUENCE_CONSTANT,params);
|
|
|
|
|
String params = path + "|" + attribute + "|" + newValue;
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + "::" + DigitalDisplayConstants.EDIT_SEQUENCE_CONSTANT +":" ,params);
|
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
log.error(e);
|
|
|
|
@ -210,20 +207,20 @@ public class DigitalDisplayControllerService {
|
|
|
|
|
*/
|
|
|
|
|
@Path("/add-resource")
|
|
|
|
|
@POST
|
|
|
|
|
public void addNewResource(@QueryParam("deviceId") String deviceId,
|
|
|
|
|
@QueryParam("owner") String owner,
|
|
|
|
|
@QueryParam("type") String type,
|
|
|
|
|
@QueryParam("time") String time,
|
|
|
|
|
@QueryParam("path") String path,
|
|
|
|
|
@QueryParam("sessionId") String sessionId,
|
|
|
|
|
public void addNewResource(@FormParam("deviceId") String deviceId,
|
|
|
|
|
@FormParam("owner") String owner,
|
|
|
|
|
@FormParam("type") String type,
|
|
|
|
|
@FormParam("time") String time,
|
|
|
|
|
@FormParam("path") String path,
|
|
|
|
|
@FormParam("sessionId") String sessionId,
|
|
|
|
|
@Context HttpServletResponse response){
|
|
|
|
|
|
|
|
|
|
log.info("Add Sequence : " + deviceId);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String params = type + File.separator + time + File.separator + path;
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + ":" +
|
|
|
|
|
DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT,params);
|
|
|
|
|
String params = type + "|" + time + "|" + path;
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + "::" +
|
|
|
|
|
DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT +":" ,params);
|
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
log.error(e);
|
|
|
|
@ -248,22 +245,22 @@ public class DigitalDisplayControllerService {
|
|
|
|
|
*/
|
|
|
|
|
@Path("/add-resource-before")
|
|
|
|
|
@POST
|
|
|
|
|
public void addNewResourceBefore(@QueryParam("deviceId") String deviceId,
|
|
|
|
|
@QueryParam("owner") String owner,
|
|
|
|
|
@QueryParam("sessionId") String sessionId,
|
|
|
|
|
@QueryParam("type") String type,
|
|
|
|
|
@QueryParam("time") String time,
|
|
|
|
|
@QueryParam("path") String path,
|
|
|
|
|
@QueryParam("next-page") String nextPage,
|
|
|
|
|
public void addNewResourceBefore(@FormParam("deviceId") String deviceId,
|
|
|
|
|
@FormParam("owner") String owner,
|
|
|
|
|
@FormParam("sessionId") String sessionId,
|
|
|
|
|
@FormParam("type") String type,
|
|
|
|
|
@FormParam("time") String time,
|
|
|
|
|
@FormParam("path") String path,
|
|
|
|
|
@FormParam("next-page") String nextPage,
|
|
|
|
|
@Context HttpServletResponse response){
|
|
|
|
|
|
|
|
|
|
log.info("Add Sequence : " + deviceId);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String params = type + File.separator + time + File.separator + path +
|
|
|
|
|
File.separator + "before=" + nextPage;
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + ":" +
|
|
|
|
|
DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT,params);
|
|
|
|
|
String params = type + "|" + time + "|" + path +
|
|
|
|
|
"|" + "before=" + nextPage;
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + "::" +
|
|
|
|
|
DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT +":" ,params);
|
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
log.error(e);
|
|
|
|
@ -289,22 +286,22 @@ public class DigitalDisplayControllerService {
|
|
|
|
|
*/
|
|
|
|
|
@Path("/add-resource-next")
|
|
|
|
|
@POST
|
|
|
|
|
public void addNewResourceAfter(@QueryParam("deviceId") String deviceId,
|
|
|
|
|
@QueryParam("owner") String owner,
|
|
|
|
|
@QueryParam("type") String type,
|
|
|
|
|
@QueryParam("time") String time,
|
|
|
|
|
@QueryParam("path") String path,
|
|
|
|
|
@QueryParam("before-page") String beforePage,
|
|
|
|
|
@QueryParam("sessionId") String sessionId,
|
|
|
|
|
public void addNewResourceAfter(@FormParam("deviceId") String deviceId,
|
|
|
|
|
@FormParam("owner") String owner,
|
|
|
|
|
@FormParam("type") String type,
|
|
|
|
|
@FormParam("time") String time,
|
|
|
|
|
@FormParam("path") String path,
|
|
|
|
|
@FormParam("before-page") String beforePage,
|
|
|
|
|
@FormParam("sessionId") String sessionId,
|
|
|
|
|
@Context HttpServletResponse response){
|
|
|
|
|
|
|
|
|
|
log.info("Add Sequence : " + deviceId);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String params = type + File.separator + time + File.separator + path +
|
|
|
|
|
File.separator + "after=" + beforePage;
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + ":" +
|
|
|
|
|
DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT,params);
|
|
|
|
|
String params = type + "|" + time + "|" + path +
|
|
|
|
|
"|" + "after=" + beforePage;
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + "::" +
|
|
|
|
|
DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT + ":",params);
|
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
log.error(e);
|
|
|
|
@ -325,19 +322,18 @@ public class DigitalDisplayControllerService {
|
|
|
|
|
* @param path path of the page no need to delete
|
|
|
|
|
*/
|
|
|
|
|
@Path("/remove-resource")
|
|
|
|
|
@DELETE
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public void removeResource(@QueryParam("deviceId") String deviceId,
|
|
|
|
|
@QueryParam("owner") String owner,
|
|
|
|
|
@QueryParam("path") String path,
|
|
|
|
|
@QueryParam("sessionId") String sessionId,
|
|
|
|
|
@POST
|
|
|
|
|
public void removeResource(@FormParam("deviceId") String deviceId,
|
|
|
|
|
@FormParam("owner") String owner,
|
|
|
|
|
@FormParam("path") String path,
|
|
|
|
|
@FormParam("sessionId") String sessionId,
|
|
|
|
|
@Context HttpServletResponse response){
|
|
|
|
|
|
|
|
|
|
log.info("Remove Resource : " + deviceId);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + ":" +
|
|
|
|
|
DigitalDisplayConstants.REMOVE_RESOURCE_CONSTANT,path);
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + "::" +
|
|
|
|
|
DigitalDisplayConstants.REMOVE_RESOURCE_CONSTANT + ":",path);
|
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
log.error(e);
|
|
|
|
@ -359,18 +355,17 @@ public class DigitalDisplayControllerService {
|
|
|
|
|
* @param directoryName path of the folder need to delete
|
|
|
|
|
*/
|
|
|
|
|
@Path("/remove-directory")
|
|
|
|
|
@DELETE
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public void removeDirectory(@QueryParam("directory-name") String directoryName,
|
|
|
|
|
@QueryParam("deviceId") String deviceId ,
|
|
|
|
|
@QueryParam("owner") String owner,
|
|
|
|
|
@QueryParam("sessionId") String sessionId,
|
|
|
|
|
@POST
|
|
|
|
|
public void removeDirectory(@FormParam("directory-name") String directoryName,
|
|
|
|
|
@FormParam("deviceId") String deviceId ,
|
|
|
|
|
@FormParam("owner") String owner,
|
|
|
|
|
@FormParam("sessionId") String sessionId,
|
|
|
|
|
@Context HttpServletResponse response){
|
|
|
|
|
|
|
|
|
|
log.info("Remove Directory : " + deviceId);
|
|
|
|
|
try {
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + ":" +
|
|
|
|
|
DigitalDisplayConstants.REMOVE_DIRECTORY_CONSTANT,directoryName);
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + "::" +
|
|
|
|
|
DigitalDisplayConstants.REMOVE_DIRECTORY_CONSTANT + ":",directoryName);
|
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
log.error(e);
|
|
|
|
@ -393,19 +388,18 @@ public class DigitalDisplayControllerService {
|
|
|
|
|
* @param response response type of the method
|
|
|
|
|
*/
|
|
|
|
|
@Path("/remove-content")
|
|
|
|
|
@DELETE
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public void removeContent(@QueryParam("directory_name") String directoryName,
|
|
|
|
|
@QueryParam("content") String content,
|
|
|
|
|
@QueryParam("deviceId") String deviceId ,
|
|
|
|
|
@QueryParam("owner") String owner,
|
|
|
|
|
@QueryParam("sessionId") String sessionId,
|
|
|
|
|
@POST
|
|
|
|
|
public void removeContent(@FormParam("directory-name") String directoryName,
|
|
|
|
|
@FormParam("content") String content,
|
|
|
|
|
@FormParam("deviceId") String deviceId ,
|
|
|
|
|
@FormParam("owner") String owner,
|
|
|
|
|
@FormParam("sessionId") String sessionId,
|
|
|
|
|
@Context HttpServletResponse response){
|
|
|
|
|
|
|
|
|
|
log.info("Remove Content : " + deviceId);
|
|
|
|
|
try {
|
|
|
|
|
String param = directoryName + File.separator + content;
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + ":" + DigitalDisplayConstants.REMOVE_CONTENT_CONSTANT,param);
|
|
|
|
|
String param = directoryName + "|" + content;
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + "::" + DigitalDisplayConstants.REMOVE_CONTENT_CONSTANT + ":",param);
|
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
log.error(e);
|
|
|
|
@ -427,15 +421,15 @@ public class DigitalDisplayControllerService {
|
|
|
|
|
*/
|
|
|
|
|
@Path("/shutdown-display")
|
|
|
|
|
@POST
|
|
|
|
|
public void shutDownDisplay(@QueryParam("deviceId") String deviceId,
|
|
|
|
|
@QueryParam("owner") String owner,
|
|
|
|
|
@QueryParam("sessionId") String sessionId,
|
|
|
|
|
public void shutDownDisplay(@FormParam("deviceId") String deviceId,
|
|
|
|
|
@FormParam("owner") String owner,
|
|
|
|
|
@FormParam("sessionId") String sessionId,
|
|
|
|
|
@Context HttpServletResponse response){
|
|
|
|
|
|
|
|
|
|
log.info("Shut down display : " + deviceId);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + ":" + DigitalDisplayConstants.SHUTDOWN_DISPLAY_CONSTANT,"");
|
|
|
|
|
sendCommandViaMQTT(owner,deviceId,sessionId + "::" + DigitalDisplayConstants.SHUTDOWN_DISPLAY_CONSTANT + ":" ,"");
|
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
log.error(e);
|
|
|
|
@ -457,9 +451,9 @@ public class DigitalDisplayControllerService {
|
|
|
|
|
*/
|
|
|
|
|
@Path("/get-status")
|
|
|
|
|
@GET
|
|
|
|
|
public void getStatus(@QueryParam("deviceId") String deviceId,
|
|
|
|
|
@QueryParam("owner") String owner,
|
|
|
|
|
@QueryParam("sessionId") String sessionId,
|
|
|
|
|
public void getStatus(@FormParam("deviceId") String deviceId,
|
|
|
|
|
@FormParam("owner") String owner,
|
|
|
|
|
@FormParam("sessionId") String sessionId,
|
|
|
|
|
@Context HttpServletResponse response){
|
|
|
|
|
|
|
|
|
|
log.info("Status : " + deviceId);
|
|
|
|
|