String strJson = req.getParameter("jsonData");
if(strJson != null){ //update image if the json is not empty.
String strJsonDel = req.getParameter("jsonDelete");
Image data;
//do the delete first
if(strJsonDel!=null && strJsonDel!=""){
data = new Gson().fromJson(strJsonDel, Image.class);
if (ofy == null) ofy = PMF.getObjectify();
//need to delete blobstoreServic
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
for (Iterator<Image> iter = data.getImgList().iterator(); iter.hasNext();) {
Image img = ofy.get(Image.class, ((Image) iter.next()).id);
BlobKey blobKey = new BlobKey(img.blobKey);
//if(blobKey !=null)
//blobstoreService.delete(blobKey);
}
ofy.delete(data.getImgList());
}
data = new Gson().fromJson(strJson, Image.class);
for (Iterator<Image> iter = data.getImgList().iterator(); iter.hasNext();) {
Image img = (Image) iter.next();
saveImageData(img.id, null,null, img.description, img.order );
}
}
else if (req.getParameter("websiteComponentIdentifier") !=null) { //otherwise, add new image
saveImageData(0,req.getParameter("websiteComponentIdentifier"), req.getParameter("blobkey"), req.getParameter("description"), 0);