| Line 1... |
Line 1... |
| 1 |
package in.shop2020.mobileapi.serving.controllers;
|
1 |
package in.shop2020.mobileapi.serving.controllers;
|
| 2 |
|
2 |
|
| - |
|
3 |
import in.shop2020.mobileapi.serving.pojos.NotificationPojo;
|
| 3 |
import in.shop2020.mobileapi.serving.services.ContentServingService;
|
4 |
import in.shop2020.mobileapi.serving.services.ContentServingService;
|
| 4 |
import in.shop2020.mobileapi.serving.utils.PojoPopulator;
|
5 |
import in.shop2020.mobileapi.serving.utils.PojoPopulator;
|
| 5 |
import in.shop2020.mobileapi.serving.utils.SnippetType;
|
6 |
import in.shop2020.mobileapi.serving.utils.SnippetType;
|
| 6 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
7 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
| 7 |
import in.shop2020.model.v1.catalog.Item;
|
8 |
import in.shop2020.model.v1.catalog.Item;
|
| Line 99... |
Line 100... |
| 99 |
return "index";
|
100 |
return "index";
|
| 100 |
}
|
101 |
}
|
| 101 |
|
102 |
|
| 102 |
public String create() {
|
103 |
public String create() {
|
| 103 |
try {
|
104 |
try {
|
| - |
|
105 |
NotificationPojo np = new NotificationPojo();
|
| 104 |
UserClient userServiceClient = new UserClient();
|
106 |
UserClient userServiceClient = new UserClient();
|
| 105 |
UserContextService.Client userClient = userServiceClient.getClient();
|
107 |
UserContextService.Client userClient = userServiceClient.getClient();
|
| 106 |
cartMsg = userClient.addItemToCart(id, itemId, 1, -1);
|
108 |
cartMsg = userClient.addItemToCart(id, itemId, 1, -1);
|
| 107 |
if (!("".equals(cartMsg))) {
|
109 |
if (!("".equals(cartMsg))) {
|
| - |
|
110 |
String emailId = "";
|
| - |
|
111 |
try {
|
| - |
|
112 |
emailId = this.request.getParameter("emailId");
|
| - |
|
113 |
if(emailId!=null){
|
| - |
|
114 |
np.setMessage("Could not add this item to cart");
|
| - |
|
115 |
np.setStatus("oos");
|
| - |
|
116 |
cartPojoJson = new Gson().toJson(np);
|
| - |
|
117 |
return "index";
|
| - |
|
118 |
|
| - |
|
119 |
}
|
| - |
|
120 |
itemId = Long.parseLong(this.request.getParameter("itemId"));
|
| - |
|
121 |
|
| - |
|
122 |
CatalogClient catalogClientService;
|
| - |
|
123 |
catalogClientService = new CatalogClient();
|
| - |
|
124 |
in.shop2020.model.v1.catalog.CatalogService.Client client = catalogClientService.getClient();
|
| - |
|
125 |
client.addProductNotification(itemId, emailId);
|
| - |
|
126 |
} catch (Exception e) {
|
| - |
|
127 |
log.error("Exception while adding product notification for item: " + itemId + " and email: " + emailId, e);
|
| - |
|
128 |
}
|
| - |
|
129 |
log.debug("Got product notification for product: " + itemId + " from user: " + emailId );
|
| - |
|
130 |
np.setMessage("You will be notified when product is avaliable");
|
| - |
|
131 |
np.setStatus("success");
|
| - |
|
132 |
cartPojoJson = new Gson().toJson(np);
|
| 108 |
return "outofstock";
|
133 |
return "index";
|
| 109 |
}
|
134 |
}
|
| 110 |
} catch (TException e) {
|
135 |
} catch (TException e) {
|
| 111 |
log.error("Unable to create or add to cart because of: ", e);
|
136 |
log.error("Unable to create or add to cart because of: ", e);
|
| 112 |
errorMsg = "Unable to add to cart. Please try again.";
|
137 |
errorMsg = "Unable to add to cart. Please try again.";
|
| 113 |
} catch (Exception e) {
|
138 |
} catch (Exception e) {
|