Remove experiment code.

Support for multiple deviceNames.
This commit is contained in:
burke.davey
2011-02-12 21:30:24 +00:00
parent 9bb21e74d8
commit 3e73e0b03d
4 changed files with 22 additions and 35 deletions

View File

@@ -84,9 +84,6 @@ public class DeviceInfo {
@Persistent
private Boolean debug;
@Persistent
private Boolean phoneToChromeExperimentEnabled;
public DeviceInfo(Key key, String deviceRegistrationID) {
this.key = key;
this.deviceRegistrationID = deviceRegistrationID;
@@ -123,15 +120,6 @@ public class DeviceInfo {
this.debug = new Boolean(debug);
}
public boolean getPhoneToChromeExperimentEnabled() {
return (phoneToChromeExperimentEnabled != null ?
phoneToChromeExperimentEnabled.booleanValue() : false);
}
public void setPhoneToChromeExperimentEnabled(boolean phoneToChromeExperimentEnabled) {
this.phoneToChromeExperimentEnabled = new Boolean(phoneToChromeExperimentEnabled);
}
public void setType(String type) {
this.type = type;
}

View File

@@ -43,7 +43,6 @@ public class RegisterServlet extends HttpServlet {
private static final Logger log =
Logger.getLogger(RegisterServlet.class.getName());
private static final String OK_STATUS = "OK";
private static final String NOT_ENABLED_STATUS = "NOT_ENABLED";
private static final String LOGIN_REQUIRED_STATUS = "LOGIN_REQUIRED";
private static final String ERROR_STATUS = "ERROR";
@@ -171,15 +170,9 @@ public class RegisterServlet extends HttpServlet {
pm.makePersistent(device);
if (device.getType().equals(DeviceInfo.TYPE_CHROME)) {
// if (device.getPhoneToChromeExperimentEnabled()) {
if (true) {
String channelId =
ChannelServiceFactory.getChannelService().createChannel(deviceRegistrationId);
resp.getWriter().println(OK_STATUS + " " + channelId);
} else {
resp.setStatus(400);
resp.getWriter().println(NOT_ENABLED_STATUS);
}
String channelId =
ChannelServiceFactory.getChannelService().createChannel(deviceRegistrationId);
resp.getWriter().println(OK_STATUS + " " + channelId);
} else {
resp.getWriter().println(OK_STATUS);
}

View File

@@ -67,20 +67,20 @@ public class SendServlet extends HttpServlet {
return;
}
String deviceName = req.getParameter("deviceName");
String[] deviceNames = req.getParameter("deviceName") != null ? req.getParameter("deviceName").split(",") : null;
String deviceType = req.getParameter("deviceType");
User user = RegisterServlet.checkUser(req, resp, false);
if (user != null) {
doSendToDevice(url, title, sel, user.getEmail(),
deviceName, deviceType, resp);
deviceNames, deviceType, resp);
} else {
resp.getWriter().println(LOGIN_REQUIRED_STATUS);
}
}
protected boolean doSendToDevice(String url, String title, String sel, String userAccount,
String deviceName, String deviceType, HttpServletResponse resp) throws IOException {
String deviceNames[], String deviceType, HttpServletResponse resp) throws IOException {
// ok = we sent to at least one device.
boolean ok = false;
@@ -119,9 +119,17 @@ public class SendServlet extends HttpServlet {
int numSendAttempts = 0;
for (DeviceInfo deviceInfo : registrations) {
if (deviceName != null && !deviceName.equals(deviceInfo.getName())) {
continue; // user-specified device name
if (deviceNames != null) {
boolean found = false;
for (int i = 0; i < deviceNames.length; i++) {
if (deviceNames[i].equals(deviceInfo.getName())) {
found = true;
break;
}
}
if (!found) continue; // user-specified device name
}
if (deviceType != null && !deviceType.equals(deviceInfo.getType())) {
continue; // user-specified device type
}
@@ -185,8 +193,6 @@ public class SendServlet extends HttpServlet {
sel = sel.substring(0, space);
} // else: we'll get an error sending
}
// TODO: when we have history, save the url/title/sel in the history
// and send a pointer, have device fetch it.
}
boolean res;

View File

@@ -16,7 +16,7 @@
-->
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>chrometophone</application>
<version>7</version>
<version>8</version>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>