return;
}
final Map attrs = new HashMap();
String alert = null, uuid = null, nextURI = null, sid = null;
Desktop desktop = null;
try {
if (!isMultipartContent(request)) {
if ("uploadInfo".equals(request.getParameter("cmd"))) {
uuid = request.getParameter("wid");
sid = request.getParameter("sid");
desktop = ((WebAppCtrl)sess.getWebApp()).getDesktopCache(sess).getDesktop(request.getParameter("dtid"));
Map precent = (Map) desktop.getAttribute(Attributes.UPLOAD_PERCENT);
Map size = (Map)desktop.getAttribute(Attributes.UPLOAD_SIZE);
final String key = uuid + '_' + sid;
Object sinfo = size.get(key);
if (sinfo instanceof String) {
response.getWriter().append("error:" + sinfo);
size.remove(key);
precent.remove(key);
return;
}
final Integer p = (Integer)precent.get(key);
final Long cb = (Long)sinfo;
response.getWriter().append((p != null ? p.intValue(): -1)+ ","
+(cb != null ? cb.longValue(): -1));
return;
} else
alert = "enctype must be multipart/form-data";
} else {
uuid = request.getParameter("uuid");
sid = request.getParameter("sid");
if (uuid == null || uuid.length() == 0) {
alert = "uuid is required!";
} else {
attrs.put("uuid", uuid);
attrs.put("sid", sid);
final String dtid = request.getParameter("dtid");
if (dtid == null || dtid.length() == 0) {
alert = "dtid is required!";
} else {
desktop = ((WebAppCtrl)sess.getWebApp())
.getDesktopCache(sess).getDesktop(dtid);
final Map params = parseRequest(request, desktop, uuid + '_' + sid);
nextURI = (String)params.get("nextURI");
// Bug 3054784
params.put("native", request.getParameter("native"));
processItems(desktop, params, attrs);
}
}
}
} catch (Throwable ex) {
if (uuid == null) {
uuid = request.getParameter("uuid");
if (uuid != null)
attrs.put("uuid", uuid);
}
if (nextURI == null)
nextURI = request.getParameter("nextURI");
if (ex instanceof ComponentNotFoundException) {
alert = Messages.get(MZk.UPDATE_OBSOLETE_PAGE, uuid);
} else if (ex instanceof IOFileUploadException) {
log.debug("File upload cancelled!");
} else {
alert = handleError(ex);
}
if (desktop != null) {
Map precent = (Map) desktop.getAttribute(Attributes.UPLOAD_PERCENT);
Map size = (Map)desktop.getAttribute(Attributes.UPLOAD_SIZE);
final String key = uuid + '_' + sid;
if (precent != null) {
precent.remove(key);
size.remove(key);
}
}
}
if (attrs.get("contentId") == null && alert == null)
alert = "contentId is required!";
if (alert != null) {
if (desktop == null) {
response.setIntHeader("ZK-Error", HttpServletResponse.SC_GONE);
return;
}
Map precent = (Map) desktop.getAttribute(Attributes.UPLOAD_PERCENT);
Map size = (Map)desktop.getAttribute(Attributes.UPLOAD_SIZE);
final String key = uuid + '_' + sid;
if (precent != null) {
precent.remove(key);
size.put(key, alert);
}