Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Commit

Permalink
Stab at addressing issue #25. Doesn't work, not sure why
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Baker committed Nov 1, 2011
1 parent e6e0975 commit 9c09492
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
27 changes: 26 additions & 1 deletion modules/backstage/MOD-INF/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function process(path, request, response) {
// /exhibit-session - where configurations of lenses and facets are POSTed, returning 201 to...
// /exhibit-session/<slug>/ - which is where the facet queries are performed
// /exhibit-session/<slug>/component/<compid> - components of the exhibit, where you can POST state
// /exhibit-session/<slug>/lens-cache - query cache for this data. DELETE it when you modify an exhibit
//

// Backstage is stateful so we need sessions to hold on to our Exhibit objects
Expand Down Expand Up @@ -118,7 +119,31 @@ function process(path, request, response) {
}
}
return;
} else if (method == "OPTIONS") { // CORS-only
} else if (method == "OPTIONS") {
CORSify(request,response);
butterfly.sendString(request, response, "", "utf-8", "text/plain");
return;
} else if (method == "DELETE") {
// flushes the lens cache for the database associated with the given session.
// no UI is provided so don't forget the session cookie
if (pathSegs[0] == "exhibit-session") {
if (pathSegs.length >= 2) {
var exhibit = backstage.getExhibit(request, pathSegs[1])
if (exhibit == null) {
butterfly.sendError(request, response, 404, "Exhibit session not found");
return;
}

if (pathSegs[2] == "lens-cache") {
exhibit.getDatabase().discardQueryCache()
butterfly.sendString(request, response, "Lens cache cleared", "utf-8", "text/plain");
return;
}

butterfly.sendError(request, response, 404, "Page not found");
return;
}
}
CORSify(request,response);
butterfly.sendString(request, response, "", "utf-8", "text/plain");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ public boolean isType(URI uri) {
public void discardCacheableQuery(String key) {
_cacheableQueries.remove(key);
}


public void discardQueryCache() {
_cacheableQueries.clear();
}

public Object cacheAndRun(String key, CacheableQuery cq) {
_logger.debug("> cacheAndRun");
if (_cacheableQueries.containsKey(key)) {
Expand Down

0 comments on commit 9c09492

Please sign in to comment.