.indexOf(AbstractApplicationServlet.UPLOAD_URL_PREFIX)
+ AbstractApplicationServlet.UPLOAD_URL_PREFIX.length();
String uppUri = pathInfo.substring(startOfData);
- String[] parts = uppUri.split("/", 3); // 0 = pid, 1= name, 2 = sec key
- String variableName = parts[1];
- String paintableId = parts[0];
-
- StreamVariable streamVariable = getStreamVariable(paintableId,
+ String[] parts = uppUri.split("/", 4); // 0= rootid, 1 = cid, 2= name, 3
+ // = sec key
+ String rootId = parts[0];
+ String connectorId = parts[1];
+ String variableName = parts[2];
+ Root root = application.getRootById(Integer.parseInt(rootId));
+ Root.setCurrent(root);
+
- StreamVariable streamVariable = pidToNameToStreamVariable.get(
- connectorId).get(variableName);
++ StreamVariable streamVariable = getStreamVariable(connectorId,
+ variableName);
String secKey = streamVariableToSeckey.get(streamVariable);
- if (secKey.equals(parts[2])) {
+ if (secKey.equals(parts[3])) {
- VariableOwner source = getVariableOwner(paintableId);
+ ClientConnector source = getConnector(root, connectorId);
String contentType = request.getContentType();
- if (request.getContentType().contains("boundary")) {
+ if (contentType.contains("boundary")) {
// Multipart requests contain boundary string
- doHandleSimpleMultipartFileUpload(
- new HttpServletRequestWrapper(request),
- new HttpServletResponseWrapper(response),
+ doHandleSimpleMultipartFileUpload(request, response,
streamVariable, variableName, source,
contentType.split("boundary=")[1]);
} else {
}
- /**
- * Handles UIDL request
- *
- * TODO document
- *
- * @param request
- * @param response
- * @param applicationServlet
- * @param window
- * target window of the UIDL request, can be null if window not
- * found
- * @throws IOException
- * @throws ServletException
- */
- public void handleUidlRequest(HttpServletRequest request,
- HttpServletResponse response,
- AbstractApplicationServlet applicationServlet, Window window)
- throws IOException, ServletException,
- InvalidUIDLSecurityKeyException {
- doHandleUidlRequest(new HttpServletRequestWrapper(request),
- new HttpServletResponseWrapper(response),
- new AbstractApplicationServletWrapper(applicationServlet),
- window);
- }
-
- /**
- * Gets the existing application or creates a new one. Get a window within
- * an application based on the requested URI.
- *
- * @param request
- * the HTTP Request.
- * @param application
- * the Application to query for window.
- * @param assumedWindow
- * if the window has been already resolved once, this parameter
- * must contain the window.
- * @return Window matching the given URI or null if not found.
- * @throws ServletException
- * if an exception has occurred that interferes with the
- * servlet's normal operation.
- */
- Window getApplicationWindow(HttpServletRequest request,
- AbstractApplicationServlet applicationServlet,
- Application application, Window assumedWindow)
- throws ServletException {
- return doGetApplicationWindow(new HttpServletRequestWrapper(request),
- new AbstractApplicationServletWrapper(applicationServlet),
- application, assumedWindow);
- }
-
- /**
- * Calls the Window URI handler for a request and returns the
- * {@link DownloadStream} returned by the handler.
- *
- * If the window is the main window of an application, the deprecated
- * {@link Application#handleURI(java.net.URL, String)} is called first to
- * handle {@link ApplicationResource}s and the window handler is only called
- * if it returns null.
- *
- * @see AbstractCommunicationManager#handleURI(Window, Request, Response,
- * Callback)
- *
- * @param window
- * @param request
- * @param response
- * @param applicationServlet
- * @return
- */
- DownloadStream handleURI(Window window, HttpServletRequest request,
- HttpServletResponse response,
- AbstractApplicationServlet applicationServlet) {
- return handleURI(window, new HttpServletRequestWrapper(request),
- new HttpServletResponseWrapper(response),
- new AbstractApplicationServletWrapper(applicationServlet));
- }
-
+ /**
+ * Gets a stream variable based on paintable id and variable name. Returns
+ * <code>null</code> if no matching variable has been registered.
+ *
+ * @param paintableId
+ * id of paintable to get variable for
+ * @param variableName
+ * name of the stream variable
+ * @return the corresponding stream variable, or <code>null</code> if not
+ * found
+ */
+ public StreamVariable getStreamVariable(String paintableId,
+ String variableName) {
+ Map<String, StreamVariable> nameToStreamVariable = pidToNameToStreamVariable
+ .get(paintableId);
+ if (nameToStreamVariable == null) {
+ return null;
+ }
+ StreamVariable streamVariable = nameToStreamVariable.get(variableName);
+ return streamVariable;
+ }
+
@Override
- protected void unregisterPaintable(Component p) {
- /* Cleanup possible receivers */
+ protected void postPaint(Root root) {
+ super.postPaint(root);
+
if (pidToNameToStreamVariable != null) {
- Map<String, StreamVariable> removed = pidToNameToStreamVariable
- .remove(getPaintableId(p));
- if (removed != null) {
- for (String key : removed.keySet()) {
- streamVariableToSeckey.remove(removed.get(key));
+ Iterator<String> iterator = pidToNameToStreamVariable.keySet()
+ .iterator();
+ while (iterator.hasNext()) {
+ String connectorId = iterator.next();
+ if (root.getConnectorTracker().getConnector(connectorId) == null) {
+ // Owner is no longer attached to the application
+ Map<String, StreamVariable> removed = pidToNameToStreamVariable
+ .get(connectorId);
+ for (String key : removed.keySet()) {
+ streamVariableToSeckey.remove(removed.get(key));
+ }
+ iterator.remove();
}
}
}
private Map<StreamVariable, String> streamVariableToSeckey;
@Override
- String getStreamVariableTargetUrl(ClientConnector owner, String name,
- public String getStreamVariableTargetUrl(VariableOwner owner, String name,
-- StreamVariable value) {
++ public String getStreamVariableTargetUrl(ClientConnector owner,
++ String name, StreamVariable value) {
/*
* We will use the same APP/* URI space as ApplicationResources but
* prefix url with UPLOAD
}
@Override
- protected void cleanStreamVariable(ClientConnector owner, String name) {
- public void cleanStreamVariable(VariableOwner owner, String name) {
++ public void cleanStreamVariable(ClientConnector owner, String name) {
Map<String, StreamVariable> nameToStreamVar = pidToNameToStreamVariable
- .get(getPaintableId((Paintable) owner));
+ .get(owner.getConnectorId());
- nameToStreamVar.remove("name");
+ nameToStreamVar.remove(name);
if (nameToStreamVar.isEmpty()) {
- pidToNameToStreamVariable.remove(getPaintableId((Paintable) owner));
+ pidToNameToStreamVariable.remove(owner.getConnectorId());
}
}