Blame | Last modification | View Log | RSS feed
package com.hotspotstore.controllers;import org.json.JSONObject;import com.hotspotstore.storage.Mongo;public class ProductsController extends BaseController{/****/private static final long serialVersionUID = 1L;private String entityId;private String result;public String getResult() {return result;}public void setResult(String result) {this.result = result;}public String getEntityId() {return entityId;}public void setEntityId(String entityId) {this.entityId = entityId;}public String index(){return "index";}public String fetchEntityDetails() throws NumberFormatException, Exception{JSONObject entityData = Mongo.getEntityById(Long.valueOf(entityId));setResult(entityData.getString("title"));return "result";}public String addEntity() throws NumberFormatException, Exception{try{JSONObject entityData = Mongo.getEntityById(Long.valueOf(entityId));Mongo.addEntityToHotspot(entityData.getLong("_id"), entityData.getString("title"));setResult("Entity added");}catch(Exception e){setResult("Entity already added");}return "result";}}