Author: paperwing
Date: 2012-05-11 16:12:16 -0700 (Fri, 11 May 2012)
New Revision: 29250
Added:
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/api-notes.txt
Modified:
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/net/server/AppGetResponder.java
Log:
Added api-notes.txt with current local HTTP API, AppGetResponder updated to
respond in JSON
Added: csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/api-notes.txt
===================================================================
--- csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/api-notes.txt
(rev 0)
+++ csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/api-notes.txt
2012-05-11 23:12:16 UTC (rev 29250)
@@ -0,0 +1,48 @@
+Note: All responses are in JSON.
+
+
+Get App Status
+==============
+
+URL
+---
+
+GET http://127.0.0.1:2608/status?appname=<app_name>
+
+Notes: App_name is the app store unique app name. For web-downloaded apps, it
will be the same
+as the Cytoscape-App-Name entry in the manifest. If no matches were found in
web apps, we
+will look for matches using only the Cytoscape-App-Name entry.
+
+Response
+--------
+
+{
+ "request_name": The app name requested by the app store
+ "status": installed, uninstall-on-restart, uninstalled, or not-found. Not
found would
+mean the app isn't found on the user's computer.
+ "version": The version of the app, as found in the Cytoscape-App-Version
manifest entry.
+}
+
+Install an App
+==============
+
+URL
+---
+
+GET http://127.0.0.1:2608/install?appname=<app_name>&version=<version>
+
+Response
+--------
+
+The server attempts to query the app from the app store. If no matches were
found
+for the version, or if the version information was absent, we will try to get
the latest
+version.
+
+Upon completion, the server sends the following:
+
+{
+ "app_name": The name of the install app
+ "install_status": The result of the installation. Values could be: success,
+app-not-found, version-not-found.
+}
+
Property changes on:
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/api-notes.txt
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
===================================================================
---
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
2012-05-11 22:46:49 UTC (rev 29249)
+++
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
2012-05-11 23:12:16 UTC (rev 29250)
@@ -58,7 +58,7 @@
*/
public enum AppStatus{
INSTALLED("Installed"),
- TO_BE_UNINSTALLED("Uninstall on Restart"),
+ TO_BE_UNINSTALLED("Uninstall-on-Restart"),
UNINSTALLED("Uninstalled");
String readableStatus;
Modified:
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/net/server/AppGetResponder.java
===================================================================
---
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/net/server/AppGetResponder.java
2012-05-11 22:46:49 UTC (rev 29249)
+++
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/net/server/AppGetResponder.java
2012-05-11 23:12:16 UTC (rev 29250)
@@ -6,6 +6,7 @@
import org.cytoscape.app.internal.manager.App;
import org.cytoscape.app.internal.manager.AppManager;
import org.cytoscape.app.internal.net.server.LocalHttpServer.Response;
+import org.json.JSONObject;
/**
* This class is responsible for handling GET requests received by the local
HTTP server.
@@ -38,37 +39,60 @@
String urlRequestPrefix = getUrlRequestPrefix(url);
+
if (urlRequestPrefix.equalsIgnoreCase(STATUS_QUERY_URL)) {
String appName = parsed.get(STATUS_QUERY_APP_NAME);
boolean appFound = false;
if (appName != null) {
+
+ Map<String, String> statusData = new
HashMap<String, String>();
+ String status = null;
+ String version = null;
+
// throw new Exception("Missing value for app
name under the key \"" + STATUS_QUERY_APP_NAME + "\"");
+
+ // Searches web apps first. If not found,
searches other apps using manifest name field.
for (App app : appManager.getApps()) {
if
(app.getAppName().equalsIgnoreCase(appName)) {
- responseBody =
String.valueOf(app.getStatus());
- appFound = true;
+ status = app.getStatus() ==
null? null : app.getStatus().toString().toLowerCase();
+ version = app.getVersion() ==
null? "null" : app.getVersion().toString();
}
}
- Map<String, String> statusData = new
HashMap<String, String>();
+ statusData.put("request_name", appName); // web
unique identifier
+ statusData.put("status", status);
+ statusData.put("version", version);
- if (!appFound) {
- responseBody = "App \"" + appName + "\"
not installed.";
- }
+ JSONObject jsonObject = new
JSONObject(statusData);
+
+ responseBody = jsonObject.toString();
}
} else if
(urlRequestPrefix.equalsIgnoreCase(INSTALL_QUERY_URL)) {
String appName = parsed.get(INSTALL_QUERY_APP_NAME);
String version = parsed.get(INSTALL_QUERY_APP_VERSION);
+ // If version not available, get the latest version?
+
if (appName != null && version != null) {
// Use the WebQuerier to obtain the app from
the app store using the app name and version
responseBody = "Will obtain \"" + appName +
"\", version " + version;
+
+ Map<String, String> installResultData = new
HashMap<String, String>();
+
+ installResultData.put("name", appName);
+ installResultData.put("install_status",
"empty");
+
+ JSONObject jsonObject = new
JSONObject(installResultData);
+
+ responseBody = jsonObject.toString();
}
+
+
}
responseBody += "\n";
- LocalHttpServer.Response response = new
LocalHttpServer.Response(responseBody, "text/plain");
+ LocalHttpServer.Response response = new
LocalHttpServer.Response(responseBody, "application/json");
return response;
}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.