Merge pull request #93 from menaka121/IoTS-1.0.0-M1

Add resource method change
Ruwan 9 years ago
commit 4e99dee4da

@ -247,98 +247,20 @@ public class DigitalDisplayControllerService {
@FormParam("type") String type, @FormParam("type") String type,
@FormParam("time") String time, @FormParam("time") String time,
@FormParam("path") String path, @FormParam("path") String path,
@FormParam("position") String position,
@HeaderParam("sessionId") String sessionId, @HeaderParam("sessionId") String sessionId,
@Context HttpServletResponse response) { @Context HttpServletResponse response) {
log.info("Add Sequence : " + deviceId); log.info("Add Sequence : " + deviceId);
String params;
try { try {
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);
response.setStatus(Response.Status.UNAUTHORIZED.getStatusCode());
} catch (DigitalDisplayException e) {
log.error(e);
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
}
}
/** if (position.isEmpty()){
* Add new resource to sequence before given page no params = type + "|" + time + "|" + path;
* } else {
* @param deviceId id of the controlling digital display params = type + "|" + time + "|" + path +
* @param owner owner of the digital display "|" + "after=" + position;
* @param sessionId web socket id of the method invoke client }
* @param response response type of the method
* @param type type of the new resource
* @param time new resource visible time
* @param path URL of the new resource
* @param nextPage next page no of after adding new resource
*/
@Path("/add-resource-before")
@POST
@Feature(code = "add-resource-before", name = "Add Resource Before", type="operation",
description = "Add new resource to sequence before given page no. in Digital Display")
public void addNewResourceBefore(@HeaderParam("deviceId") String deviceId,
@HeaderParam("owner") String owner,
@HeaderParam("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 + "|" + 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);
response.setStatus(Response.Status.UNAUTHORIZED.getStatusCode());
} catch (DigitalDisplayException e) {
log.error(e);
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
}
}
/**
* Add new resource to sequence after given page
*
* @param deviceId id of the controlling digital display
* @param owner owner of the digital display
* @param sessionId web socket id of the method invoke client
* @param response response type of the method
* @param type type of the new resource
* @param time new resource visible time
* @param path URL of the new resource
* @param beforePage before page no of after adding new resource
*/
@Path("/add-resource-next")
@POST
@Feature(code = "add-resource-next", name = "Add Resource Next", type="operation",
description = "Add new resource to sequence after given page in Digital Display")
public void addNewResourceAfter(@HeaderParam("deviceId") String deviceId,
@HeaderParam("owner") String owner,
@FormParam("type") String type,
@FormParam("time") String time,
@FormParam("path") String path,
@FormParam("before-page") String beforePage,
@HeaderParam("sessionId") String sessionId,
@Context HttpServletResponse response) {
log.info("Add Sequence : " + deviceId);
try {
String params = type + "|" + time + "|" + path +
"|" + "after=" + beforePage;
sendCommandViaMQTT(owner, deviceId, sessionId + "::" + sendCommandViaMQTT(owner, deviceId, sessionId + "::" +
DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT + ":", params); DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT + ":", params);
response.setStatus(Response.Status.OK.getStatusCode()); response.setStatus(Response.Status.OK.getStatusCode());

Loading…
Cancel
Save