|
From: <tre...@us...> - 2007-07-06 23:11:23
|
Revision: 218
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=218&view=rev
Author: trevorolio
Date: 2007-07-06 16:11:25 -0700 (Fri, 06 Jul 2007)
Log Message:
-----------
Fixed a bug when the embeds specified a starting position or rotation which was caused by my overzealous optimization of space initialization.
Worked around an amazingly bad bug in Java 1.6u1 in which everything fetched from the applet cache is corrupt. This caused the second space load to be nothing but broken obj ? models. Added a random parameter to urls in 1.6, so there's no caching and things are slow to reload. Rumor says this is fixed in 1.6u2.
Modified Paths:
--------------
spaces/trunk/src/com/ogoglio/client/SpaceClient.java
spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
Modified: spaces/trunk/src/com/ogoglio/client/SpaceClient.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/SpaceClient.java 2007-07-06 17:42:54 UTC (rev 217)
+++ spaces/trunk/src/com/ogoglio/client/SpaceClient.java 2007-07-06 23:11:25 UTC (rev 218)
@@ -111,7 +111,8 @@
}
}
- UserDocument[] userDocs = spaceDoc.getUserDocuments();
+ //can't use spaceDoc list of users because it doesn't include the user that just authed (me!)
+ UserDocument[] userDocs = webClient.getUserDocuments();
for (int i = 0; i < userDocs.length; i++) {
space.addUser(new User(space, userDocs[i].getUsername(), userDocs[i].getTransform(), userDocs[i].getBodyID()));
}
Modified: spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-07-06 17:42:54 UTC (rev 217)
+++ spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-07-06 23:11:25 UTC (rev 218)
@@ -20,7 +20,7 @@
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URI;
-import java.util.Date;
+import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -59,15 +59,19 @@
private AuthDocument authDocument = null;
private AccountDocument accountDocument = null;
+
+ private static boolean printedCacheComplaint = false;
+
private static final URI NO_SPACE = null; /* constant representing that we want no space connection */
-
+
public WebAPIClient(URI serviceURI, String authCookie) throws IOException {
- this(NO_SPACE,serviceURI,authCookie);
+ this(NO_SPACE, serviceURI, authCookie);
}
+
public WebAPIClient(URI spaceURI, URI serviceURI, String authCookie) throws IOException {
//seems that we have to allow the null spaceURI to indicate that
- //the client has no interest in a space
- //ArgumentUtils.assertNotNull(spaceURI);
+ //the client has no interest in a space
+ //ArgumentUtils.assertNotNull(spaceURI);
this.spaceURI = spaceURI;
ArgumentUtils.assertNotNull(serviceURI);
this.serviceURI = serviceURI;
@@ -505,6 +509,26 @@
}
public static DecoratedInputStream performGET(URI uri, String authCookie) throws IOException {
+
+ String version = System.getProperty("java.version");
+ if ((version == null) || version.startsWith("1.6")) {
+ //THIS IS TO WORK AROUND SUN'S ABSOLUTELY BROKEN APPLET CACHE IN JRE 1.6u1
+ String uriString = uri.toASCIIString();
+ try {
+ if (uriString.indexOf("?") == -1) {
+ uri = new URI(uri.toString() + "?cacheFix=" + Math.random());
+ } else {
+ uri = new URI(uri.toString() + "&cacheFix=" + Math.random());
+ }
+ if (!printedCacheComplaint) {
+ printedCacheComplaint = true;
+ System.err.println("NOTE: Not using Sun's download cache, which they broke in Java 1.6u1.");
+ }
+ } catch (URISyntaxException e) {
+ System.err.println("Tried to reset the URI to avoid bad cache in 1.6:" + e);
+ }
+ }
+
HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
connection.setRequestMethod("GET");
connection.setAllowUserInteraction(false);
@@ -533,7 +557,7 @@
public static long requestContentLength(URI uri, String authCookie) {
String lastModValue = getHeadValue(uri, authCookie, "Content-Length");
- if(lastModValue == null) {
+ if (lastModValue == null) {
return -1;
}
return Long.parseLong(lastModValue);
@@ -556,7 +580,7 @@
return -1;
}
}
-
+
private static String getHeadValue(URI uri, String authCookie, String headerName) {
try {
HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
@@ -812,7 +836,8 @@
public URI getSettingURI(String key) {
return WebAPIUtil.appendToURI(getSettingsURI(), key + "/");
}
+
public String toString() {
- return "<WebAPI:"+serviceURI+">";
+ return "<WebAPI:" + serviceURI + ">";
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|