getServletContext().log(
"-> DirDataSvr.doPost()\nParameters= "
+ request.getParameterMap().toString());
// Extract request parameters
String path=null;
JsonDirData dirData = null;
boolean isDirRenamed = false;
try {
dirData = JsonDirData.decode(request.getInputStream());
path = dirData.getPath();
}
catch (Exception ex) {
getServletContext().log("Cannot get POSTed directory parameters", ex);
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return;
}
// Check if directory must be renamed
if ((path != null) && (dirData.getDirName() != null) && (!dirData.getDirName().equals(PathUtil.pathToName(path)))) {
File dir = new File(cfg.imageRootPath + path);
if (dir.exists() && dir.isDirectory()) {
dir.renameTo(new File(dir.getParentFile(), dirData.getDirName()));
isDirRenamed = true;
dirData.setPath(PathUtil.changeName(path, dirData.getDirName()));
}
}
// Persist the directory description data into database
EntityManager em = ModelFactory.getEntityManager();