|
From: <ian...@us...> - 2007-11-26 18:30:22
|
Revision: 603
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=603&view=rev
Author: iansmith
Date: 2007-11-26 10:30:26 -0800 (Mon, 26 Nov 2007)
Log Message:
-----------
Added some Log messages so we have a hope of finding the "empty space bug" in a triumvirate.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometProto.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptHTTPRequest.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/OgoglioServletBase.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -36,12 +36,14 @@
throw new IllegalArgumentException("Cannot copy a space to itself: " + destinationSpaceID);
}
+ Log.info("DUP:Creating new client:"+destinationSpaceID+","+emptyFirst+", from "+originSpaceID);
WebAPIClient client = new WebAPIClient(descriptor, auth, wire);
if (emptyFirst) {
emptySpace(destinationSpaceID, client);
}
+ Log.info("DUP: Getting space document and setting simple properties");
SpaceDocument spaceDoc1 = client.getSpaceDocument(originSpaceID, false);
SpaceDocument spaceDoc2 = client.getSpaceDocument(destinationSpaceID, false);
@@ -52,7 +54,9 @@
client.setSpacePublished(destinationSpaceID, spaceDoc1.isPublished());
ThingDocument[] thingDocs = client.getThingDocuments(originSpaceID);
+ Log.info("DUP: setting up possessions and things:"+thingDocs.length);
for (int i = 0; i < thingDocs.length; i++) {
+ Log.info("DUP: Setting up thing "+i+":"+thingDocs[i].getDisplayName());
PossessionDocument[] possDocuments = client.getPossessionDocuments();
PossessionDocument possToUse = null;
for (int j = 0; j < possDocuments.length; j++) {
@@ -81,10 +85,12 @@
}
DoorDocument[] doorDocs = client.getDoorDocuments(spaceDoc1.getSpaceID());
+ Log.info("DUP: Setting up doors:"+doorDocs.length);
for (int i = 0; i < doorDocs.length; i++) {
client.createDoor(spaceDoc2.getSpaceID(), doorDocs[i].getTemplateID(), doorDocs[i].getTemplateOwner(), doorDocs[i].getDisplayName(), doorDocs[i].getLink(), doorDocs[i].getTransform());
}
+ Log.info("DUP: copying space settings ");
Map settings = client.getSpaceSettings(spaceDoc1.getSpaceID());
String[] keys = (String[]) settings.keySet().toArray(new String[0]);
for (int i = 0; i < keys.length; i++) {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -13,7 +13,6 @@
limitations under the License. */
package com.ogoglio.client;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
@@ -27,6 +26,7 @@
import nanoxml.XMLElement;
import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.util.Log;
import com.ogoglio.util.StreamUtils;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.AuthDocument;
@@ -382,6 +382,7 @@
XMLElement list = wire.fetchAuthenticatedXML(descriptor.getThingsURI(spaceID), authenticator.getAuthCookie());
XMLElement[] children = (XMLElement[]) list.getChildren().toArray(new XMLElement[0]);
+ Log.info("CLIENT: Fetched thing document for space "+spaceID+" and found "+children.length+" children");
for (int i = 0; i < children.length; i++) {
results.add(new ThingDocument(children[i]));
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -26,6 +26,7 @@
import javax.vecmath.Vector3d;
import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.util.Log;
public class Space {
@@ -372,6 +373,7 @@
}
public synchronized Thing[] getThings() {
+ Log.info("SPACE: query of things content:"+ things.values().size()+" of space "+spaceID);
return (Thing[]) things.values().toArray(new Thing[0]);
}
@@ -416,6 +418,7 @@
}
public void addThing(Thing thing) {
+ Log.info("Space: adding thing:"+thing.getName()+" to space "+spaceID);
synchronized (this) {
if (thing.getThingID() == -1) {
thing.setThingID(getNewThingID());
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometProto.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometProto.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometProto.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -105,15 +105,17 @@
} catch (IOException e) {
Log.error("Problem attempting to flush comet proto buffers:" + e.getMessage());
}
- //again, a horrible modularity break: we *know* that needs chunking implies we are on the
- //client side
- if (needsChunking) {
- try {
- Log.info("Closing client-side connection to server since we are shutting down.");
+ }
+ //again, a horrible modularity break: we *know* that needs chunking implies we are on the
+ //client side
+ if (needsChunking) {
+ try {
+ Log.info("Closing client-side connection to server since we are shutting down. ("+(writer==null)+")");
+ if (writer!=null) {
writer.close();
- } catch (IOException e) {
- Log.error("Unable to close connection to server:" + e.getMessage());
}
+ } catch (IOException e) {
+ Log.error("Unable to close connection to server:"+e.getMessage());
}
}
input = null;
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -266,20 +266,26 @@
}
public SpaceSimulator getOrCreateSpaceSimulator(SpaceRecord record) {
+ Log.debug("Sim.getOrCreateSpaceSim:"+record.getDisplayName()+","+record.getSpaceID());
synchronized (spaceSimulators) {
SpaceSimulator simulator = (SpaceSimulator) spaceSimulators.getForward(new Long(record.getSpaceID()));
if (simulator != null) {
return simulator;
}
+ Log.debug("Sim.getOrCreateSpaceSim: don't have space doc cached.");
SpaceDocument spaceDoc = null;
try {
+ Log.debug("Sim.getOrCreateSpaceSim: about to read it from the media service!");
spaceDoc = getSpaceDocument(record.getSpaceID());
+ Log.debug("Sim.getOrCreateSpaceSim: Media service:"+(spaceDoc==null));
} catch (IOException e) {
}
if (spaceDoc == null) {
+ Log.debug("Sim.getOrCreateSpaceSim:Now trying to get it from the DocumentFactory.");
spaceDoc = DocumentFactory.documentFromRecord(record);
} else {
+ Log.debug("Sim.getOrCreateSpaceSim: Setting basic properties... why aren't these there before?");
spaceDoc.setDisplayName(record.getDisplayName());
spaceDoc.setMaxGuests(record.getMaxGuests());
spaceDoc.setSimID(record.getSimID());
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -98,6 +98,7 @@
renderer.setSimCamera(); //Sigh, you have to add a view before it will schedule the behavior
ThingDocument[] thingDocs = spaceDocument.getThingDocuments();
+ Log.debug("Initialization SpaceSimulator on space "+spaceDocument.getSpaceID()+" with "+thingDocs.length);
for (int i = 0; i < thingDocs.length; i++) {
TemplateDocument templateDoc = listener.getTemplateDocument(thingDocs[i].getTemplateID());
if (templateDoc == null) {
@@ -705,6 +706,7 @@
public ThingDocument[] getThingDocuments() {
Thing[] things = space.getThings();
+ Log.debug("SpaceSimulator: asked space object how many things:"+things.length);
ThingDocument[] results = new ThingDocument[things.length];
for (int i = 0; i < results.length; i++) {
results[i] = new ThingDocument(things[i]);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptHTTPRequest.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptHTTPRequest.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptHTTPRequest.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -228,6 +228,7 @@
method.setFollowRedirects(false);
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(1, false));
method.getParams().setParameter(HttpMethodParams.USER_AGENT, USER_AGENT);
+ Log.info("About to invoke an HTTP "+methodType+" on "+url+" from a sim script...");
try {
httpCode = client.executeMethod(method);
if (scriptSpace != null && destinationThingID != -1 && destinationPageID != -1) {
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -38,6 +38,7 @@
import com.ogoglio.client.WebAPIDescriptor;
import com.ogoglio.media.MediaService;
import com.ogoglio.persist.AccountRecord;
+import com.ogoglio.persist.PossessionPersistTasks;
import com.ogoglio.persist.ServiceInitializationPersistTasks;
import com.ogoglio.persist.SimPersistTasks;
import com.ogoglio.persist.SimRecord;
@@ -480,9 +481,11 @@
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
-
+ Log.debug("GET on SimServlet.ThingsResource: "+requestedSpaceID+" --- how many possessions?"+
+ (PossessionPersistTasks.findPossessionsBySpaceID(requestedSpaceID, getSessionFactory())));
SpaceSimulator simulator = sim.getOrCreateSpaceSimulator(spaceRecord);
ThingDocument[] thingDocs = simulator.getThingDocuments();
+ Log.debug("SimServlet, Thing request:"+thingDocs.length);
XMLElement list = new XMLElement("list");
for (int i = 0; i < thingDocs.length; i++) {
list.addChild(thingDocs[i].toElement());
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/OgoglioServletBase.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/OgoglioServletBase.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/OgoglioServletBase.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -28,6 +28,10 @@
initBaseUrl();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
String mediaUrl = (String) envCtx.lookup("ogoglio/mediaURL");
+ if (!mediaUrl.endsWith("/")) {
+ Log.warn("mediaURL doesn't end with a '/': patching from "+mediaUrl+" to " + mediaUrl+"/");
+ mediaUrl=mediaUrl+"/";
+ }
boolean simsAllowRemoteAccess = "true".equals(envCtx.lookup("ogoglio/simsAllowRemoteAccess"));
File mailDir = null;
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -66,8 +66,11 @@
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
- messageProxy = new MessageProxy(getSessionFactory(),new WebAPIDescriptor(new URI(baseUrl)));
- config.getServletContext().setAttribute(MESSAGE_PROXY_KEY, messageProxy);
+ //don't bother running a proxy with no space resources!
+ if (servletNeeded) {
+ messageProxy = new MessageProxy(getSessionFactory(),new WebAPIDescriptor(new URI(baseUrl)));
+ config.getServletContext().setAttribute(MESSAGE_PROXY_KEY, messageProxy);
+ }
} catch (URISyntaxException e) {
throw new ServletException("Could not start the message proxy (bad URI for service):" + e);
} catch (IOException e) {
@@ -454,6 +457,7 @@
proxyURI += pathElements[i] + "/";
}
proxyURI += "?" + request.getQueryString();
+ Log.debug("DoProxy SpaceServlet: proxying request for thing:"+proxyURI+" with "+method);
proxy(new URI(proxyURI), method, request, response);
} catch (PersistException e) {
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -34,6 +34,8 @@
private static final int MAX_RECENT_CHECKS = 10;
+ public static final int NO_SPACE_SERVLET = -7911;
+
public SiteResource createBaseResource(ServletConfig servletConfig) {
return new StatusResource();
}
@@ -243,9 +245,14 @@
}
private void addSpaceInfo(StatusData data) throws IOException {
- XMLElement space = frontDoorGetXML(getBaseUrl(),"space");
- data.simCount = space.getIntAttribute("simcount");
- data.userCount = space.getIntAttribute("usercount");
+ try {
+ XMLElement space = frontDoorGetXML(getBaseUrl(),"space");
+ data.simCount = space.getIntAttribute("simcount");
+ data.userCount = space.getIntAttribute("usercount");
+ } catch (IOException e) {
+ data.simCount=NO_SPACE_SERVLET;
+ data.userCount=NO_SPACE_SERVLET;
+ }
}
@@ -348,8 +355,12 @@
buffer.append(sd.fs[j].root + ":" + per + "% full\n");
}
}
- buffer.append("User count :" + sd.userCount + "\n");
- buffer.append("Sim count :" + sd.simCount + "\n");
+ if (sd.userCount!=NO_SPACE_SERVLET) {
+ buffer.append("User count :" + sd.userCount + "\n");
+ buffer.append("Sim count :" + sd.simCount + "\n");
+ } else {
+ buffer.append("Space servlet not present\n");
+ }
buffer.append("-----------------------------------------------\n");
}
@@ -566,14 +577,19 @@
}
private String dodgyConversionOfSimURI(String simURI) {
+ return dodgyConversionOfURI(simURI, "/og/sim/");
+ }
+ private String dodgyConversionOfMediaURI(String mediaURI) {
+ return dodgyConversionOfURI(mediaURI, "/og/media/");
+ }
+ private String dodgyConversionOfURI(String URI, String suffix) {
String result;
- String standardSIMSuffix="/og/sim/";
- if (!simURI.endsWith(standardSIMSuffix)) {
- Log.error("Don't understand the sim URI we got, so we can't convert to a status URI:"+simURI);
- return simURI; //not a great answer, but it'll cause IOExceptions elsewhere
+ if (!URI.endsWith(suffix)) {
+ Log.error("Don't understand the URI we got, so we can't convert to a a better URI:"+URI);
+ return URI; //not a great answer, but it'll cause IOExceptions elsewhere
}
- result=simURI.substring(0,simURI.length()-standardSIMSuffix.length()) + "/og/status";
- Log.warn("Somewhat dodgy: Converting the URI "+simURI +" to "+result+" for status report!");
+ result=URI.substring(0,URI.length()-suffix.length()) + "/og/";
+ Log.warn("Somewhat dodgy: Converting the URI "+URI+" to "+result+" for status report!");
return result;
}
private void formatForHuman(StringBuffer buffer) {
@@ -590,7 +606,9 @@
buffer.append("Sim Server:" + sim.getDisplayName() + " [" + sim.getSimID() + "] " + sim.getSimURI() + "\n");
buffer.append("===============================================\n");
if (!isOnLocalhost(sim)) {
- statusReports = frontDoorGetText(dodgyConversionOfSimURI(sim.getSimURI().toString()),STATUS_HUMAN);
+ String hackedURI=dodgyConversionOfSimURI(sim.getSimURI().toString());
+ buffer.append("Hacked sim status URI:"+hackedURI+"\n");
+ statusReports = frontDoorGetText(hackedURI,STATUS_HUMAN);
buffer.append(statusReports);
}
} catch (IOException e) {
@@ -601,11 +619,13 @@
buffer.append("Media Server:" + mediaURI+"\n");
buffer.append("===============================================\n");
if (!mediaURI.startsWith("file:")) {
- statusReports = frontDoorGetText(mediaURI,STATUS_HUMAN);
+ String patchedURI=dodgyConversionOfMediaURI(mediaURI);
+ buffer.append("Hacked media status URI:"+patchedURI+"\n");
+ statusReports = frontDoorGetText(patchedURI,STATUS_HUMAN);
buffer.append(statusReports);
}
} catch (IOException e) {
- buffer.append("Could not contact other status applet:" + e.getMessage());
+ buffer.append("Could not contact other status servlet:" + e.getMessage());
} catch (PersistException e) {
buffer.append("Unable to contact database [PersistException]:" + e.getMessage());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2007-12-12 17:47:06
|
Revision: 627
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=627&view=rev
Author: iansmith
Date: 2007-12-12 09:46:59 -0800 (Wed, 12 Dec 2007)
Log Message:
-----------
Added some debugging logs to various parts of the comet chain so we can see what happens as tours get started.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometClient.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometChannelManager.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometClient.java 2007-12-10 22:57:46 UTC (rev 626)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometClient.java 2007-12-12 17:46:59 UTC (rev 627)
@@ -62,11 +62,15 @@
}
private static void sendHTTPStartupInfo(Writer wr, String host, String path) throws IOException {
- sendLine("POST "+path+" HTTP/1.1", wr);
+ Log.debug("About to send POST to "+path+" on "+host);
+ /*sendLine("POST "+path+" HTTP/1.1", wr);
+ HACK FOR DEALING WITH MOD_PROXY IN APACHE 2.2*/
+ sendLine("GET "+path+" HTTP/1.1", wr);
sendLine("Host: "+host, wr);
sendLine("Transfer-encoding: chunked",wr);
sendLine("",wr);
wr.flush();
+ Log.debug("GET/POST Sent!");
}
private static String getHTTPResponse(InputStream is) throws IOException {
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometChannelManager.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometChannelManager.java 2007-12-10 22:57:46 UTC (rev 626)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometChannelManager.java 2007-12-12 17:46:59 UTC (rev 627)
@@ -100,7 +100,7 @@
//the buffer is critical here
StringBuffer buff=(StringBuffer)sessionToBuffer.get(event);
buff.append(tmp);
-
+ Log.debug("Added some text to the buffer in ChanMgr:"+buff.toString());
String msg = CometClient.pullOutNextMessage(buff);
if (msg!=null) {
messageDone((TCPChannel) sessionToChannel.get(event), msg, event);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometServlet.java 2007-12-10 22:57:46 UTC (rev 626)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometServlet.java 2007-12-12 17:46:59 UTC (rev 627)
@@ -111,7 +111,7 @@
CometChannelManager mgr = (CometChannelManager) iterator.next();
mgr.connectionDropped(event);
}
- //Log.info("Destroyed comet info for path "+path+":"+event.getHttpServletRequest().getSession(true).getId());
+ Log.info("Destroyed comet info for path "+path+":"+event.getHttpServletRequest().getSession(true).getId());
} else {
Log.warn("Close comet on path " + path + " but nobody interested....");
}
@@ -145,7 +145,7 @@
mgr.addConnection(event, channel);
//in 6.0.14 this is an unsupported operation
//event.setTimeout(30000);
- //Log.info("Added comet connection for path "+event.getHttpServletRequest().getPathInfo()+":"+event.getHttpServletRequest().getSession(true).getId());
+ Log.info("Added comet connection for path "+event.getHttpServletRequest().getPathInfo()+":"+event.getHttpServletRequest().getSession(true).getId());
}
private boolean drainDataBuffer(CometEvent event, HttpServletRequest request) throws IOException {
@@ -167,7 +167,7 @@
} while (is.available() > 0);
return true;
} catch (IOException exception) {
- //Log.info("Client appears to have closed the comet connection:" + event.getHttpServletRequest().getSession(true).getId()+". Closing it b/c:"+exception.getMessage()+" of type "+exception.getClass().getName());
+ Log.info("Client appears to have closed the comet connection:" + event.getHttpServletRequest().getSession(true).getId()+". Closing it b/c:"+exception.getMessage()+" of type "+exception.getClass().getName());
closeComet(event);
return false;
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-12-10 22:57:46 UTC (rev 626)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-12-12 17:46:59 UTC (rev 627)
@@ -134,13 +134,15 @@
public void destroy() {
try {
super.destroy();
- sim.cleanup();
- SimRecord rec = SimPersistTasks.findSimsBySimURI(simURI, getSessionFactory());
- if (rec == null) {
- Log.warn("Destroy: Can't find URI in database during shutdown of sim! URI=" + simURI);
- } else {
- Log.info("Destroy: Removing " + simURI + " from database list of sims.");
- SimPersistTasks.delete(rec, getSessionFactory());
+ if (servletNeeded) {
+ sim.cleanup();
+ SimRecord rec = SimPersistTasks.findSimsBySimURI(simURI, getSessionFactory());
+ if (rec == null) {
+ Log.warn("Destroy: Can't find URI in database during shutdown of sim! URI=" + simURI);
+ } else {
+ Log.info("Destroy: Removing " + simURI + " from database list of sims.");
+ SimPersistTasks.delete(rec, getSessionFactory());
+ }
}
} catch (PersistException e) {
Log.error("Can't clean up Sim record in database:" + e.getMessage(), e);
Modified: maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java
===================================================================
--- maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java 2007-12-10 22:57:46 UTC (rev 626)
+++ maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java 2007-12-12 17:46:59 UTC (rev 627)
@@ -126,6 +126,15 @@
transform.setEuler(new Vector3d(rx, ry, rz));
transform.setTranslation(new Vector3d(x, y, z));
spaceClient.viewpointMotionStopped(transform);
+ if (spaceClient.getSpace()==null) {
+ Log.warn("No space in space client!");
+ }
+ if (spaceClient.getUsername()==null) {
+ Log.warn("No username in space client");
+ }
+ if (spaceClient.getSpace().getUser(spaceClient.getUsername())==null) {
+ Log.warn("No user by that name in the space!");
+ }
spaceClient.getSpace().getUser(spaceClient.getUsername()).setPosition(transform);
}
renderer = new J3DRenderer(spaceClient, false);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2008-01-03 18:57:31
|
Revision: 669
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=669&view=rev
Author: iansmith
Date: 2008-01-03 10:57:35 -0800 (Thu, 03 Jan 2008)
Log Message:
-----------
Rolled in support for mail stuff trevor did.
Modified Paths:
--------------
maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/mail/MailClient.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java
maven/trunk/ogoglio-server/src/test/java/com/ogoglio/persist/test/PersistTest.java
Added Paths:
-----------
maven/trunk/ogoglio-common/src/main/java/nanoxml/XMLElement_Localized.java
Modified: maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/mail/MailClient.java
===================================================================
--- maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/mail/MailClient.java 2008-01-03 02:14:27 UTC (rev 668)
+++ maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/mail/MailClient.java 2008-01-03 18:57:35 UTC (rev 669)
@@ -23,6 +23,7 @@
private File outputDir = null;
+ public static final String FAKE_MAIL_PREFIX="Mail-Message-";
/**
* Sends all mail to individual files in outputDir
*/
@@ -58,7 +59,7 @@
}
private void sendToDisk(String to, String from, String subject, String body) throws IOException {
- FileOutputStream output = new FileOutputStream(new File(outputDir, "Mail-Message-" + System.currentTimeMillis()));
+ FileOutputStream output = new FileOutputStream(new File(outputDir, FAKE_MAIL_PREFIX + System.currentTimeMillis()));
output.write(("to: " + to + "\n").getBytes());
output.write(("from: " + from + "\n").getBytes());
output.write(("subject: " + subject + "\n").getBytes());
Added: maven/trunk/ogoglio-common/src/main/java/nanoxml/XMLElement_Localized.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/nanoxml/XMLElement_Localized.java (rev 0)
+++ maven/trunk/ogoglio-common/src/main/java/nanoxml/XMLElement_Localized.java 2008-01-03 18:57:35 UTC (rev 669)
@@ -0,0 +1,2958 @@
+/* XMLElement.java
+ *
+ * $Revision: 1.1 $
+ * $Date: 2005/10/13 15:48:55 $
+ * $Name: $
+ *
+ * This file is part of NanoXML 2 Lite.
+ * Copyright (C) 2000-2002 Marc De Scheemaecker, All Rights Reserved.
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the
+ * use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software in
+ * a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ *
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ *
+ * 3. This notice may not be removed or altered from any source distribution.
+ *****************************************************************************/
+
+// TFS added some basic functions. Look for the ones without Javadocs. :-O
+// IES: fixed internationalization: now we FORCE it to EN_us
+package nanoxml;
+
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayReader;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.Writer;
+import java.text.ParseException;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Locale;
+import java.util.Vector;
+
+/**
+ * XMLElement is a representation of an XML object. The object is able to parse XML code.
+ * <P>
+ * <DL>
+ * <DT><B>Parsing XML Data</B></DT>
+ * <DD> You can parse XML data using the following code:
+ * <UL>
+ * <CODE> XMLElement xml = new XMLElement();<BR>
+ * FileReader reader = new FileReader("filename.xml");<BR>
+ * xml.parseFromReader(reader); </CODE>
+ * </UL>
+ * </DD>
+ * </DL>
+ * <DL>
+ * <DT><B>Retrieving Attributes</B></DT>
+ * <DD> You can enumerate the attributes of an element using the method {@link #enumerateAttributeNames() enumerateAttributeNames}. The attribute values can be retrieved using the method {@link #getStringAttribute(java.lang.String) getStringAttribute}. The following example shows how to list the attributes of an element:
+ * <UL>
+ * <CODE> XMLElement element = ...;<BR>
+ * Enumeration enum = element.getAttributeNames();<BR>
+ * while (enum.hasMoreElements()) {<BR>
+ * String key = (String) enum.nextElement();<BR>
+ * String value = element.getStringAttribute(key);<BR>
+ * System.out.println(key + " = " + value);<BR> } </CODE>
+ * </UL>
+ * </DD>
+ * </DL>
+ * <DL>
+ * <DT><B>Retrieving Child Elements</B></DT>
+ * <DD> You can enumerate the children of an element using {@link #enumerateChildren() enumerateChildren}. The number of child elements can be retrieved using {@link #countChildren() countChildren}. </DD>
+ * </DL>
+ * <DL>
+ * <DT><B>Elements Containing Character Data</B></DT>
+ * <DD> If an elements contains character data, like in the following example:
+ * <UL>
+ * <CODE> <title>The Title</title> </CODE>
+ * </UL>
+ * you can retrieve that data using the method {@link #getContent() getContent}. </DD>
+ * </DL>
+ * <DL>
+ * <DT><B>Subclassing XMLElement</B></DT>
+ * <DD> When subclassing XMLElement, you need to override the method {@link #createAnotherElement() createAnotherElement} which has to return a new copy of the receiver. </DD>
+ * </DL>
+ * <P>
+ *
+ * @see nanoxml.XMLParseException
+ *
+ * @author Marc De Scheemaecker <<A href="mailto:cyb...@ma...">cyb...@ma...</A>>
+ * @version $Name: $, $Revision: 1.1 $
+ */
+public class XMLElement_Localized {
+
+ /**
+ * Serialization serial version ID.
+ */
+ static final long serialVersionUID = 6685035139346394777L;
+
+ /**
+ * Major version of NanoXML. Classes with the same major and minor version are binary compatible. Classes with the same major version are source compatible. If the major version is different, you may need to modify the client source code.
+ *
+ * @see nanoxml.XMLElement#NANOXML_MINOR_VERSION
+ */
+ public static final int NANOXML_MAJOR_VERSION = 2;
+
+ /**
+ * Minor version of NanoXML. Classes with the same major and minor version are binary compatible. Classes with the same major version are source compatible. If the major version is different, you may need to modify the client source code.
+ *
+ * @see nanoxml.XMLElement#NANOXML_MAJOR_VERSION
+ */
+ public static final int NANOXML_MINOR_VERSION = 2;
+
+ /**
+ * For dealing with files generated by us and distributed with system. We *always* use
+ * the US locale. Trust us, you don't want multiple file formats.
+ */
+ private static java.text.NumberFormat enUSFormat = java.text.NumberFormat.getInstance(Locale.US);
+
+ /*
+ * True if we have already updated the enUSFormat properly.
+ */
+ private static boolean haveUpdatedenUSFormat = false;
+
+ /**
+ * The attributes given to the element.
+ *
+ * <dl>
+ * <dt><b>Invariants:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>The field can be empty.
+ * <li>The field is never <code>null</code>.
+ * <li>The keys and the values are strings.
+ * </ul>
+ * </dd>
+ * </dl>
+ */
+ private Hashtable attributes;
+
+ /**
+ * Child elements of the element.
+ *
+ * <dl>
+ * <dt><b>Invariants:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>The field can be empty.
+ * <li>The field is never <code>null</code>.
+ * <li>The elements are instances of <code>XMLElement</code> or a subclass of <code>XMLElement</code>.
+ * </ul>
+ * </dd>
+ * </dl>
+ */
+ private Vector children;
+
+ /**
+ * The name of the element.
+ *
+ * <dl>
+ * <dt><b>Invariants:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>The field is <code>null</code> iff the element is not initialized by either parse or setName.
+ * <li>If the field is not <code>null</code>, it's not empty.
+ * <li>If the field is not <code>null</code>, it contains a valid XML identifier.
+ * </ul>
+ * </dd>
+ * </dl>
+ */
+ private String name;
+
+ /**
+ * The #PCDATA content of the object.
+ *
+ * <dl>
+ * <dt><b>Invariants:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>The field is <code>null</code> iff the element is not a #PCDATA element.
+ * <li>The field can be any string, including the empty string.
+ * </ul>
+ * </dd>
+ * </dl>
+ */
+ private String contents;
+
+ /**
+ * Conversion table for &...; entities. The keys are the entity names without the & and ; delimiters.
+ *
+ * <dl>
+ * <dt><b>Invariants:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>The field is never <code>null</code>.
+ * <li>The field always contains the following associations: "lt" => "<", "gt" => ">", "quot" => "\"", "apos" => "'", "amp" => "&"
+ * <li>The keys are strings
+ * <li>The values are char arrays
+ * </ul>
+ * </dd>
+ * </dl>
+ */
+ private Hashtable entities;
+
+ /**
+ * The line number where the element starts.
+ *
+ * <dl>
+ * <dt><b>Invariants:</b></dt>
+ * <dd>
+ * <ul>
+ * <li><code>lineNr >= 0</code>
+ * </ul>
+ * </dd>
+ * </dl>
+ */
+ private int lineNr;
+
+ /**
+ * <code>false</code> if the case of the element and attribute names are case insensitive.
+ */
+ private boolean ignoreCase;
+
+ /**
+ * <code>true</code> if the leading and trailing whitespace of #PCDATA sections have to be ignored.
+ */
+ private boolean ignoreWhitespace;
+
+ /**
+ * Character read too much. This character provides push-back functionality to the input reader without having to use a PushbackReader. If there is no such character, this field is '\0'.
+ */
+ private char charReadTooMuch;
+
+ /**
+ * The reader provided by the caller of the parse method.
+ *
+ * <dl>
+ * <dt><b>Invariants:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>The field is not <code>null</code> while the parse method is running.
+ * </ul>
+ * </dd>
+ * </dl>
+ */
+ private Reader reader;
+
+ /**
+ * The current line number in the source content.
+ *
+ * <dl>
+ * <dt><b>Invariants:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>parserLineNr > 0 while the parse method is running.
+ * </ul>
+ * </dd>
+ * </dl>
+ */
+ private int parserLineNr;
+
+ /**
+ * Creates and initializes a new XML element. Calling the construction is equivalent to:
+ * <ul>
+ * <code>new XMLElement(new Hashtable(), false, true);
+ * setName(name);
+ * </code>
+ * </ul>
+ */
+ public XMLElement_Localized(String name) {
+ this(new Hashtable(), false, true, false);
+ setName(name);
+ }
+
+ /**
+ * Creates and initializes a new XML element. Calling the construction is equivalent to:
+ * <ul>
+ * <code>new XMLElement(new Hashtable(), false, true);
+ * setName(name);
+ * setContent(content);
+ * </code>
+ * </ul>
+ */
+ public XMLElement_Localized(String name, String content) {
+ this(new Hashtable(), false, true, false);
+ setName(name);
+ setContent(content);
+ }
+
+ /**
+ * Creates and initializes a new XML element. Calling the construction is equivalent to:
+ * <ul>
+ * <code>new XMLElement(new Hashtable(), false, true)
+ * </code>
+ * </ul>
+ *
+ * <dl>
+ * <dt><b>Postconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>countChildren() => 0
+ * <li>enumerateChildren() => empty enumeration
+ * <li>enumeratePropertyNames() => empty enumeration
+ * <li>getChildren() => empty vector
+ * <li>getContent() => ""
+ * <li>getLineNr() => 0
+ * <li>getName() => null
+ * </ul>
+ * </dd>
+ * </dl>
+ *
+ * @see nanoxml.XMLElement#XMLElement(java.util.Hashtable) XMLElement(Hashtable)
+ * @see nanoxml.XMLElement#XMLElement(boolean)
+ * @see nanoxml.XMLElement#XMLElement(java.util.Hashtable,boolean) XMLElement(Hashtable, boolean)
+ */
+ public XMLElement_Localized() {
+ this(new Hashtable(), false, true, false);
+ }
+
+ /**
+ * Creates and initializes a new XML element. Calling the construction is equivalent to:
+ * <ul>
+ * <code>new XMLElement(entities, false, true)
+ * </code>
+ * </ul>
+ *
+ * @param entities
+ * The entity conversion table.
+ *
+ * </dl>
+ * <dl>
+ * <dt><b>Preconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li><code>entities != null</code>
+ * </ul>
+ * </dd>
+ * </dl>
+ *
+ * <dl>
+ * <dt><b>Postconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>countChildren() => 0
+ * <li>enumerateChildren() => empty enumeration
+ * <li>enumeratePropertyNames() => empty enumeration
+ * <li>getChildren() => empty vector
+ * <li>getContent() => ""
+ * <li>getLineNr() => 0
+ * <li>getName() => null
+ * </ul>
+ * </dd>
+ * </dl>
+ * <dl>
+ *
+ * @see nanoxml.XMLElement#XMLElement()
+ * @see nanoxml.XMLElement#XMLElement(boolean)
+ * @see nanoxml.XMLElement#XMLElement(java.util.Hashtable,boolean) XMLElement(Hashtable, boolean)
+ */
+ public XMLElement_Localized(Hashtable entities) {
+ this(entities, false, true, false);
+ }
+
+ /**
+ * Creates and initializes a new XML element. Calling the construction is equivalent to:
+ * <ul>
+ * <code>new XMLElement(new Hashtable(), skipLeadingWhitespace, true)
+ * </code>
+ * </ul>
+ *
+ * @param skipLeadingWhitespace
+ * <code>true</code> if leading and trailing whitespace in PCDATA content has to be removed.
+ *
+ * </dl>
+ * <dl>
+ * <dt><b>Postconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>countChildren() => 0
+ * <li>enumerateChildren() => empty enumeration
+ * <li>enumeratePropertyNames() => empty enumeration
+ * <li>getChildren() => empty vector
+ * <li>getContent() => ""
+ * <li>getLineNr() => 0
+ * <li>getName() => null
+ * </ul>
+ * </dd>
+ * </dl>
+ * <dl>
+ *
+ * @see nanoxml.XMLElement#XMLElement()
+ * @see nanoxml.XMLElement#XMLElement(java.util.Hashtable) XMLElement(Hashtable)
+ * @see nanoxml.XMLElement#XMLElement(java.util.Hashtable,boolean) XMLElement(Hashtable, boolean)
+ */
+ public XMLElement_Localized(boolean skipLeadingWhitespace) {
+ this(new Hashtable(), skipLeadingWhitespace, true, false);
+ }
+
+ /**
+ * Creates and initializes a new XML element. Calling the construction is equivalent to:
+ * <ul>
+ * <code>new XMLElement(entities, skipLeadingWhitespace, true)
+ * </code>
+ * </ul>
+ *
+ * @param entities
+ * The entity conversion table.
+ * @param skipLeadingWhitespace
+ * <code>true</code> if leading and trailing whitespace in PCDATA content has to be removed.
+ *
+ * </dl>
+ * <dl>
+ * <dt><b>Preconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li><code>entities != null</code>
+ * </ul>
+ * </dd>
+ * </dl>
+ *
+ * <dl>
+ * <dt><b>Postconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>countChildren() => 0
+ * <li>enumerateChildren() => empty enumeration
+ * <li>enumeratePropertyNames() => empty enumeration
+ * <li>getChildren() => empty vector
+ * <li>getContent() => ""
+ * <li>getLineNr() => 0
+ * <li>getName() => null
+ * </ul>
+ * </dd>
+ * </dl>
+ * <dl>
+ *
+ * @see nanoxml.XMLElement#XMLElement()
+ * @see nanoxml.XMLElement#XMLElement(boolean)
+ * @see nanoxml.XMLElement#XMLElement(java.util.Hashtable) XMLElement(Hashtable)
+ */
+ public XMLElement_Localized(Hashtable entities, boolean skipLeadingWhitespace) {
+ this(entities, skipLeadingWhitespace, true, false);
+ }
+
+ /**
+ * Creates and initializes a new XML element.
+ *
+ * @param entities
+ * The entity conversion table.
+ * @param skipLeadingWhitespace
+ * <code>true</code> if leading and trailing whitespace in PCDATA content has to be removed.
+ * @param ignoreCase
+ * <code>true</code> if the case of element and attribute names have to be ignored.
+ *
+ * </dl>
+ * <dl>
+ * <dt><b>Preconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li><code>entities != null</code>
+ * </ul>
+ * </dd>
+ * </dl>
+ *
+ * <dl>
+ * <dt><b>Postconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>countChildren() => 0
+ * <li>enumerateChildren() => empty enumeration
+ * <li>enumeratePropertyNames() => empty enumeration
+ * <li>getChildren() => empty vector
+ * <li>getContent() => ""
+ * <li>getLineNr() => 0
+ * <li>getName() => null
+ * </ul>
+ * </dd>
+ * </dl>
+ * <dl>
+ *
+ * @see nanoxml.XMLElement#XMLElement()
+ * @see nanoxml.XMLElement#XMLElement(boolean)
+ * @see nanoxml.XMLElement#XMLElement(java.util.Hashtable) XMLElement(Hashtable)
+ * @see nanoxml.XMLElement#XMLElement(java.util.Hashtable,boolean) XMLElement(Hashtable, boolean)
+ */
+ public XMLElement_Localized(Hashtable entities, boolean skipLeadingWhitespace, boolean ignoreCase) {
+ this(entities, skipLeadingWhitespace, true, ignoreCase);
+ }
+
+ /**
+ * Creates and initializes a new XML element.
+ * <P>
+ * This constructor should <I>only</I> be called from {@link #createAnotherElement() createAnotherElement} to create child elements.
+ *
+ * @param entities
+ * The entity conversion table.
+ * @param skipLeadingWhitespace
+ * <code>true</code> if leading and trailing whitespace in PCDATA content has to be removed.
+ * @param fillBasicConversionTable
+ * <code>true</code> if the basic entities need to be added to the entity list.
+ * @param ignoreCase
+ * <code>true</code> if the case of element and attribute names have to be ignored.
+ *
+ * </dl>
+ * <dl>
+ * <dt><b>Preconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li><code>entities != null</code>
+ * <li>if <code>fillBasicConversionTable == false</code> then <code>entities</code> contains at least the following entries: <code>amp</code>, <code>lt</code>, <code>gt</code>, <code>apos</code> and <code>quot</code>
+ * </ul>
+ * </dd>
+ * </dl>
+ *
+ * <dl>
+ * <dt><b>Postconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>countChildren() => 0
+ * <li>enumerateChildren() => empty enumeration
+ * <li>enumeratePropertyNames() => empty enumeration
+ * <li>getChildren() => empty vector
+ * <li>getContent() => ""
+ * <li>getLineNr() => 0
+ * <li>getName() => null
+ * </ul>
+ * </dd>
+ * </dl>
+ * <dl>
+ *
+ * @see nanoxml.XMLElement#createAnotherElement()
+ */
+ protected XMLElement_Localized(Hashtable entities, boolean skipLeadingWhitespace, boolean fillBasicConversionTable, boolean ignoreCase) {
+ this.ignoreWhitespace = skipLeadingWhitespace;
+ this.ignoreCase = ignoreCase;
+ this.name = null;
+ this.contents = "";
+ this.attributes = new Hashtable();
+ this.children = new Vector();
+ this.entities = entities;
+ this.lineNr = 0;
+ Enumeration enumerator = this.entities.keys();
+ while (enumerator.hasMoreElements()) {
+ Object key = enumerator.nextElement();
+ Object value = this.entities.get(key);
+ if (value instanceof String) {
+ value = ((String) value).toCharArray();
+ this.entities.put(key, value);
+ }
+ }
+ if (fillBasicConversionTable) {
+ this.entities.put("amp", new char[] { '&' });
+ this.entities.put("quot", new char[] { '"' });
+ this.entities.put("apos", new char[] { '\'' });
+ this.entities.put("lt", new char[] { '<' });
+ this.entities.put("gt", new char[] { '>' });
+ }
+ }
+
+ /**
+ * Adds a child element.
+ *
+ * @param child
+ * The child element to add.
+ *
+ * </dl>
+ * <dl>
+ * <dt><b>Preconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li><code>child != null</code>
+ * <li><code>child.getName() != null</code>
+ * <li><code>child</code> does not have a parent element
+ * </ul>
+ * </dd>
+ * </dl>
+ *
+ * <dl>
+ * <dt><b>Postconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>countChildren() => old.countChildren() + 1
+ * <li>enumerateChildren() => old.enumerateChildren() + child
+ * <li>getChildren() => old.enumerateChildren() + child
+ * </ul>
+ * </dd>
+ * </dl>
+ * <dl>
+ *
+ * @see nanoxml.XMLElement#countChildren()
+ * @see nanoxml.XMLElement#enumerateChildren()
+ * @see nanoxml.XMLElement#getChildren()
+ * @see nanoxml.XMLElement#removeChild(nanoxml.XMLElement) removeChild(XMLElement)
+ */
+ public void addChild(XMLElement_Localized child) {
+ this.children.addElement(child);
+ }
+
+ public void removeChildren(String name) {
+ XMLElement[] elements = this.getChildren(name);
+ for (int i = 0; i < elements.length; i++) {
+ removeChild(elements[i]);
+ }
+ }
+
+ /**
+ * Adds or modifies an attribute.
+ *
+ * @param name
+ * The name of the attribute.
+ * @param value
+ * The value of the attribute.
+ *
+ * </dl>
+ * <dl>
+ * <dt><b>Preconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li><code>name != null</code>
+ * <li><code>name</code> is a valid XML identifier
+ * <li><code>value != null</code>
+ * </ul>
+ * </dd>
+ * </dl>
+ *
+ * <dl>
+ * <dt><b>Postconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>enumerateAttributeNames() => old.enumerateAttributeNames() + name
+ * <li>getAttribute(name) => value
+ * </ul>
+ * </dd>
+ * </dl>
+ * <dl>
+ *
+ * @see nanoxml.XMLElement#setDoubleAttribute(java.lang.String, double) setDoubleAttribute(String, double)
+ * @see nanoxml.XMLElement#setIntAttribute(java.lang.String, int) setIntAttribute(String, int)
+ * @see nanoxml.XMLElement#enumerateAttributeNames()
+ * @see nanoxml.XMLElement#getAttribute(java.lang.String) getAttribute(String)
+ * @see nanoxml.XMLElement#getAttribute(java.lang.String, java.lang.Object) getAttribute(String, Object)
+ * @see nanoxml.XMLElement#getAttribute(java.lang.String, java.util.Hashtable, java.lang.String, boolean) getAttribute(String, Hashtable, String, boolean)
+ * @see nanoxml.XMLElement#getStringAttribute(java.lang.String) getStringAttribute(String)
+ * @see nanoxml.XMLElement#getStringAttribute(java.lang.String, java.lang.String) getStringAttribute(String, String)
+ * @see nanoxml.XMLElement#getStringAttribute(java.lang.String, java.util.Hashtable, java.lang.String, boolean) getStringAttribute(String, Hashtable, String, boolean)
+ */
+ public void setAttribute(String name, Object value) {
+ if (this.ignoreCase) {
+ name = name.toUpperCase();
+ }
+ this.attributes.put(name, value);
+ }
+
+ public void setAttribute(String name, long value) {
+ setAttribute(name, new Long(value));
+ }
+
+ public void setAttribute(String name, boolean value) {
+ setAttribute(name, new Boolean(value));
+ }
+
+ public void setAttribute(String name, double value) {
+ //Object[] args = { new Double(value) };
+ setAttribute(name, new Double(value));
+ }
+
+ public void setAttribute(String name, float value) {
+ //Object[] args = { new Float(value) };
+ setAttribute(name, new Double(value));
+ }
+
+ public void setTypedAttribute(String name, String raw) {
+ boolean longOk=false;
+ boolean doubleOk=false;
+ boolean dump=false;
+ long l=-123L;
+ double d=-123.0;
+
+ if (raw.indexOf('@')!=-1) {
+ dump=true;
+ }
+ //try long in US format... note: you try this BEFORE you try the double since
+ //the double can also parse the long
+ try {
+ l=enUSFormat.parse(raw).longValue();
+ longOk=true;
+ } catch (ParseException e) {
+
+ }
+
+ //try understanding it as a double in US formate (xx.yyy)
+ try {
+ d=enUSFormat.parse(raw).doubleValue();
+ doubleOk=true;
+ } catch (ParseException ignored) {
+
+ }
+
+ if (dump) {
+ System.out.println("FART PARSE: Parsing "+raw+" and got "+longOk+" and "+doubleOk+" with "+l+" and "+d);
+ }
+
+ if ((longOk) && (doubleOk)) {
+ System.out.println("FART GOT BOTH OK:"+raw);
+ setAttribute(name, d);
+ return;
+ }
+
+ if (longOk) {
+ System.out.println("FART GOT LONG ONLY:"+raw);
+ setAttribute(name,l);
+ return;
+ }
+
+ if (doubleOk) {
+ System.out.println("FART GOT DOUBLE ONLY:"+raw);
+ setAttribute(name, d);
+ return;
+ }
+
+
+ //try boolean
+ if ((raw.equalsIgnoreCase("true")) || (raw.equalsIgnoreCase("false"))) {
+ raw=raw.toLowerCase();
+ setAttribute(name, Boolean.valueOf(raw));
+ return;
+ }
+
+ //hope it's a string
+ setAttribute(name, raw);
+ }
+
+ /**
+ * Adds or modifies an attribute.
+ *
+ * @param name
+ * The name of the attribute.
+ * @param value
+ * The value of the attribute.
+ *
+ * </dl>
+ * <dl>
+ * <dt><b>Preconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li><code>name != null</code>
+ * <li><code>name</code> is a valid XML identifier
+ * </ul>
+ * </dd>
+ * </dl>
+ *
+ * <dl>
+ * <dt><b>Postconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>enumerateAttributeNames() => old.enumerateAttributeNames() + name
+ * <li>getIntAttribute(name) => value
+ * </ul>
+ * </dd>
+ * </dl>
+ * <dl>
+ *
+ * @see nanoxml.XMLElement#setDoubleAttribute(java.lang.String, double) setDoubleAttribute(String, double)
+ * @see nanoxml.XMLElement#setAttribute(java.lang.String, java.lang.Object) setAttribute(String, Object)
+ * @see nanoxml.XMLElement#removeAttribute(java.lang.String) removeAttribute(String)
+ * @see nanoxml.XMLElement#enumerateAttributeNames()
+ * @see nanoxml.XMLElement#getIntAttribute(java.lang.String) getIntAttribute(String)
+ * @see nanoxml.XMLElement#getIntAttribute(java.lang.String, int) getIntAttribute(String, int)
+ * @see nanoxml.XMLElement#getIntAttribute(java.lang.String, java.util.Hashtable, java.lang.String, boolean) getIntAttribute(String, Hashtable, String, boolean)
+ */
+ public void setIntAttribute(String name, int value) {
+ if (this.ignoreCase) {
+ name = name.toUpperCase();
+ }
+ this.attributes.put(name, new Integer(value));
+ }
+
+ /**
+ * Adds or modifies an attribute.
+ *
+ * @param name
+ * The name of the attribute.
+ * @param value
+ * The value of the attribute.
+ *
+ * </dl>
+ * <dl>
+ * <dt><b>Preconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li><code>name != null</code>
+ * <li><code>name</code> is a valid XML identifier
+ * </ul>
+ * </dd>
+ * </dl>
+ *
+ * <dl>
+ * <dt><b>Postconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li>enumerateAttributeNames() => old.enumerateAttributeNames() + name
+ * <li>getDoubleAttribute(name) => value
+ * </ul>
+ * </dd>
+ * </dl>
+ * <dl>
+ *
+ * @see nanoxml.XMLElement#setIntAttribute(java.lang.String, int) setIntAttribute(String, int)
+ * @see nanoxml.XMLElement#setAttribute(java.lang.String, java.lang.Object) setAttribute(String, Object)
+ * @see nanoxml.XMLElement#removeAttribute(java.lang.String) removeAttribute(String)
+ * @see nanoxml.XMLElement#enumerateAttributeNames()
+ * @see nanoxml.XMLElement#getDoubleAttribute(java.lang.String) getDoubleAttribute(String)
+ * @see nanoxml.XMLElement#getDoubleAttribute(java.lang.String, double) getDoubleAttribute(String, double)
+ * @see nanoxml.XMLElement#getDoubleAttribute(java.lang.String, java.util.Hashtable, java.lang.String, boolean) getDoubleAttribute(String, Hashtable, String, boolean)
+ */
+ public void setDoubleAttribute(String name, double value) {
+ if (this.ignoreCase) {
+ name = name.toUpperCase();
+ }
+ this.attributes.put(name, new Double(value));
+ }
+
+ /**
+ * Returns the number of child elements of the element.
+ *
+ * <dl>
+ * <dt><b>Postconditions:</b></dt>
+ * <dd>
+ * <ul>
+ * <li><code>result >= 0</code>
+ * </ul>
+ * </dd>
+ * </dl>
+ *
+ * @see nanoxml.XMLElement#addChild(nanoxml.XMLElement) addChild(XMLElement)
+ * @see nanoxml.XMLEl...
[truncated message content] |
|
From: <ian...@us...> - 2008-01-10 18:22:20
|
Revision: 673
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=673&view=rev
Author: iansmith
Date: 2008-01-10 10:22:23 -0800 (Thu, 10 Jan 2008)
Log Message:
-----------
Improved error logging when we fail to migrate.
Added log4j config for ogoglio-server so you can debug it.
Added support for concurrent database access via hibernate configuration files.
Modified Paths:
--------------
maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java
maven/trunk/ogoglio-server/pom.xml
maven/trunk/ogoglio-server/src/main/resources/hibernate/hibernate.cfg.xml
maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-0.xml
maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-1.xml
Modified: maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java
===================================================================
--- maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java 2008-01-09 18:39:59 UTC (rev 672)
+++ maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java 2008-01-10 18:22:23 UTC (rev 673)
@@ -92,6 +92,7 @@
} else {
configuration.addProperties(ps.getAllProps(PropStorage.TEST_CONFIG_PROPS));
}
+ Log.info("Trying read in hibernate config ["+getResourcePath() + "/migration-" + num + ".xml"+"]");
configuration.addInputStream(UIConstants.getResource(getResourcePath() + "/migration-" + num + ".xml"));
return configuration.configure();
}
@@ -182,28 +183,30 @@
}
public boolean destroyAllData() {
+ Log.info("Destroying all data in the database and media serve... hope this is a dev machine.");
PropStorage ps = new PropStorage();
if (ps.loadPropertySet(PropStorage.TEST_CONFIG_PROPS) == false) {
+ Log.error("destroyAllData: unable to load the property set!");
return false;
}
-
if (initVersionOnly(false, ps) == false) {
+ Log.error("destroyAllData: unable to init the version number!");
return false;
}
if (tryUpgrade(null, null, 0, getVersionNumber(), DDL_MODE_CREATE, false, ps) == false) {
- Log.error("Aborted destroying data after failure to upgrade");
+ Log.error("destroyAllData: Aborted destroying data after failure to upgrade");
return false;
}
ps.loadPropertySet(PropStorage.BASIC_PROPS);
String dir = ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.mediaDirectory");
if (dir == null) {
- Log.error("Can't find a property ogoglio.mediaDirectory to cleanse media store");
+ Log.error("destroyAllData:Can't find a property ogoglio.mediaDirectory to cleanse media store");
return false;
}
if(!destroyFiles(new File(dir))){
- Log.error("Media directory doesn't exist or can't be changed:" + dir);
+ Log.error("destroyAllData: Media directory doesn't exist or can't be changed:" + dir);
return false;
}
Modified: maven/trunk/ogoglio-server/pom.xml
===================================================================
--- maven/trunk/ogoglio-server/pom.xml 2008-01-09 18:39:59 UTC (rev 672)
+++ maven/trunk/ogoglio-server/pom.xml 2008-01-10 18:22:23 UTC (rev 673)
@@ -34,6 +34,12 @@
</includes>
</resource>
<resource>
+ <directory>src/main/resources/log4j</directory>
+ <includes>
+ <include>log4j.properties</include>
+ </includes>
+ </resource>
+ <resource>
<targetPath>com/ogoglio/migrate</targetPath>
<directory>src/main/resources/hibernate</directory>
<includes>
Modified: maven/trunk/ogoglio-server/src/main/resources/hibernate/hibernate.cfg.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/hibernate/hibernate.cfg.xml 2008-01-09 18:39:59 UTC (rev 672)
+++ maven/trunk/ogoglio-server/src/main/resources/hibernate/hibernate.cfg.xml 2008-01-10 18:22:23 UTC (rev 673)
@@ -13,6 +13,5 @@
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
-->
-
</session-factory>
</hibernate-configuration>
Modified: maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-0.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-0.xml 2008-01-09 18:39:59 UTC (rev 672)
+++ maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-0.xml 2008-01-10 18:22:23 UTC (rev 673)
@@ -6,7 +6,7 @@
<!-- version 0... from a clean DB -->
<class name="com.ogoglio.appdev.migrate.DBVersionRecord" table="DBVersionRecords">
<id name="versionId">
- <generator class="increment"/>
+ <generator class="identity"/>
</id>
<property name="version" not-null="true"/>
</class>
Modified: maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-1.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-1.xml 2008-01-09 18:39:59 UTC (rev 672)
+++ maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-1.xml 2008-01-10 18:22:23 UTC (rev 673)
@@ -12,7 +12,7 @@
<class name="com.ogoglio.persist.ServiceStateRecord"
table="ServiceStateRecords">
<id name="serviceStateID">
- <generator class="increment" />
+ <generator class="identity" />
</id>
<property name="registrationState" not-null="true" />
</class>
@@ -30,7 +30,7 @@
<class name="com.ogoglio.persist.PossessionRecord"
table="PossessionRecords">
<id name="possessionID">
- <generator class="increment" />
+ <generator class="identity" />
</id>
<property name="ownerUsername" not-null="true" />
@@ -42,7 +42,7 @@
<class name="com.ogoglio.persist.SpaceRecord"
table="SpaceRecords">
<id name="spaceID" access="field">
- <generator class="increment" />
+ <generator class="identity" />
</id>
<property name="displayName" not-null="true" />
@@ -61,7 +61,7 @@
<class name="com.ogoglio.persist.SpaceMemberRecord"
table="SpaceMemberRecords">
<id name="spaceMemberID">
- <generator class="increment" />
+ <generator class="identity" />
</id>
<property name="spaceID" update="false" />
@@ -72,7 +72,7 @@
<class name="com.ogoglio.persist.SimRecord" table="SimRecords">
<id name="simID">
- <generator class="increment" />
+ <generator class="identity" />
</id>
<property name="displayName" />
@@ -83,7 +83,9 @@
<class name="com.ogoglio.persist.AccountRecord"
table="AccountRecords">
- <id name="username"></id>
+ <id name="username">
+ <generator class="assigned" />
+ </id>
<property name="email" not-null="true" unique="true" />
<property name="emailValid" />
<property name="accountlevel" not-null="true" />
@@ -102,7 +104,7 @@
<class name="com.ogoglio.persist.TemplateRecord"
table="TemplateRecords">
<id name="templateID">
- <generator class="increment" />
+ <generator class="identity" />
</id>
<property name="ownerUsername" not-null="true" />
@@ -127,9 +129,9 @@
</class>
<class name="com.ogoglio.appdev.migrate.DBVersionRecord"
- table="DBVersionRecords">
+ table="DBVersion">
<id name="versionId">
- <generator class="increment" />
+ <generator class="identity" />
</id>
<property name="version" not-null="true" />
</class>
@@ -137,7 +139,7 @@
<class name="com.ogoglio.persist.TemplateSupportFileRecord"
table="TemplateSupportFileRecords">
<id name="templateSupportFileID">
- <generator class="increment" />
+ <generator class="identity" />
</id>
<property name="supportFile" />
<property name="script" not-null="true" />
@@ -148,7 +150,7 @@
<class name="com.ogoglio.persist.BodyDataRecord"
table="BodyDataRecords">
<id name="bodyDataID">
- <generator class="increment" />
+ <generator class="identity" />
</id>
<property name="displayName" not-null="true" />
<property name="fileName" not-null="true" unique="true" />
@@ -157,7 +159,7 @@
<class name="com.ogoglio.persist.BodyConfigurationRecord"
table="BodyConfigurationRecords">
<id name="bodyConfigurationID">
- <generator class="increment" />
+ <generator class="identity" />
</id>
<property name="ownerUsername" not-null="true" />
<property name="displayName" not-null="true" />
@@ -168,7 +170,7 @@
<class name="com.ogoglio.persist.BodySettingRecord"
table="BodySettingRecords">
<id name="bodySettingID">
- <generator class="increment" />
+ <generator class="identity" />
</id>
<property name="settingName" not-null="true" />
<property name="setting" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <duc...@us...> - 2008-01-31 23:07:07
|
Revision: 704
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=704&view=rev
Author: ducheneaut
Date: 2008-01-31 15:07:09 -0800 (Thu, 31 Jan 2008)
Log Message:
-----------
Deal more gracefully with the (rare) occasions when files checked out by SVN on MacOS X have exactly the same timestamp, causing og:populate to throw an exception. Instead, PopulateMojo now increases a file's timestamp by a few milliseconds if it's equal to another one.
Modified Paths:
--------------
maven/trunk/dev-plugins/.classpath
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
maven/trunk/ogoglio/.classpath
maven/trunk/ogoglio-bodies/.classpath
maven/trunk/ogoglio-server/.classpath
Modified: maven/trunk/dev-plugins/.classpath
===================================================================
--- maven/trunk/dev-plugins/.classpath 2008-01-31 19:01:00 UTC (rev 703)
+++ maven/trunk/dev-plugins/.classpath 2008-01-31 23:07:09 UTC (rev 704)
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/main/resources"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="src" path="src/test/java"/>
+ <classpathentry excluding="**" kind="src" output="src/main/resources" path="src/main/resources"/>
+ <classpathentry excluding="**" kind="src" output="src/test/resources" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
Modified: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java 2008-01-31 19:01:00 UTC (rev 703)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java 2008-01-31 23:07:09 UTC (rev 704)
@@ -42,7 +42,7 @@
private Map<Long, SpaceDocument> localSpaces = new HashMap<Long, SpaceDocument>();
- private Map<String, SpaceDocument> serveSpacerNameToSpaceDoc = new HashMap<String, SpaceDocument>();
+ private Map<String, SpaceDocument> serverSpaceNameToSpaceDoc = new HashMap<String, SpaceDocument>();
private Map<String, TemplateDocument> existingServerTemplates = null;
@@ -67,14 +67,14 @@
if (candidate.getName().startsWith(TEMPLATE_PREFIX)) {
uploadTemplate(client, candidate, existingServerTemplates);
} else if (candidate.getName().startsWith(SPACE_PREFIX)) {
- readSpace(client, candidate);
+ readSpace(client, candidate, i);
} else {
if (!candidate.getName().equals(".svn")) {
getLog().warn("Unable to process in populate:" + candidate.getAbsolutePath());
}
}
}
- serveSpacerNameToSpaceDoc = getAllServerSpaces(client);
+ serverSpaceNameToSpaceDoc = getAllServerSpaces(client);
patchSpaces(client);
}
@@ -110,8 +110,8 @@
try {
long localModTime = iter.next();
fakeSpaceDoc = localSpaces.get(localModTime);
- if (serveSpacerNameToSpaceDoc.containsKey(fakeSpaceDoc.getDisplayName())) {
- realSpaceDoc = serveSpacerNameToSpaceDoc.get(fakeSpaceDoc.getDisplayName());
+ if (serverSpaceNameToSpaceDoc.containsKey(fakeSpaceDoc.getDisplayName())) {
+ realSpaceDoc = serverSpaceNameToSpaceDoc.get(fakeSpaceDoc.getDisplayName());
Date fileModified = new Date(localModTime);
Date serverModified = TemplateSupportFileDocument.fmt.parse(realSpaceDoc.getLastModifiedAsUTC());
@@ -167,7 +167,7 @@
}
}
- private void readSpace(WebAPIClient client, File candidate) throws MojoExecutionException {
+ private void readSpace(WebAPIClient client, File candidate, int fileNumber) throws MojoExecutionException {
String name = candidate.getName();
String num = name.substring(SPACE_PREFIX.length());
int spaceFakeId = -189;
@@ -183,10 +183,13 @@
FileInputStream inputStream = new FileInputStream(candidate);
String docContent = StreamUtils.readInput(inputStream);
SpaceDocument doc = new SpaceDocument(XMLElement.parseElementFromString(docContent));
- if(localSpaces.get(candidate.lastModified()) != null){
- throw new MojoExecutionException("Sadly, space-* docs must have unique timestamps.");
+ long timeStamp = candidate.lastModified();
+ if(localSpaces.get(timeStamp) != null){
+ // Rare occurrence: sometimes files checked out by SVN on MacOS X end up having exactly the same timestamp
+ // Simply increment it by a few milliseconds and use the new value for the index
+ timeStamp = candidate.lastModified() + fileNumber;
}
- localSpaces.put(candidate.lastModified(), doc);
+ localSpaces.put(timeStamp, doc);
inputStream.close();
} catch (IOException e) {
throw new MojoExecutionException("IO Error reading space", e);
Modified: maven/trunk/ogoglio/.classpath
===================================================================
--- maven/trunk/ogoglio/.classpath 2008-01-31 19:01:00 UTC (rev 703)
+++ maven/trunk/ogoglio/.classpath 2008-01-31 23:07:09 UTC (rev 704)
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/main/resources"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="src" path="src/test/java"/>
+ <classpathentry excluding="**" kind="src" output="src/main/resources" path="src/main/resources"/>
+ <classpathentry excluding="**" kind="src" output="src/test/resources" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
Modified: maven/trunk/ogoglio-bodies/.classpath
===================================================================
--- maven/trunk/ogoglio-bodies/.classpath 2008-01-31 19:01:00 UTC (rev 703)
+++ maven/trunk/ogoglio-bodies/.classpath 2008-01-31 23:07:09 UTC (rev 704)
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="ogoglio-body-tools/src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
Modified: maven/trunk/ogoglio-server/.classpath
===================================================================
--- maven/trunk/ogoglio-server/.classpath 2008-01-31 19:01:00 UTC (rev 703)
+++ maven/trunk/ogoglio-server/.classpath 2008-01-31 23:07:09 UTC (rev 704)
@@ -6,10 +6,6 @@
<classpathentry excluding="**" kind="src" output="src/main/resources/hibernate" path="src/main/resources/hibernate"/>
<classpathentry excluding="**" kind="src" output="src/test/resources" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
- <attributes>
- <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="/usr/local/jdk1.5.0_12/jre/lib/i386"/>
- </attributes>
- </classpathentry>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2008-02-01 23:48:57
|
Revision: 705
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=705&view=rev
Author: iansmith
Date: 2008-02-01 15:48:38 -0800 (Fri, 01 Feb 2008)
Log Message:
-----------
Added some chicanery so that our openGL settings don't hose an EC2 instance.
Pom changes so we can debug with log4j (sigh) in ogoglio integration tests.
Modified Paths:
--------------
maven/trunk/ogoglio-appdev/pom.xml
maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java
maven/trunk/ogoglio-integration-test/pom.xml
maven/trunk/ogoglio-server/pom.xml
Modified: maven/trunk/ogoglio-appdev/pom.xml
===================================================================
--- maven/trunk/ogoglio-appdev/pom.xml 2008-01-31 23:07:09 UTC (rev 704)
+++ maven/trunk/ogoglio-appdev/pom.xml 2008-02-01 23:48:38 UTC (rev 705)
@@ -15,7 +15,7 @@
<dependencies>
<dependency>
- <groupId>com.sun</groupId>
+ <groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
<scope>provided</scope>
Modified: maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java
===================================================================
--- maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2008-01-31 23:07:09 UTC (rev 704)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2008-02-01 23:48:38 UTC (rev 705)
@@ -382,13 +382,13 @@
setLayout(new BorderLayout());
universe = new J3DUniverse();
- canvas = new J3DCanvas(J3DRenderer.getGraphicsConfiguration(), false);
+ canvas = new J3DCanvas(J3DRenderer.getGraphicsConfiguration(false), false);
canvas.addMouseWheelListener(this);
camera = new J3DCamera();
camera.setCanvas(canvas);
add(canvas, BorderLayout.CENTER);
- offscreenCanvas = new J3DCanvas(J3DRenderer.getGraphicsConfiguration(), true);
+ offscreenCanvas = new J3DCanvas(J3DRenderer.getGraphicsConfiguration(false), true);
camera.getView().addCanvas3D(offscreenCanvas);
setupUniverse();
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2008-01-31 23:07:09 UTC (rev 704)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2008-02-01 23:48:38 UTC (rev 705)
@@ -128,7 +128,7 @@
setCapabilities(sceneRoot);
setCapabilities(usersGroup);
setCapabilities(worldGroup);
- GraphicsConfiguration graphicsConfig = getGraphicsConfiguration();
+ GraphicsConfiguration graphicsConfig = getGraphicsConfiguration(this.offScreen);
if (graphicsConfig == null) {
throw new IllegalStateException("Cannot create a 3D graphics configuration.");
}
@@ -747,13 +747,15 @@
return renderable;
}
- public static GraphicsConfiguration getGraphicsConfiguration() {
+ public static GraphicsConfiguration getGraphicsConfiguration(boolean offscreen) {
GraphicsConfigTemplate3D configTemplate = new GraphicsConfigTemplate3D();
configTemplate.setSceneAntialiasing(GraphicsConfigTemplate.PREFERRED);
configTemplate.setDoubleBuffer(GraphicsConfigTemplate.PREFERRED);
- configTemplate.setBlueSize(8);
- configTemplate.setRedSize(8);
- configTemplate.setGreenSize(8);
+ if (!offscreen) { //it appears that these lines hose up an EC2 instance running j3d
+ configTemplate.setBlueSize(8);
+ configTemplate.setRedSize(8);
+ configTemplate.setGreenSize(8);
+ }
GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(configTemplate);
if (config != null) {
return config;
Modified: maven/trunk/ogoglio-integration-test/pom.xml
===================================================================
--- maven/trunk/ogoglio-integration-test/pom.xml 2008-01-31 23:07:09 UTC (rev 704)
+++ maven/trunk/ogoglio-integration-test/pom.xml 2008-02-01 23:48:38 UTC (rev 705)
@@ -16,6 +16,14 @@
<packaging>jar</packaging>
<build>
+ <resources>
+ <resource>
+ <directory>src/main/resources/log4j</directory>
+ <includes>
+ <include>log4j.properties</include>
+ </includes>
+ </resource>
+ </resources>
<testResources>
<testResource>
<filtering>true</filtering>
Modified: maven/trunk/ogoglio-server/pom.xml
===================================================================
--- maven/trunk/ogoglio-server/pom.xml 2008-01-31 23:07:09 UTC (rev 704)
+++ maven/trunk/ogoglio-server/pom.xml 2008-02-01 23:48:38 UTC (rev 705)
@@ -295,7 +295,7 @@
</dependency>
<dependency>
- <groupId>com.sun</groupId>
+ <groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
<scope>provided</scope>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2008-02-05 04:00:21
|
Revision: 706
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=706&view=rev
Author: iansmith
Date: 2008-02-04 20:00:23 -0800 (Mon, 04 Feb 2008)
Log Message:
-----------
Added support for a new optional argument in server.xml (preferredIPAddr). This allows the
server configuration to control what IP the server will give out for itself when asked. This returned via the ServiceDocument that can be grabbed from the BaseSpace resource.
This was needed because it appears amazon uses a NAT interface via Xen to protect instances, thus servers were (wrongly, from a client point of view) reporting their IP addr as a local address, like 10.1.2.3. This interacted badly (sigh) with our workaround to the sun security
problem that appeared in java 1.6_03 that required us to use IP addresses to address the server.
Really, most people will never need this. Really.
Modified Paths:
--------------
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/VerifyEnvironmentMojo.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/WebappServletBase.java
maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml
Modified: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/VerifyEnvironmentMojo.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/VerifyEnvironmentMojo.java 2008-02-01 23:48:38 UTC (rev 705)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/VerifyEnvironmentMojo.java 2008-02-05 04:00:23 UTC (rev 706)
@@ -29,6 +29,11 @@
"UserDatabase",
"mailSession"
};
+
+ private static final String[] OPTIONAL_NAMES= {
+ "preferredIPAddr"
+ };
+
/**
* @parameter
*/
@@ -108,7 +113,7 @@
Iterator<String> it = resourceLinkMap.keySet().iterator();
while (it.hasNext()) {
String target = it.next();
- if (!areDefined.contains(target)) {
+ if ((!areDefined.contains(target)) && (!isOptional(target))) {
result.add(target);
}
}
@@ -116,6 +121,15 @@
}
+ private boolean isOptional(String target) {
+ for (int i=0; i<OPTIONAL_NAMES.length;++i) {
+ if (OPTIONAL_NAMES[i].equals(target)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private Map<String,String> computeExpectedLinks(XMLElement contextRoot) throws MojoExecutionException {
Map<String,String> result=new HashMap<String,String>();
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2008-02-01 23:48:38 UTC (rev 705)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2008-02-05 04:00:23 UTC (rev 706)
@@ -109,7 +109,11 @@
}
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
- ServiceDocument serviceDocument = new ServiceDocument(messageProxy.getUserCount(), messageProxy.getSimCount(), request.getLocalAddr());
+ String localAddr=request.getLocalAddr();
+ if (preferredIPAddr!=null) {
+ localAddr=preferredIPAddr;
+ }
+ ServiceDocument serviceDocument = new ServiceDocument(messageProxy.getUserCount(), messageProxy.getSimCount(), localAddr);
sendStringResponse(serviceDocument.toString(), "text/xml", response);
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/WebappServletBase.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/WebappServletBase.java 2008-02-01 23:48:38 UTC (rev 705)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/WebappServletBase.java 2008-02-05 04:00:23 UTC (rev 706)
@@ -1,6 +1,7 @@
package com.ogoglio.site;
import javax.naming.Context;
+import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -8,6 +9,7 @@
public abstract class WebappServletBase extends OgoglioServletBase {
protected boolean servletNeeded=true;
+ protected String preferredIPAddr=null;
public void init(ServletConfig config) throws ServletException {
try {
@@ -17,6 +19,11 @@
if ("false".equals(useMe.toLowerCase())) {
servletNeeded=false;
}
+ try {
+ preferredIPAddr = (String) envCtx.lookup("ogoglio/preferredIPAddr");
+ } catch (NameNotFoundException e) {
+ //this is optional
+ }
super.init(config);
} catch (NamingException e) {
bailOutOfInit(e);
Modified: maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml 2008-02-01 23:48:38 UTC (rev 705)
+++ maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml 2008-02-05 04:00:23 UTC (rev 706)
@@ -23,4 +23,6 @@
<ResourceLink name="ogoglio/simFilter" global="simFilter" type="java.lang.String"/>
<ResourceLink name="ogoglio/simFilterPort" global="simFilterPort" type="java.lang.String"/>
+ <ResourceLink name="ogoglio/preferredIPAddr" global="preferredIPAddr" type="java.lang.String"/>
+
</Context>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <duc...@us...> - 2008-02-07 00:01:38
|
Revision: 718
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=718&view=rev
Author: ducheneaut
Date: 2008-02-06 16:01:39 -0800 (Wed, 06 Feb 2008)
Log Message:
-----------
Fixed a bug that prevented pages from persisting across sessions. Pages are translated into PageDocuments that are included in a Thing's ThingDocument, which is in turn dumped to disk as part of the SpaceDocument on logout.
Note that this has implications for template scripts: they must NOT call createTextPage in their constructor anymore (unless you want page contents to be re-created from scratch all the time). Instead the recommended approach is to call getPageIDs to see if we have pages from previous sessions in the SpaceDocument, and point the script at the correct pageIDs if they exist. See whiteboard.js for an example.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Page.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Thing.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/PageDocument.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/ThingDocument.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSpace.java
maven/trunk/ogoglio-server/src/main/resources/populate/template-28/WhiteBoard.js
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Page.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Page.java 2008-02-06 17:31:15 UTC (rev 717)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Page.java 2008-02-07 00:01:39 UTC (rev 718)
@@ -5,6 +5,8 @@
import javax.media.j3d.Transform3D;
+import com.ogoglio.xml.PageDocument;
+
public class Page {
public static final String TEXT_PLAIN = "text/plain";
@@ -31,6 +33,11 @@
private double height = -1;
+ public Page(Thing thing, PageDocument document) {
+ this(thing, document.getPageID(), document.getContentType(), document.getWidth(), document.getHeight(), document.getTransform());
+
+ }
+
public Page(Thing thing, long pageID, String contentType, double width, double height, Transform3D position) {
this.thing = thing;
this.pageID = pageID;
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Thing.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Thing.java 2008-02-06 17:31:15 UTC (rev 717)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Thing.java 2008-02-07 00:01:39 UTC (rev 718)
@@ -14,13 +14,12 @@
package com.ogoglio.client.model;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.HashMap;
import javax.media.j3d.Transform3D;
import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.xml.PageDocument;
import com.ogoglio.xml.ShapeDocument;
import com.ogoglio.xml.ThingDocument;
@@ -54,6 +53,10 @@
for (int i = 0; i < shapeDocs.length; i++) {
addShape(new Shape(this, shapeDocs[i]));
}
+ PageDocument[] pageDocs = thingDoc.getPageDocuments();
+ for (int j = 0; j < pageDocs.length; j++) {
+ addPageFromThingDocument(new Page(this, pageDocs[j]));
+ }
}
public Thing(Space space, long thingID, Template template, String name, String ownerUsername, long possessionID, Transform3D position) {
@@ -146,6 +149,13 @@
pages.put(new Long(page.getPageID()), page);
space.notifyPageAdded(page);
}
+
+ public void addPageFromThingDocument(Page page) {
+ if (pages.get(new Long(page.getPageID())) != null) {
+ return;
+ }
+ pages.put(new Long(page.getPageID()), page);
+ }
public void removePage(Page page) {
if (pages.remove(new Long(page.getPageID())) == null) {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/PageDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/PageDocument.java 2008-02-06 17:31:15 UTC (rev 717)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/PageDocument.java 2008-02-07 00:01:39 UTC (rev 718)
@@ -2,6 +2,8 @@
import javax.media.j3d.Transform3D;
+import com.ogoglio.client.model.Page;
+
import nanoxml.XMLElement;
public class PageDocument extends PositionedDocument {
@@ -15,6 +17,10 @@
public static final String HEIGHT = "height";
+ public PageDocument(Page page) {
+ this(page.getPageID(), page.getContentType(), page.getWidth(), page.getHeight(), page.getPosition());
+ }
+
public PageDocument(long pageID, String contentType, double width, double height, Transform3D position) {
super(NAME, position, null);
getData().setAttribute(PAGE_ID, pageID);
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/ThingDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/ThingDocument.java 2008-02-06 17:31:15 UTC (rev 717)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/ThingDocument.java 2008-02-07 00:01:39 UTC (rev 718)
@@ -17,6 +17,7 @@
import nanoxml.XMLElement;
+import com.ogoglio.client.model.Page;
import com.ogoglio.client.model.Shape;
import com.ogoglio.client.model.SplinePath;
import com.ogoglio.client.model.Thing;
@@ -44,7 +45,11 @@
getData().addChild(new ShapeDocument(shapes[i]).toElement());
}
- //we don't automatically store pages, because they're ephemeral between space instances
+ // Persist pages to disk also, to avoid loosing images between sessions
+ Page[] pages = thing.getPages();
+ for (int j = 0; j < pages.length; j++) {
+ getData().addChild(new PageDocument(pages[j]).toElement());
+ }
}
public ThingDocument(long thingID, String displayName, long templateID, String templateOwner, String ownerUsername, long possessionID, Transform3D transform, SplinePath splinePath) {
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2008-02-06 17:31:15 UTC (rev 717)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2008-02-07 00:01:39 UTC (rev 718)
@@ -56,7 +56,6 @@
import com.ogoglio.xml.SettingDocument;
import com.ogoglio.xml.SpaceDocument;
import com.ogoglio.xml.SpaceEvent;
-import com.ogoglio.xml.SpaceMemberDocument;
import com.ogoglio.xml.TemplateDocument;
import com.ogoglio.xml.ThingDocument;
import com.ogoglio.xml.UserDocument;
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSpace.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSpace.java 2008-02-06 17:31:15 UTC (rev 717)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSpace.java 2008-02-07 00:01:39 UTC (rev 718)
@@ -22,7 +22,6 @@
import java.util.TimerTask;
import javax.media.j3d.Transform3D;
-import javax.vecmath.Point3f;
import javax.vecmath.Quat4d;
import javax.vecmath.Vector3d;
@@ -39,7 +38,6 @@
import com.ogoglio.sim.SpaceSimulator;
import com.ogoglio.util.ArgumentUtils;
import com.ogoglio.util.Log;
-import com.ogoglio.viewer.j3d.J3DSplineKeyFrame;
import com.ogoglio.viewer.j3d.J3DSplinePath;
import com.ogoglio.xml.PageDocument;
import com.ogoglio.xml.SpaceEvent;
@@ -203,7 +201,7 @@
spaceSimulator.setPageContent((long) thingID, pageID, Page.TEXT_PLAIN, content);
return pageID;
}
-
+
public void jsFunction_setTextPageContent(double thingID, double pageID, String content) {
spaceSimulator.setPageContent((long) thingID, (long) pageID, Page.TEXT_PLAIN, content);
}
Modified: maven/trunk/ogoglio-server/src/main/resources/populate/template-28/WhiteBoard.js
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/populate/template-28/WhiteBoard.js 2008-02-06 17:31:15 UTC (rev 717)
+++ maven/trunk/ogoglio-server/src/main/resources/populate/template-28/WhiteBoard.js 2008-02-07 00:01:39 UTC (rev 718)
@@ -9,8 +9,12 @@
function construct(id){
thingID = id;
textSettingKey = "thing." + thingID + ".whiteboard.text";
-
- pageID = space.createTextPage(thingID, 4, 2, htmlPrefix + formatBoardText(getTextSetting()) + htmlSuffix, 0, 2, 0.1, 0, math.PI, 0);
+ var pageIDs = space.getPageIDs(thingID);
+ if (pageIDs.length == 0) {
+ pageID = space.createTextPage(thingID, 4, 2, htmlPrefix + formatBoardText(getTextSetting()) + htmlSuffix, 0, 2, 0.1, 0, math.PI, 0);
+ } else {
+ pageID = pageIDs[0]; // Note: whiteboards are assumed to have only one page.
+ }
}
function cleanup(){
@@ -129,6 +133,7 @@
var imageReq = new HTTPRequest(thingID, "GET", url, handleImageResponse);
imageReq.setDestinationPage(space, thingID, pageID);
imageReq.send();
+ space.removeSetting(textSettingKey);
}
function handleImageResponse(requestingThingID, request){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2008-02-07 02:31:46
|
Revision: 720
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=720&view=rev
Author: iansmith
Date: 2008-02-06 18:28:03 -0800 (Wed, 06 Feb 2008)
Log Message:
-----------
Added a migration to fix the SimRecords in the database to have the fields we want and dropped the old fields we were not using.
This checkin does not change functionality, it just does the same things as the old version with this new datamodel. Tests and various places were updated to reflect the new data model and semantics, including "retirement" of sims.
For hibernate reasons, I was forced to add some bogus code in SimRecords. This only increases the size of the SimRecord class' code by a few bytes, so it seemed better than fighting hibernate.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SimDocument.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java
maven/trunk/ogoglio-server/pom.xml
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/migrate/OgoglioServerMigration.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/ServiceInitializationPersistTasks.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimPersistTasks.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimRecord.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpacePersistTasks.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SimMessageHandler.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/xml/server/DocumentFactory.java
maven/trunk/ogoglio-server/src/test/java/com/ogoglio/persist/test/PersistTest.java
Added Paths:
-----------
maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-3.xml
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SimDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SimDocument.java 2008-02-07 01:01:18 UTC (rev 719)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SimDocument.java 2008-02-07 02:28:03 UTC (rev 720)
@@ -27,26 +27,26 @@
public static final String SIM_URI = "simuri";
- public static final String DISPLAY_NAME = "displayname";
+ public static final String REACHABLE = "reachable";
- public static final String ACTIVE = "active";
+ public static final String RETIRED = "retired";
XMLElement data = null;
- public SimDocument(long simID, URI simURI, String displayName, boolean active) {
- if (active && simURI == null) {
- throw new IllegalArgumentException("Active sims need a URI: " + simURI);
+ public SimDocument(long simID, URI simURI, boolean reachable, boolean retired) {
+ if (reachable && simURI == null) {
+ throw new IllegalArgumentException("Reachable sims need a URI: " + simURI);
}
- if (displayName == null) {
- throw new IllegalArgumentException("You must name the sim");
+ if (!retired && simURI == null) {
+ throw new IllegalArgumentException("Non-retired sims need a URI: " + simURI);
}
data = new XMLElement(NAME);
if (simURI != null) {
data.setAttribute(SIM_URI, simURI.toString());
}
data.setAttribute(SIM_ID, simID);
- data.setAttribute(DISPLAY_NAME, displayName);
- data.setAttribute(ACTIVE, active);
+ data.setAttribute(REACHABLE, reachable);
+ data.setAttribute(RETIRED, retired);
}
public SimDocument(XMLElement data) {
@@ -54,11 +54,14 @@
throw new IllegalArgumentException("SimDocument data is null");
}
if (!NAME.equals(data.getName())) {
- throw new IllegalArgumentException("SimDocument data is not named Auth: " + data);
+ throw new IllegalArgumentException("SimDocument data is not named Sim: " + data);
}
- if (data.getBooleanAttribute(ACTIVE, false) && data.getStringAttribute(SIM_URI) == null) {
- throw new IllegalArgumentException("No sim URI in active sim document");
+ if (data.getBooleanAttribute(REACHABLE, false) && data.getStringAttribute(SIM_URI) == null) {
+ throw new IllegalArgumentException("No sim URI in reachable sim document");
}
+ if (data.getBooleanAttribute(RETIRED, false) && data.getStringAttribute(SIM_URI) == null) {
+ throw new IllegalArgumentException("No sim URI in a non-retired sim document");
+ }
this.data = data;
}
@@ -74,12 +77,12 @@
return data.getLongAttribute(SIM_ID);
}
- public boolean isActive() {
- return data.getBooleanAttribute(ACTIVE, false);
+ public boolean isReachable() {
+ return data.getBooleanAttribute(REACHABLE, false);
}
- public String getDisplayName() {
- return data.getStringAttribute(DISPLAY_NAME);
+ public boolean isRetired() {
+ return data.getBooleanAttribute(RETIRED, false);
}
public URI getSimURI() {
Modified: maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java 2008-02-07 01:01:18 UTC (rev 719)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java 2008-02-07 02:28:03 UTC (rev 720)
@@ -122,23 +122,29 @@
}
public void testSimDocuments() {
- SimDocument simDoc1 = new SimDocument(1, simURI1, displayName1, true);
+ SimDocument simDoc1 = new SimDocument(1, simURI1, true, false);
assertEquals(1, simDoc1.getSimID());
- assertEquals(displayName1, simDoc1.getDisplayName());
assertEquals(simURI1, simDoc1.getSimURI());
- assertEquals(true, simDoc1.isActive());
+ assertEquals(true, simDoc1.isReachable());
+ assertEquals(false, simDoc1.isRetired());
SimDocument simDoc2 = new SimDocument(XMLElement.parseElementFromString(simDoc1.toElement().toString()));
- assertEquals(displayName1, simDoc2.getDisplayName());
assertEquals(simURI1, simDoc2.getSimURI());
- assertEquals(true, simDoc2.isActive());
+ assertEquals(true, simDoc2.isReachable());
+ assertEquals(false, simDoc2.isRetired());
try {
- new SimDocument(1, null, displayName1, true);
- fail("Shouldn't allow null URIs when active");
+ new SimDocument(1, null, true, true);
+ fail("Shouldn't allow null URIs when reachable");
} catch (IllegalArgumentException e) {
//this should happen
}
+ try {
+ new SimDocument(1, null, false, false);
+ fail("Shouldn't allow null URIs when not retired");
+ } catch (IllegalArgumentException e) {
+ //this should happen
+ }
String displayName = "Rolling Donuts";
ThingDocument doc1 = new ThingDocument(1, displayName, 2, "susan", "susan", 1, new Transform3D(), null);
Modified: maven/trunk/ogoglio-server/pom.xml
===================================================================
--- maven/trunk/ogoglio-server/pom.xml 2008-02-07 01:01:18 UTC (rev 719)
+++ maven/trunk/ogoglio-server/pom.xml 2008-02-07 02:28:03 UTC (rev 720)
@@ -207,7 +207,6 @@
<!-- these are for the populate -->
<configuration>
-
<serviceURI>${ogoglio.baseURL}</serviceURI>
<username>${ogoglio.bootstrapUser}</username>
<password>${ogoglio.bootstrapUserPW}</password>
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/migrate/OgoglioServerMigration.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/migrate/OgoglioServerMigration.java 2008-02-07 01:01:18 UTC (rev 719)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/migrate/OgoglioServerMigration.java 2008-02-07 02:28:03 UTC (rev 720)
@@ -17,10 +17,10 @@
public static final OgoglioServerMigration SINGLETON = new OgoglioServerMigration();
// THIS IS THE CRITICAL VERSION NUMBER
- private static final int DB_VERSION_NUMBER = 2;
+ private static final int DB_VERSION_NUMBER = 3;
// this is the set of semantic migrations, in order
- private static final Migration[] migration = { new AccountsForTesting(), new NoopMigration() };
+ private static final Migration[] migration = { new AccountsForTesting(), new NoopMigration(), new NoopMigration() };
public Migration[] getMigrationList() {
return migration;
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/ServiceInitializationPersistTasks.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/ServiceInitializationPersistTasks.java 2008-02-07 01:01:18 UTC (rev 719)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/ServiceInitializationPersistTasks.java 2008-02-07 02:28:03 UTC (rev 720)
@@ -21,8 +21,6 @@
public class ServiceInitializationPersistTasks {
- public static final String LOCAL_SIM_DISPLAY_NAME = "Localhost Sim";
-
public static final String DEFAULT_LAND_DISPLAY_NAME = "Default Land";
public static final String DEFAULT_DOOR_DISPLAY_NAME = "Default Door";
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimPersistTasks.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimPersistTasks.java 2008-02-07 01:01:18 UTC (rev 719)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimPersistTasks.java 2008-02-07 02:28:03 UTC (rev 720)
@@ -28,8 +28,10 @@
public static final String SIM_BY_ID = "com.ogoglio.persist.simBySimID";
- public static final String SIMS_BY_ACTIVE = "com.ogoglio.persist.simsByActive";
+ public static final String SIMS_BY_REACHABLE_AND_RETIRED= "com.ogoglio.persist.simsByReachableAndRetired";
+ public static final String SIMS_BY_REACHABLE= "com.ogoglio.persist.simsByReachable";
+
public static final String SIMS = "com.ogoglio.persist.sims";
public static SimRecord[] findSims(SessionFactory sessionFactory) throws PersistException {
@@ -55,10 +57,10 @@
return (SimRecord) task.execute();
}
- public static SimRecord createSim(final String displayName, final URI simURI, final int eventPort, final boolean active, SessionFactory sessionFactory) throws PersistException {
+ public static SimRecord createSim(final URI simURI, final boolean reachable, final boolean retired, SessionFactory sessionFactory) throws PersistException {
HibernateTask task = new HibernateTask() {
public Object run(Session hibernateSession) {
- SimRecord record = new SimRecord(displayName, simURI, eventPort, active);
+ SimRecord record = new SimRecord(simURI, reachable, retired);
hibernateSession.save(record);
return record;
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimRecord.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimRecord.java 2008-02-07 01:01:18 UTC (rev 719)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimRecord.java 2008-02-07 02:28:03 UTC (rev 720)
@@ -19,18 +19,14 @@
public class SimRecord {
- public static final int DEFAULT_EVENT_PORT = 8932;
-
private long simID = -1;
- private String displayName = null;
-
private String simURIString = null;
- private int eventPort = -1;
+ private boolean reachable = false;
+
+ private boolean retired = false;
- private boolean active = false;
-
/***
* The SimRecord stores the connection information for a simulation server which can simultaneously simulate multiple spaces
*/
@@ -39,29 +35,28 @@
}
- public SimRecord(String displayName, URI simURI, int eventPort, boolean active) {
- this.displayName = displayName;
+ public SimRecord(URI simURI, boolean reachable, boolean retired) {
if (simURI != null) {
this.simURIString = simURI.toString();
}
- this.eventPort = eventPort;
- this.active = active;
+ this.reachable=reachable;
+ this.retired=retired;
}
- public boolean isActive() {
- return active;
+ public boolean isReachable() {
+ return reachable;
}
- public void setActive(boolean active) {
- this.active = active;
+ public void setReachable(boolean reachable) {
+ this.reachable= reachable;
}
- public String getDisplayName() {
- return displayName;
+ public boolean isRetired() {
+ return retired;
}
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
+ public void setRetired(boolean retired) {
+ this.retired= retired;
}
public long getSimID() {
@@ -106,12 +101,26 @@
public int hashCode() {
return ("SimRecord-YO" + getSimID()).hashCode();
}
-
- public int getEventPort() {
- return eventPort;
+
+ /*
+ * This is pretty darn evil. XXX EVIL XXX
+ */
+ private String getDisplayName() { //FIELD NO LONGER EXISTS
+ return null;
}
-
- public void setEventPort(int eventPort) {
- this.eventPort = eventPort;
+
+ private void setDisplayName(String IGNORED) { //FIELD NO LONGER EXISTS
}
+ private boolean getActive() { //FIELD NO LONGER EXISTS
+ return false;
+ }
+
+ private void setActive(boolean IGNORED) { //FIELD NO LONGER EXISTS
+ }
+ private int getEventPort() { //FIELD NO LONGER EXISTS
+ return 0;
+ }
+
+ private void setEventPort(int IGNORED) { //FIELD NO LONGER EXISTS
+ }
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpacePersistTasks.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpacePersistTasks.java 2008-02-07 01:01:18 UTC (rev 719)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpacePersistTasks.java 2008-02-07 02:28:03 UTC (rev 720)
@@ -169,7 +169,7 @@
task.execute();
}
- private static SimRecord findSimIfActive(final SpaceRecord spaceRecord, SessionFactory sessionFactory) throws PersistException {
+ private static SimRecord findSimFromSpaceIfReachable(final SpaceRecord spaceRecord, SessionFactory sessionFactory) throws PersistException {
HibernateTask task = new HibernateTask() {
public Object run(Session hibernateSession) {
SimRecord simRecord = null;
@@ -177,10 +177,9 @@
Query simQuery = hibernateSession.getNamedQuery(SimPersistTasks.SIM_BY_ID);
simQuery.setLong("simID", spaceRecord.getSimID());
simRecord = (SimRecord) simQuery.uniqueResult();
- if (simRecord == null || simRecord.isActive() == false) {
+ if (simRecord == null || simRecord.isReachable()== false) {
spaceRecord.setSimID(-1);
updateRecordAndUpdateModifiedTime(spaceRecord, hibernateSession, true);
- simRecord = null;
return null;
} else {
return simRecord;
@@ -194,68 +193,68 @@
return (SimRecord) task.execute();
}
- private static void markInactive(SimRecord record, SessionFactory sessionFactory) throws PersistException {
- record.setActive(false);
+ private static void markNotReachable(SimRecord record, SessionFactory sessionFactory) throws PersistException {
+ record.setReachable(false);
SimPersistTasks.update(record, sessionFactory);
}
public static SimRecord findOrAssignSim(final SpaceRecord spaceRecord, SessionFactory sessionFactory) throws PersistException {
return findOrAssignSim(spaceRecord, sessionFactory, true);
}
- public static void verifyActiveSims(SimRecord[] purportedActive, SessionFactory sessionFactory) throws PersistException {
+ public static void verifyReachableSims(SimRecord[] puportedReachable, SessionFactory sessionFactory) throws PersistException {
//let's see if they are ok
- for (int i=0; i<purportedActive.length;++i) {
+ for (int i=0; i<puportedReachable.length;++i) {
try {
- URI simURI=purportedActive[i].getSimURI();
+ URI simURI=puportedReachable[i].getSimURI();
HttpURLConnection connection = (HttpURLConnection) simURI.toURL().openConnection();
connection.setRequestMethod("GET");
connection.setAllowUserInteraction(false);
+ connection.setReadTimeout(3000);
if (connection.getResponseCode()!=200) {
Log.warn("Can't get a connection to "+simURI+"! Marking inactive!");
- markInactive(purportedActive[i], sessionFactory);
+ markNotReachable(puportedReachable[i], sessionFactory);
} else {
Log.info("Verified connection to "+simURI);
}
} catch (MalformedURLException e) {
- Log.warn("Can't understand the URI "+purportedActive[i].getSimURI()+"! Marking inactive!");
- markInactive(purportedActive[i], sessionFactory);
+ Log.warn("Can't understand the URI "+puportedReachable[i].getSimURI()+"! Marking inactive!");
+ markNotReachable(puportedReachable[i], sessionFactory);
} catch (ProtocolException e) {
- Log.warn("Can't understand the URI protocol "+purportedActive[i].getSimURI()+"! Marking inactive!");
- markInactive(purportedActive[i], sessionFactory);
+ Log.warn("Can't understand the URI protocol "+puportedReachable[i].getSimURI()+"! Marking inactive!");
+ markNotReachable(puportedReachable[i], sessionFactory);
} catch (IOException e) {
- Log.warn("Can't connect to "+purportedActive[i].getSimURI()+"! Marking inactive! IOException:"+e.getMessage());
- markInactive(purportedActive[i], sessionFactory);
+ Log.warn("Can't connect to "+puportedReachable[i].getSimURI()+"! Marking inactive! IOException:"+e.getMessage());
+ markNotReachable(puportedReachable[i], sessionFactory);
}
}
}
public static SimRecord findOrAssignSim(final SpaceRecord spaceRecord, SessionFactory sessionFactory, boolean use_network) throws PersistException {
- SimRecord rec = findSimIfActive(spaceRecord, sessionFactory);
- SimRecord[] active;
+ SimRecord rec = findSimFromSpaceIfReachable(spaceRecord, sessionFactory);
if (rec!=null) {
//assume that if we have a sim ID already assigned we are ok
return rec;
}
- active=findAllActiveSims(spaceRecord, sessionFactory);
- if (active.length==0) {
- throw new PersistException("Unable to find any active sims!");
+ SimRecord[] assignable=findAllReachableAndNotRetiredSims(spaceRecord, sessionFactory);
+ if (assignable.length==0) {
+ throw new PersistException("Unable to find any sims that we can assign to!");
}
//has it been a while?
long now=System.currentTimeMillis();
if ((now-lastTestOfSimServers<TEST_SIM_INTERVAL_MS) || (!use_network)) {
- return pickSimRandomly(spaceRecord, sessionFactory, active);
+ return pickSimRandomly(spaceRecord, sessionFactory, assignable);
}
//update the time check
lastTestOfSimServers=now;
- verifyActiveSims(active,sessionFactory);
+ verifyReachableSims(findAllReachableSims(spaceRecord, sessionFactory),sessionFactory);
- active=findAllActiveSims(spaceRecord, sessionFactory);
- if (active.length==0) {
- throw new PersistException("Unable to find any active sims (after doing a check)!");
+ assignable=findAllReachableAndNotRetiredSims(spaceRecord, sessionFactory);
+ if (assignable.length==0) {
+ throw new PersistException("Unable to find any reachable sims (after doing a check)!");
}
- return pickSimRandomly(spaceRecord, sessionFactory, active);
+ return pickSimRandomly(spaceRecord, sessionFactory, assignable);
}
private static SimRecord pickSimRandomly(final SpaceRecord spaceRecord, SessionFactory sessionFactory, SimRecord[] active) throws PersistException {
@@ -267,17 +266,30 @@
return rec;
}
- private static SimRecord[] findAllActiveSims(final SpaceRecord spaceRecord, SessionFactory sessionFactory) throws PersistException {
+ private static SimRecord[] findAllReachableSims(final SpaceRecord spaceRecord, SessionFactory sessionFactory) throws PersistException {
HibernateTask task = new HibernateTask() {
public Object run(Session hibernateSession) {
- Query simsQuery = hibernateSession.getNamedQuery(SimPersistTasks.SIMS_BY_ACTIVE);
- simsQuery.setBoolean("active", true);
+ Query simsQuery = hibernateSession.getNamedQuery(SimPersistTasks.SIMS_BY_REACHABLE);
+ simsQuery.setBoolean("reachable", true);
return (SimRecord[]) simsQuery.list().toArray(new SimRecord[0]);
}
};
task.setSessionFactory(sessionFactory);
return (SimRecord[]) task.execute();
}
+
+ private static SimRecord[] findAllReachableAndNotRetiredSims(final SpaceRecord spaceRecord, SessionFactory sessionFactory) throws PersistException {
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ Query simsQuery = hibernateSession.getNamedQuery(SimPersistTasks.SIMS_BY_REACHABLE_AND_RETIRED);
+ simsQuery.setBoolean("reachable", true);
+ simsQuery.setBoolean("retired", false);
+ return (SimRecord[]) simsQuery.list().toArray(new SimRecord[0]);
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ return (SimRecord[]) task.execute();
+ }
public static SpaceRecord createSpace(final String displayName, final String ownerUsername, SessionFactory sessionFactory) throws PersistException {
HibernateTask task = new HibernateTask() {
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java 2008-02-07 01:01:18 UTC (rev 719)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java 2008-02-07 02:28:03 UTC (rev 720)
@@ -94,7 +94,7 @@
ArgumentUtils.assertNotNull(sessionFactory);
this.sessionFactory = sessionFactory;
- messageHandler = new SimMessageHandler(simRecord.getEventPort(), this, descriptor);
+ messageHandler = new SimMessageHandler(this, descriptor);
snapshotTimer.schedule(new SnapshotTask(), 300000, SNAPSHOT_FREQUENCY);
reaperTimer.schedule(new ReaperTask(), 30000, VACANCY_TIME_TILL_SHUTDOWN);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SimMessageHandler.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SimMessageHandler.java 2008-02-07 01:01:18 UTC (rev 719)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SimMessageHandler.java 2008-02-07 02:28:03 UTC (rev 720)
@@ -32,7 +32,7 @@
private Sim sim = null;
- public SimMessageHandler(int port, Sim sim, WebAPIDescriptor descriptor) throws IOException {
+ public SimMessageHandler(Sim sim, WebAPIDescriptor descriptor) throws IOException {
channelServer = new NetworkChannelServer(this, descriptor.getCometSimURI(), false, this);
this.sim = sim;
//Log.info("Started SimMessageHandler on port " + channelServer.getLocator().getPort());
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2008-02-07 01:01:18 UTC (rev 719)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2008-02-07 02:28:03 UTC (rev 720)
@@ -38,7 +38,6 @@
import com.ogoglio.client.WebAPIDescriptor;
import com.ogoglio.media.MediaService;
import com.ogoglio.persist.AccountRecord;
-import com.ogoglio.persist.PossessionPersistTasks;
import com.ogoglio.persist.ServiceInitializationPersistTasks;
import com.ogoglio.persist.SimPersistTasks;
import com.ogoglio.persist.SimRecord;
@@ -58,7 +57,6 @@
import com.ogoglio.xml.PageDocument;
import com.ogoglio.xml.SettingDocument;
import com.ogoglio.xml.SpaceDocument;
-import com.ogoglio.xml.SpaceMemberDocument;
import com.ogoglio.xml.SpaceSimulatorDocument;
import com.ogoglio.xml.TemplateDocument;
import com.ogoglio.xml.ThingDocument;
@@ -104,12 +102,13 @@
SimRecord simRecord = SimPersistTasks.findSimsBySimURI(simURI, getSessionFactory());
if (simRecord != null) {
//error
- Log.warn("Marking sim server active @ " + simRecord.getSimURI() + " [it was already in the database]! Ignored.");
- simRecord.setActive(true);
+ Log.warn("Marking sim server as ready @ " + simRecord.getSimURI() + " [it was already in the database]! Ignored.");
+ simRecord.setReachable(true);
+ simRecord.setRetired(false);
SimPersistTasks.update(simRecord, getSessionFactory());
} else {
Log.info("Starting up sim @ " + simURI);
- simRecord = SimPersistTasks.createSim(ServiceInitializationPersistTasks.LOCAL_SIM_DISPLAY_NAME, simURI, SimRecord.DEFAULT_EVENT_PORT, true, getSessionFactory());
+ simRecord = SimPersistTasks.createSim(simURI, true, false, getSessionFactory());
}
WebAPIDescriptor descriptor;
String serviceURI = (String) envCtx.lookup("ogoglio/baseURL");
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java 2008-02-07 01:01:18 UTC (rev 719)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java 2008-02-07 02:28:03 UTC (rev 720)
@@ -611,7 +611,7 @@
for (int i = 0; i < simRecord.length; ++i) {
SimRecord sim = simRecord[i];
try {
- buffer.append("Sim Server:" + sim.getDisplayName() + " [" + sim.getSimID() + "] " + sim.getSimURI() + "\n");
+ buffer.append("Sim Server: [" + sim.getSimID() + "] " + sim.getSimURI() + "\n");
buffer.append("===============================================\n");
if (!isOnLocalhost(sim)) {
String hackedURI=dodgyConversionOfSimURI(sim.getSimURI().toString());
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/xml/server/DocumentFactory.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/xml/server/DocumentFactory.java 2008-02-07 01:01:18 UTC (rev 719)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/xml/server/DocumentFactory.java 2008-02-07 02:28:03 UTC (rev 720)
@@ -32,7 +32,7 @@
}
public static SimDocument documentFromRecord(SimRecord record) {
- return new SimDocument(record.getSimID(), record.getSimURI(), record.getDisplayName(), record.isActive());
+ return new SimDocument(record.getSimID(), record.getSimURI(), record.isReachable(), record.isRetired());
}
public static SpaceDocument documentFromRecord(SpaceRecord requestedRecord) {
Added: maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-3.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-3.xml (rev 0)
+++ maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-3.xml 2008-02-07 02:28:03 UTC (rev 720)
@@ -0,0 +1,337 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+ Copyright 2007,2008 Transmutable (http://transmutable.com/)
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+-->
+
+<hibernate-mapping>
+
+ <class name="com.ogoglio.persist.ServiceStateRecord"
+ table="ServiceStateRecords">
+ <id name="serviceStateID">
+ <generator class="identity" />
+ </id>
+ <property name="registrationState" not-...
[truncated message content] |
|
From: <ian...@us...> - 2008-02-08 20:27:03
|
Revision: 729
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=729&view=rev
Author: iansmith
Date: 2008-02-08 12:27:01 -0800 (Fri, 08 Feb 2008)
Log Message:
-----------
Added support for messing with SimRecords/SimDocuments via the API. You can now programmatically set sims to not reachable or retired.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIDescriptor.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SimDocument.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/WebAPITest.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimPersistTasks.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2008-02-08 18:28:09 UTC (rev 728)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2008-02-08 20:27:01 UTC (rev 729)
@@ -37,6 +37,7 @@
import com.ogoglio.xml.PossessionDocument;
import com.ogoglio.xml.ServiceStateDocument;
import com.ogoglio.xml.SettingDocument;
+import com.ogoglio.xml.SimDocument;
import com.ogoglio.xml.SpaceDocument;
import com.ogoglio.xml.SpaceMemberDocument;
import com.ogoglio.xml.TemplateDocument;
@@ -475,6 +476,19 @@
return results;
}
+ public SimDocument[] getSimDocuments() throws IOException {
+ XMLElement elem=wire.fetchAuthenticatedXML(descriptor.getSpaceSimURI(), authenticator.getAuthCookie());
+ if (!elem.getName().toLowerCase().equals("list")) {
+ throw new IOException("Unable to parse the list of sim documents!"+elem);
+ }
+ XMLElement[] children=elem.getChildren("sim");
+ SimDocument[] result=new SimDocument[children.length];
+ for (int i=0; i<result.length;++i) {
+ result[i]=new SimDocument(children[i]);
+ }
+ return result;
+ }
+
public String getSpaceSetting(long spaceID, String key) {
try {
InputStream stream = wire.performGET(descriptor.getSettingURI(spaceID, key), authenticator.getAuthCookie(), false);
@@ -607,4 +621,41 @@
public void deleteBodyTexture(String username, long bodyConfigurationID) throws IOException {
wire.sendDelete(descriptor.getBodyTextureURI(username, bodyConfigurationID), authenticator.getAuthCookie());
}
+
+ public SimDocument getSimDocument(long simID) throws IOException {
+ XMLElement elem=wire.fetchAuthenticatedXML(descriptor.getSpaceSimURI(simID), authenticator.getAuthCookie());
+ return new SimDocument(elem);
+ }
+
+ public void setSimRetired(long simID, boolean b) throws IOException {
+ SimDocument doc=getSimDocument(simID); //b/c we don't actually know what state it's in
+ if (doc.isRetired()==b) {
+ return;
+ }
+ doc.setRetired(b);
+ SimDocument after=putAndReturnSimDocResult(simID, doc);
+ if (after==null || (!after.isRetired()==b)) {
+ throw new IOException("Unable to understand result of PUT to "+descriptor.getSpaceSimURI(simID));
+ }
+ }
+
+ public SimDocument putAndReturnSimDocResult(long simID, SimDocument doc) throws IOException {
+ InputStream str=wire.performPUT(descriptor.getSpaceSimURI(simID), doc.toString(), "text/xml", authenticator.getAuthCookie());
+ String result=StreamUtils.readInput(str);
+ //so we can test that something sensible happened
+ XMLElement root=XMLElement.parseElementFromString(result);
+ return new SimDocument(root);
+ }
+
+ public void setSimReachable(long simID, boolean b) throws IOException {
+ SimDocument doc=getSimDocument(simID); //b/c we don't actually know what state it's in
+ if (doc.isReachable()==b) {
+ return;
+ }
+ doc.setReachable(b);
+ SimDocument after=putAndReturnSimDocResult(simID, doc);
+ if (after==null || (!after.isReachable()==b)) {
+ throw new IOException("Unable to understand result of PUT to "+descriptor.getSpaceSimURI(simID));
+ }
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java 2008-02-08 18:28:09 UTC (rev 728)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java 2008-02-08 20:27:01 UTC (rev 729)
@@ -6,6 +6,8 @@
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.ProtocolException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
@@ -38,11 +40,7 @@
}
StreamUtils.write(input, connection.getOutputStream());
- if (connection.getResponseCode() != 200) {
- throw new IOException("Get status " + connection.getResponseCode() + " from " + uri);
- }
-
- return connection.getInputStream();
+ return checkResponseCodeAndReturnStream(uri, connection);
}
public InputStream performPOST(URI uri, InputStream body, String type, String authCookie) throws IOException {
@@ -63,11 +61,7 @@
StreamUtils.write(body, rawOutStream);
}
- if (connection.getResponseCode() != 200) {
- throw new IOException("Get status " + connection.getResponseCode() + " from " + uri);
- }
-
- return connection.getInputStream();
+ return checkResponseCodeAndReturnStream(uri, connection);
}
public InputStream performPOST(URI uri, String body, String type, String authCookie) throws IOException {
@@ -90,11 +84,7 @@
pw.close();
}
- if (connection.getResponseCode() != 200) {
- throw new IOException("Get status " + connection.getResponseCode() + " from " + uri);
- }
-
- return connection.getInputStream();
+ return checkResponseCodeAndReturnStream(uri, connection);
}
public XMLElement sendAuthenticatedXML(URI uri, String body, String method, String authCookie) throws IOException {
@@ -189,6 +179,25 @@
}
public InputStream performPUT(URI uri, InputStream input, String type, long length, String authCookie) throws IOException {
+ HttpURLConnection connection = prepPutConnection(uri, type, length, authCookie);
+ StreamUtils.write(input, connection.getOutputStream());
+ return checkResponseCodeAndReturnStream(uri, connection);
+ }
+
+ private InputStream checkResponseCodeAndReturnStream(URI uri, HttpURLConnection connection) throws IOException {
+ if (connection.getResponseCode() != 200) {
+ throw new IOException("Get status " + connection.getResponseCode() + " from " + uri);
+ }
+
+ return connection.getInputStream();
+ }
+ public InputStream performPUT(URI uri, String data, String type, String authCookie) throws IOException {
+ HttpURLConnection connection=prepPutConnection(uri, type, data.length(), authCookie);
+ StreamUtils.write(data, connection.getOutputStream());
+ return checkResponseCodeAndReturnStream(uri, connection);
+ }
+
+ private HttpURLConnection prepPutConnection(URI uri, String type, long length, String authCookie) throws IOException, MalformedURLException, ProtocolException {
HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
connection.setRequestMethod("PUT");
connection.setAllowUserInteraction(false);
@@ -201,13 +210,7 @@
if (length >= 0) {
connection.setRequestProperty("Content-length", Long.toString(length));
}
- StreamUtils.write(input, connection.getOutputStream());
-
- if (connection.getResponseCode() != 200) {
- throw new IOException("Get status " + connection.getResponseCode() + " from " + uri);
- }
-
- return connection.getInputStream();
+ return connection;
}
public InputStream fetchAuthenticatedStream(URI uri, String authCookie) throws IOException {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIDescriptor.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIDescriptor.java 2008-02-08 18:28:09 UTC (rev 728)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIDescriptor.java 2008-02-08 20:27:01 UTC (rev 729)
@@ -21,6 +21,14 @@
return WebAPIUtil.appendToURI(serviceURI, "space/");
}
+ public URI getSpaceSimURI() {
+ return WebAPIUtil.appendToURI(getSpacesURI(), "sim/");
+ }
+
+ public URI getSpaceSimURI(long id) {
+ return WebAPIUtil.appendToURI(getSpacesURI(), "sim/"+id);
+ }
+
public URI getSpaceURI(long spaceID) {
return WebAPIUtil.appendToURI(serviceURI, "space/" + spaceID);
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SimDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SimDocument.java 2008-02-08 18:28:09 UTC (rev 728)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SimDocument.java 2008-02-08 20:27:01 UTC (rev 729)
@@ -80,10 +80,15 @@
public boolean isReachable() {
return data.getBooleanAttribute(REACHABLE, false);
}
-
+ public void setReachable(boolean b) {
+ data.setAttribute(REACHABLE, b);
+ }
public boolean isRetired() {
return data.getBooleanAttribute(RETIRED, false);
}
+ public void setRetired(boolean b) {
+ data.setAttribute(RETIRED, b);
+ }
public URI getSimURI() {
String uri = data.getStringAttribute(SIM_URI);
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-08 18:28:09 UTC (rev 728)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-08 20:27:01 UTC (rev 729)
@@ -72,6 +72,7 @@
import com.ogoglio.xml.PossessionDocument;
import com.ogoglio.xml.ServiceStateDocument;
import com.ogoglio.xml.ShapeDocument;
+import com.ogoglio.xml.SimDocument;
import com.ogoglio.xml.SpaceDocument;
import com.ogoglio.xml.SpaceMemberDocument;
import com.ogoglio.xml.TemplateDocument;
@@ -172,16 +173,7 @@
}
public void testWebAdmin() throws AuthenticationFailedException, IOException {
- PropStorage ps = new PropStorage();
- if (ps.loadPropertySet(PropStorage.BOOTSTRAP_PROPS) == false) {
- fail("unable to load properties bootstrap.properties!");
- }
-
- WebAPIAuthenticator adminAuthenticator = new WebAPIAuthenticatorFactory().authenticate(wire1, descriptor1, ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUser"), ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUserPW"));
-
- assertNotNull("got null auth cookie", adminAuthenticator.getAuthCookie());
-
- WebAPIClient adminWebClient = new WebAPIClient(descriptor1, adminAuthenticator, wire1);
+ WebAPIClient adminWebClient = createAdminWebClient();
adminWebClient.createAccount(USERNAME1, AccountDocument.ACCOUNT_LEVEL_ADVANCED, "Susan", "Advanced", "http://example.com/susan/", "su...@ex...", PASSWORD1);
adminWebClient.createAccount(USERNAME2, AccountDocument.ACCOUNT_LEVEL_BASIC, "Tina", "Basic", "http://example.com/tina/", "ti...@ex...", PASSWORD1);
@@ -295,6 +287,20 @@
assertNull(basicWebClient.getBodyTexture(basicAuthenticator.getUsername(), configDoc.getBodyConfigurationID()));
}
+ private WebAPIClient createAdminWebClient() throws AuthenticationFailedException, IOException {
+ PropStorage ps = new PropStorage();
+ if (ps.loadPropertySet(PropStorage.BOOTSTRAP_PROPS) == false) {
+ fail("unable to load properties bootstrap.properties!");
+ }
+
+ WebAPIAuthenticator adminAuthenticator = new WebAPIAuthenticatorFactory().authenticate(wire1, descriptor1, ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUser"), ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUserPW"));
+
+ assertNotNull("got null auth cookie", adminAuthenticator.getAuthCookie());
+
+ WebAPIClient adminWebClient = new WebAPIClient(descriptor1, adminAuthenticator, wire1);
+ return adminWebClient;
+ }
+
private String getLastEmailValidationURL(String email) throws IOException {
File[] mailFiles = mailDirectory.listFiles(new FilenameFilter() {
@@ -411,6 +417,28 @@
}
+ public void testSimDocumentAndRetirement() throws AuthenticationFailedException, IOException {
+ WebAPIClient adminWebClient = createAdminWebClient();
+ SimDocument[] sims=adminWebClient.getSimDocuments();
+ assertNotNull(sims);
+ assertEquals(1,sims.length);
+
+ SimDocument simDoc= adminWebClient.getSimDocument(sims[0].getSimID());
+ boolean origRetired=simDoc.isRetired();
+ boolean origReachable = simDoc.isReachable();
+ adminWebClient.setSimRetired(simDoc.getSimID(),!origRetired);
+ simDoc=adminWebClient.getSimDocument(sims[0].getSimID());
+ assertEquals(simDoc.isRetired(),!origRetired);
+ adminWebClient.setSimReachable(simDoc.getSimID(),!origReachable);
+ simDoc=adminWebClient.getSimDocument(sims[0].getSimID());
+ assertEquals(simDoc.isReachable(),!origReachable);
+
+ //put back in right state
+ adminWebClient.setSimReachable(sims[0].getSimID(), true);
+ adminWebClient.setSimRetired(sims[0].getSimID(), false);
+ }
+
+
private void checkAttachments(SpaceDocument spaceDocument, ThingDocument[] thingDocs, SpaceClient spaceClient, WebAPIClient advancedClient) throws IOException {
TemplateDocument templateDoc = advancedClient.createTemplate("Attachment Test");
assertNotNull(templateDoc);
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/WebAPITest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/WebAPITest.java 2008-02-08 18:28:09 UTC (rev 728)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/WebAPITest.java 2008-02-08 20:27:01 UTC (rev 729)
@@ -56,7 +56,6 @@
public void tearDown() {
}
-
public void testWebAPIGuestAuthenticator() {
mockAuthFactory.authenticate(descriptor, GUEST_COOKIE);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimPersistTasks.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimPersistTasks.java 2008-02-08 18:28:09 UTC (rev 728)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimPersistTasks.java 2008-02-08 20:27:01 UTC (rev 729)
@@ -21,6 +21,7 @@
import com.ogoglio.appdev.persist.HibernateTask;
import com.ogoglio.appdev.persist.PersistException;
+import com.ogoglio.xml.SimDocument;
public class SimPersistTasks {
@@ -79,6 +80,39 @@
task.setSessionFactory(sessionFactory);
task.execute();
}
+
+ public static SimRecord updateSim(final long simID, final SimDocument doc, SessionFactory sessionFactory) throws PersistException {
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ Query query = hibernateSession.getNamedQuery(SIM_BY_ID);
+ query.setLong("simID", simID);
+ SimRecord record = (SimRecord) query.uniqueResult();
+ if (record == null) {
+ return null;
+ }
+ //you can't move sims around
+ if (doc.getSimURI()!= null && !doc.getSimURI().equals(record.getSimURI())) {
+ return null;
+ }
+ boolean dirty=false, reachable=record.isReachable(), retired=record.isRetired();
+ if (doc.isReachable()!=reachable) {
+ dirty=true;
+ record.setReachable(doc.isReachable());
+ }
+ if (doc.isRetired()!=retired) {
+ dirty=true;
+ record.setRetired(doc.isRetired());
+ }
+ if (dirty) {
+ hibernateSession.update(record);
+ }
+ return record;
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ return (SimRecord) task.execute();
+ }
+
public static void delete(final SimRecord simRecord, SessionFactory sessionFactory) throws PersistException {
HibernateTask task = new HibernateTask() {
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2008-02-08 18:28:09 UTC (rev 728)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2008-02-08 20:27:01 UTC (rev 729)
@@ -102,7 +102,7 @@
private class BaseSpaceResource extends AuthenticatedSiteResource {
public BaseSpaceResource() {
super("space", false, getSessionFactory());
- addSubResource(new SimResource());
+ addSubResource(new BaseSimResource());
addSubResource(new StateResource());
addSubResource(new SpaceResource());
addSubResource(new BodiesResource());
@@ -796,14 +796,64 @@
sendStringResponse(result.toString(), "text/xml", response);
}
}
-
private class SimResource extends AuthenticatedSiteResource {
+ public SimResource() {
+ super(SiteResource.LONG_ELEMENT, true, getSessionFactory());
+ }
+ public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
+ if (!isUserAnAdmin(response, authedAccount)) {
+ return; //is SC_FORBIDDEN
+ }
+
+ long simID = Long.parseLong(pathElements[pathElements.length - 1]);
+ SimRecord simRecord= SimPersistTasks.findSimByID(simID, getSessionFactory());
+ if (simRecord == null) {
+ response.setStatus(HttpServletResponse.SC_NOT_FOUND);
+ return;
+ }
+ SimDocument doc=DocumentFactory.documentFromRecord(simRecord);
+ sendStringResponse(doc.toString(), "text/xml", response);
+ return;
+ }
+ public void doPut(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
+ long simID = Long.parseLong(pathElements[pathElements.length - 1]);
+ SimRecord simRec = SimPersistTasks.findSimByID(simID, getSessionFactory());
+ if (simRec== null) {
+ response.setStatus(HttpServletResponse.SC_NOT_FOUND);
+ return;
+ }
+
+ if (!isUserAnAdmin(response, authedAccount)) {
+ return; //is SC_FORBIDDEN
+ }
- public SimResource() {
+ SimDocument simDoc= new SimDocument(parseXML(request.getInputStream()));
+ simRec = SimPersistTasks.updateSim(simID, simDoc, sessionFactory);
+ if (simRec== null) {
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ return;
+ }
+ sendStringResponse(DocumentFactory.documentFromRecord(simRec).toString(), "text/xml", response);
+
+ }
+ private boolean isUserAnAdmin(HttpServletResponse response, AccountRecord authedAccount) {
+ //check for null is superfluous?
+ if (authedAccount == null || !AccountDocument.ACCOUNT_LEVEL_ADMIN.equals(authedAccount.getAccountlevel())) {
+ response.setStatus(HttpServletResponse.SC_FORBIDDEN);
+ return false;
+ }
+ return true;
+ }
+ }
+ private class BaseSimResource extends AuthenticatedSiteResource {
+
+ public BaseSimResource() {
super("sim", true, getSessionFactory());
+ addSubResource(new SimResource());
}
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
+ //check for null is superfluous?
if (authedAccount == null || !AccountDocument.ACCOUNT_LEVEL_ADMIN.equals(authedAccount.getAccountlevel())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2008-02-10 21:55:38
|
Revision: 732
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=732&view=rev
Author: iansmith
Date: 2008-02-10 13:55:34 -0800 (Sun, 10 Feb 2008)
Log Message:
-----------
Added support for getting the list of sims (SimDocuments) or a particular sim.
Added new fields "retired" and "reachable" that more properly indicate what state a sim can be in.
Added tests for most of the API, but not for deleteSim() b/c there is no way to recover the sim at this point and then the rest of the tests would break.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIDescriptor.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2008-02-09 15:31:27 UTC (rev 731)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2008-02-10 21:55:34 UTC (rev 732)
@@ -476,8 +476,8 @@
return results;
}
- public SimDocument[] getSimDocuments() throws IOException {
- XMLElement elem=wire.fetchAuthenticatedXML(descriptor.getSpaceSimURI(), authenticator.getAuthCookie());
+ public SimDocument[] getSimDocuments(boolean serversOnly) throws IOException {
+ XMLElement elem=wire.fetchAuthenticatedXML(descriptor.getSpaceSimURI(serversOnly), authenticator.getAuthCookie());
if (!elem.getName().toLowerCase().equals("list")) {
throw new IOException("Unable to parse the list of sim documents!"+elem);
}
@@ -658,4 +658,8 @@
throw new IOException("Unable to understand result of PUT to "+descriptor.getSpaceSimURI(simID));
}
}
+
+ public boolean deleteSim(long simID) throws IOException {
+ return wire.sendDelete(descriptor.getSpaceSimURI(simID), authenticator.getAuthCookie());
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java 2008-02-09 15:31:27 UTC (rev 731)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java 2008-02-10 21:55:34 UTC (rev 732)
@@ -25,8 +25,17 @@
private static final String BAD_SUN_VERSION = "1.6"; //don't add a semicolon on the end of this, as we want to match all 1.6x jvms
+ private int connectTimeout=0;
+ private int readTimeout=0;
+
+ private HttpURLConnection openURIWithTimeouts(URI uri) throws IOException {
+ HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
+ connection.setConnectTimeout(connectTimeout);
+ connection.setReadTimeout(readTimeout);
+ return connection;
+ }
public InputStream performPUT(URI uri, InputStream input, String type, int length, String authCookie) throws IOException {
- HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
+ HttpURLConnection connection = openURIWithTimeouts(uri);
connection.setRequestMethod("PUT");
connection.setAllowUserInteraction(false);
if (authCookie != null) {
@@ -44,7 +53,7 @@
}
public InputStream performPOST(URI uri, InputStream body, String type, String authCookie) throws IOException {
- HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
+ HttpURLConnection connection = openURIWithTimeouts(uri);
connection.setRequestMethod("POST");
connection.setAllowUserInteraction(false);
if (authCookie != null) {
@@ -65,7 +74,7 @@
}
public InputStream performPOST(URI uri, String body, String type, String authCookie) throws IOException {
- HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
+ HttpURLConnection connection = openURIWithTimeouts(uri);
connection.setRequestMethod("POST");
connection.setAllowUserInteraction(false);
if (authCookie != null) {
@@ -88,7 +97,7 @@
}
public XMLElement sendAuthenticatedXML(URI uri, String body, String method, String authCookie) throws IOException {
- HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
+ HttpURLConnection connection = openURIWithTimeouts(uri);
connection.setRequestMethod(method);
connection.setAllowUserInteraction(false);
if (authCookie != null) {
@@ -118,7 +127,7 @@
}
public boolean sendDelete(URI uri, String authCookie) throws IOException {
- HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
+ HttpURLConnection connection = openURIWithTimeouts(uri);
connection.setRequestMethod("DELETE");
connection.setAllowUserInteraction(false);
if (authCookie != null) {
@@ -154,7 +163,7 @@
}
}
- HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
+ HttpURLConnection connection = openURIWithTimeouts(uri);
connection.setRequestMethod("GET");
connection.setAllowUserInteraction(false);
if (authCookie != null) {
@@ -198,7 +207,7 @@
}
private HttpURLConnection prepPutConnection(URI uri, String type, long length, String authCookie) throws IOException, MalformedURLException, ProtocolException {
- HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
+ HttpURLConnection connection = openURIWithTimeouts(uri);
connection.setRequestMethod("PUT");
connection.setAllowUserInteraction(false);
if (authCookie != null) {
@@ -238,7 +247,7 @@
}
}
- HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
+ HttpURLConnection connection = openURIWithTimeouts(uri);
connection.setRequestMethod("GET");
connection.setAllowUserInteraction(false);
if (authCookie != null) {
@@ -270,7 +279,7 @@
public long getHeadDate(URI uri, String authCookie, String headerName) {
try {
- HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
+ HttpURLConnection connection = openURIWithTimeouts(uri);
connection.setRequestMethod("HEAD");
connection.setAllowUserInteraction(false);
if (authCookie != null) {
@@ -288,7 +297,7 @@
public String getHeadValue(URI uri, String authCookie, String headerName) {
try {
- HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
+ HttpURLConnection connection = openURIWithTimeouts(uri);
connection.setRequestMethod("HEAD");
connection.setAllowUserInteraction(false);
if (authCookie != null) {
@@ -323,7 +332,7 @@
}
public String getAuthCookieViaPost(URI uri, String body, String type) throws IOException {
- HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
+ HttpURLConnection connection = openURIWithTimeouts(uri);
connection.setRequestMethod("POST");
connection.setAllowUserInteraction(false);
connection.setDoOutput(true);
@@ -340,4 +349,11 @@
data.parseFromReader(new InputStreamReader(connection.getInputStream()));
return cookie;
}
+
+ public void setConnectTimeout(int millis) {
+ connectTimeout=millis;
+ }
+ public void setReadTimeout(int millis) {
+ readTimeout=millis;
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIDescriptor.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIDescriptor.java 2008-02-09 15:31:27 UTC (rev 731)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIDescriptor.java 2008-02-10 21:55:34 UTC (rev 732)
@@ -3,8 +3,6 @@
import java.io.IOException;
import java.net.URI;
-import com.ogoglio.message.proto.AsyncProto;
-import com.ogoglio.message.proto.AsyncProtoFactory;
import com.ogoglio.util.ArgumentUtils;
import com.ogoglio.util.WebConstants;
@@ -21,8 +19,13 @@
return WebAPIUtil.appendToURI(serviceURI, "space/");
}
- public URI getSpaceSimURI() {
- return WebAPIUtil.appendToURI(getSpacesURI(), "sim/");
+ public URI getSpaceSimURI(boolean serversOnly) {
+ String suffix="sim/";
+ if (serversOnly) {
+ suffix=suffix+"?serversOnly=true";
+ }
+ return WebAPIUtil.appendToURI(getSpacesURI(), suffix);
+
}
public URI getSpaceSimURI(long id) {
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-09 15:31:27 UTC (rev 731)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-10 21:55:34 UTC (rev 732)
@@ -419,7 +419,9 @@
public void testSimDocumentAndRetirement() throws AuthenticationFailedException, IOException {
WebAPIClient adminWebClient = createAdminWebClient();
- SimDocument[] sims=adminWebClient.getSimDocuments();
+ WebAPIClient stdWebClient = createStandardWebClient();
+
+ SimDocument[] sims=adminWebClient.getSimDocuments(false);
assertNotNull(sims);
assertEquals(1,sims.length);
@@ -433,12 +435,22 @@
simDoc=adminWebClient.getSimDocument(sims[0].getSimID());
assertEquals(simDoc.isReachable(),!origReachable);
+ //check perms and but don't actually do deletion
+ assertFalse(stdWebClient.deleteSim(simDoc.getSimID()));
+
//put back in right state
adminWebClient.setSimReachable(sims[0].getSimID(), true);
adminWebClient.setSimRetired(sims[0].getSimID(), false);
}
+ private WebAPIClient createStandardWebClient() throws IOException, AuthenticationFailedException {
+ WebAPIAuthenticator basicAuthenticator = new WebAPIAuthenticatorFactory().authenticate(wire1, descriptor1, USERNAME1, PASSWORD1);
+ assertNotNull("got null auth cookie", basicAuthenticator.getAuthCookie());
+ WebAPIClient basicWebClient = new WebAPIClient(descriptor1, basicAuthenticator, wire1);
+ return basicWebClient;
+ }
+
private void checkAttachments(SpaceDocument spaceDocument, ThingDocument[] thingDocs, SpaceClient spaceClient, WebAPIClient advancedClient) throws IOException {
TemplateDocument templateDoc = advancedClient.createTemplate("Attachment Test");
assertNotNull(templateDoc);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2008-02-09 15:31:27 UTC (rev 731)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2008-02-10 21:55:34 UTC (rev 732)
@@ -55,7 +55,7 @@
import com.ogoglio.xml.SpaceSimulatorDocument;
import com.ogoglio.xml.server.DocumentFactory;
-public class SpaceServlet extends WebappServletBase{
+public class SpaceServlet extends WebappServletBase {
public static final String MESSAGE_PROXY_KEY = "spaceMessageProxy";
@@ -68,7 +68,7 @@
try {
//don't bother running a proxy with no space resources!
if (servletNeeded) {
- messageProxy = new MessageProxy(getSessionFactory(),new WebAPIDescriptor(new URI(baseUrl)));
+ messageProxy = new MessageProxy(getSessionFactory(), new WebAPIDescriptor(new URI(baseUrl)));
config.getServletContext().setAttribute(MESSAGE_PROXY_KEY, messageProxy);
}
} catch (URISyntaxException e) {
@@ -109,9 +109,9 @@
}
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
- String localAddr=request.getLocalAddr();
- if (preferredIPAddr!=null) {
- localAddr=preferredIPAddr;
+ String localAddr = request.getLocalAddr();
+ if (preferredIPAddr != null) {
+ localAddr = preferredIPAddr;
}
ServiceDocument serviceDocument = new ServiceDocument(messageProxy.getUserCount(), messageProxy.getSimCount(), localAddr);
sendStringResponse(serviceDocument.toString(), "text/xml", response);
@@ -188,7 +188,7 @@
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord accountRecord) throws PersistException, IOException {
long bodyDataID = Long.parseLong(pathElements[pathElements.length - 1]);
BodyDataRecord bodyDataRecord = BodyPersistTasks.findBodyDataByID(bodyDataID, getSessionFactory());
- if(bodyDataRecord == null){
+ if (bodyDataRecord == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
@@ -198,12 +198,12 @@
public void doDelete(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord accountRecord) throws PersistException, IOException {
long bodyDataID = Long.parseLong(pathElements[pathElements.length - 1]);
BodyDataRecord bodyDataRecord = BodyPersistTasks.findBodyDataByID(bodyDataID, getSessionFactory());
- if(bodyDataRecord == null){
+ if (bodyDataRecord == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
-
- if(accountRecord == null || !AccountDocument.ACCOUNT_LEVEL_ADMIN.equals(accountRecord.getAccountlevel())){
+
+ if (accountRecord == null || !AccountDocument.ACCOUNT_LEVEL_ADMIN.equals(accountRecord.getAccountlevel())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -796,46 +796,66 @@
sendStringResponse(result.toString(), "text/xml", response);
}
}
+
private class SimResource extends AuthenticatedSiteResource {
public SimResource() {
super(SiteResource.LONG_ELEMENT, true, getSessionFactory());
}
+
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
if (!isUserAnAdmin(response, authedAccount)) {
return; //is SC_FORBIDDEN
}
-
+
long simID = Long.parseLong(pathElements[pathElements.length - 1]);
- SimRecord simRecord= SimPersistTasks.findSimByID(simID, getSessionFactory());
+ SimRecord simRecord = SimPersistTasks.findSimByID(simID, getSessionFactory());
if (simRecord == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
- SimDocument doc=DocumentFactory.documentFromRecord(simRecord);
+ SimDocument doc = DocumentFactory.documentFromRecord(simRecord);
sendStringResponse(doc.toString(), "text/xml", response);
return;
}
+
public void doPut(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
long simID = Long.parseLong(pathElements[pathElements.length - 1]);
SimRecord simRec = SimPersistTasks.findSimByID(simID, getSessionFactory());
- if (simRec== null) {
+ if (simRec == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
-
+
if (!isUserAnAdmin(response, authedAccount)) {
return; //is SC_FORBIDDEN
}
- SimDocument simDoc= new SimDocument(parseXML(request.getInputStream()));
+ SimDocument simDoc = new SimDocument(parseXML(request.getInputStream()));
simRec = SimPersistTasks.updateSim(simID, simDoc, sessionFactory);
- if (simRec== null) {
+ if (simRec == null) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return;
}
sendStringResponse(DocumentFactory.documentFromRecord(simRec).toString(), "text/xml", response);
-
+
}
+
+ public void doDelete(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
+ long simID = Long.parseLong(pathElements[pathElements.length - 1]);
+ SimRecord simRec = SimPersistTasks.findSimByID(simID, getSessionFactory());
+ if (simRec == null) {
+ response.setStatus(HttpServletResponse.SC_NOT_FOUND);
+ return;
+ }
+
+ if (!isUserAnAdmin(response, authedAccount)) {
+ return; //is SC_FORBIDDEN
+ }
+
+ SimPersistTasks.delete(simRec, sessionFactory);
+ response.setStatus(HttpServletResponse.SC_OK);
+ }
+
private boolean isUserAnAdmin(HttpServletResponse response, AccountRecord authedAccount) {
//check for null is superfluous?
if (authedAccount == null || !AccountDocument.ACCOUNT_LEVEL_ADMIN.equals(authedAccount.getAccountlevel())) {
@@ -845,7 +865,9 @@
return true;
}
}
+
private class BaseSimResource extends AuthenticatedSiteResource {
+ public static final String ONLY_SERVERS = "onlyServers";
public BaseSimResource() {
super("sim", true, getSessionFactory());
@@ -853,34 +875,51 @@
}
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
+ boolean onlyServers = false;
+
//check for null is superfluous?
if (authedAccount == null || !AccountDocument.ACCOUNT_LEVEL_ADMIN.equals(authedAccount.getAccountlevel())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
+ if ("true".equalsIgnoreCase(request.getParameter(ONLY_SERVERS))) {
+ onlyServers = true;
+ }
+
SimRecord[] simRecs = SimPersistTasks.findSims(getSessionFactory());
-
+ Log.debug("Found a list of sims in BaseSimResource, length is " + simRecs.length);
XMLElement list = new XMLElement("list");
for (int i = 0; i < simRecs.length; i++) {
SimDocument simDoc = DocumentFactory.documentFromRecord(simRecs[i]);
- try {
- URI uri = new URI(simDoc.getSimURI().toString() + "space/");
- XMLElement spaceList = new WebAPIClientWire().fetchAuthenticatedXML(uri, null);
- if (spaceList != null) {
- XMLElement[] spaceElements = spaceList.getChildren(SpaceSimulatorDocument.NAME);
- if (spaceElements != null) {
- for (int j = 0; j < spaceElements.length; j++) {
- simDoc.addSpaceSimulatorDocument(new SpaceSimulatorDocument(spaceElements[j]));
+ if ((simDoc.isReachable()) && (!onlyServers)) {
+ try {
+ URI uri = new URI(simDoc.getSimURI().toString() + "space/");
+ Log.debug("About to poll " + uri + " to see about it's space list...");
+ WebAPIClientWire wire = new WebAPIClientWire();
+ wire.setConnectTimeout(2000);
+ wire.setReadTimeout(2000);
+ XMLElement spaceList = wire.fetchAuthenticatedXML(uri, null);
+ if (spaceList != null) {
+ XMLElement[] spaceElements = spaceList.getChildren(SpaceSimulatorDocument.NAME);
+ if (spaceElements != null) {
+ for (int j = 0; j < spaceElements.length; j++) {
+ simDoc.addSpaceSimulatorDocument(new SpaceSimulatorDocument(spaceElements[j]));
+ }
+ } else {
+ Log.error("Got null spaceList: " + uri);
}
}
- } else {
- Log.error("Got null spaceList: " + uri);
+
+ } catch (IOException e) {
+ //probably due to a timeout
+ SimRecord rec = SimPersistTasks.findSimByID(simDoc.getSimID(), getSessionFactory());
+ rec.setReachable(false);
+ SimPersistTasks.update(rec, getSessionFactory());
+ } catch (Exception e) {
+ Log.error("Error trying to reach a sim to get it's list of spaces/users!", e);
}
- } catch (Exception e) {
- e.printStackTrace();
}
-
list.addChild(simDoc.toElement());
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java 2008-02-09 15:31:27 UTC (rev 731)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java 2008-02-10 21:55:34 UTC (rev 732)
@@ -196,17 +196,17 @@
}
if (request.getParameter("brief")!=null) {
- StatusData sd=computeCurrentStatus();
- addSpaceInfo(sd);
+ StatusData sd=computeCurrentStatus(false);
+ //addSpaceInfo(sd);
StringBuffer buffer=new StringBuffer();
- buffer.append(""+sd.load_1min+","+sd.simCount+","+sd.userCount);
+ buffer.append(""+sd.load_1min);
sendStringResponse(buffer.toString(), "text/plain", response);
response.setStatus(HttpServletResponse.SC_OK);
return;
}
try {
- StatusData data = computeCurrentStatus();
+ StatusData data = computeCurrentStatus(true);
List copy = new ArrayList();
addCurrentStatusToListAndCopy(data, copy);
@@ -240,11 +240,14 @@
}
}
- private StatusData computeCurrentStatus() throws IOException {
+ private StatusData computeCurrentStatus(boolean includeAll) throws IOException {
StatusData data = new StatusData();
+ getLoadAvg(data);
+ if (!includeAll) {
+ return data;
+ }
data.timestamp = System.currentTimeMillis();
- getLoadAvg(data);
getMemoryInfo(data);
getDiskAvailable(data);
getNetworkInfo(data);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2008-02-12 00:15:31
|
Revision: 733
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=733&view=rev
Author: iansmith
Date: 2008-02-11 16:15:34 -0800 (Mon, 11 Feb 2008)
Log Message:
-----------
Added support for the "preferredDomain" and propagated that all the way through the system to make email be "labelled" properly. This option is server.xml and is not required.
Modified Paths:
--------------
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/VerifyEnvironmentMojo.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/WebappServletBase.java
maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml
Modified: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/VerifyEnvironmentMojo.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/VerifyEnvironmentMojo.java 2008-02-10 21:55:34 UTC (rev 732)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/VerifyEnvironmentMojo.java 2008-02-12 00:15:34 UTC (rev 733)
@@ -31,7 +31,8 @@
};
private static final String[] OPTIONAL_NAMES= {
- "preferredIPAddr"
+ "preferredIPAddr",
+ "preferredDomain"
};
/**
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-10 21:55:34 UTC (rev 732)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-12 00:15:34 UTC (rev 733)
@@ -223,6 +223,7 @@
assertFalse(accountDoc.isEmailValid());
String emailValidationURL = getLastEmailValidationURL(accountDoc.getEmail());
assertNotNull(emailValidationURL);
+ Log.debug("CHECKING VALIDATION URL:"+emailValidationURL);
StreamUtils.discardInput(wire1.performGET(URI.create(emailValidationURL), null));
accountDoc = adminWebClient.getAccountDocument(username);
assertTrue(accountDoc.isEmailValid());
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java 2008-02-10 21:55:34 UTC (rev 732)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java 2008-02-12 00:15:34 UTC (rev 733)
@@ -13,6 +13,7 @@
limitations under the License. */
package com.ogoglio.site;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
@@ -405,20 +406,46 @@
AttachmentRecord[] attachmentRecords = BodyPersistTasks.findAttachmentsByConfigurationID(record.getBodyConfigurationID(), getSessionFactory());
return DocumentFactory.documentFromRecord(record, settingRecords, attachmentRecords);
}
+
+ private String getDomainForExternalUse() {
+ if (preferredDomain!=null) {
+ return preferredDomain;
+ }
+ return getSiteInfo().getHost(); //can be dodgy if you are NOT in the dev case
+ }
+ private String getHostPortionOfURLForExternalUse() {
+ StringBuffer result=new StringBuffer();
+ result.append("http://"+getDomainForExternalUse());
+ //this is a dodgy and evil hack to determine if you want an ugly or pretty URL
+ //if you bothered to make your base URL something that had a port, we repeat it, figuring
+ //that you are on a dev machine and probably need it
+ try {
+ URI uri=new URI(getSiteInfo().getBaseUrl());
+ if ((uri.getPort()!=80) && (uri.getPort()!=-1)) {
+ result.append(":"+uri.getPort());
+ }
+ } catch (URISyntaxException IGNORED) {
+
+ }
+ result.append("/");
+ return result.toString();
+ }
+
private void sendValidationMail(PendingEmailValidationRecord validationRecord) throws MailSendException {
- String from = "robot@" + getSiteInfo().getHost();
- String validationURL = getSiteInfo().getBaseUrl() + "account/validate?" + SECRET_PARAMETER + "=" + validationRecord.getSecret();
+ String from = "dont-reply@" + getDomainForExternalUse();
+ String validationURL = getHostPortionOfURLForExternalUse()+ "og/account/validate?" + SECRET_PARAMETER + "=" + validationRecord.getSecret();
MailFormatter mailFormatter = new MailFormatter();
- Map validationMap = createEmailValidationMap(validationRecord.getEmail(), validationURL, "Ogoglio", getSiteInfo().getBaseUrl());
+ Map validationMap = createEmailValidationMap(validationRecord.getEmail(), validationURL, "Ogoglio", getHostPortionOfURLForExternalUse());
String body = mailFormatter.format(validationMap, getTemplate(EMAIL_VALIDATION_TEMPLATE));
MailClient mailClient = null;
- if (getSiteInfo().getMailDirectory() == null) {
+ File mailDir = getSiteInfo().getMailDirectory() ;
+ if (mailDir == null) {
mailClient = new MailClient();
} else {
- mailClient = new MailClient(getSiteInfo().getMailDirectory());
+ mailClient = new MailClient(mailDir);
}
mailClient.sendEmail(validationRecord.getEmail(), from, "validate request", body);
Log.info("Sent validation email to " + validationRecord.getEmail());
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/WebappServletBase.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/WebappServletBase.java 2008-02-10 21:55:34 UTC (rev 732)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/WebappServletBase.java 2008-02-12 00:15:34 UTC (rev 733)
@@ -10,6 +10,7 @@
protected boolean servletNeeded=true;
protected String preferredIPAddr=null;
+ protected String preferredDomain=null;
public void init(ServletConfig config) throws ServletException {
try {
@@ -21,9 +22,20 @@
}
try {
preferredIPAddr = (String) envCtx.lookup("ogoglio/preferredIPAddr");
+ if ((preferredIPAddr!=null) && (preferredIPAddr.trim().equals(""))) {
+ preferredIPAddr=null;
+ }
} catch (NameNotFoundException e) {
//this is optional
}
+ try {
+ preferredDomain = (String) envCtx.lookup("ogoglio/preferredDomain");
+ if ((preferredDomain!=null) && (preferredDomain.trim().equals(""))) {
+ preferredDomain=null;
+ }
+ } catch (NameNotFoundException e) {
+ //this is optional
+ }
super.init(config);
} catch (NamingException e) {
bailOutOfInit(e);
Modified: maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml 2008-02-10 21:55:34 UTC (rev 732)
+++ maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml 2008-02-12 00:15:34 UTC (rev 733)
@@ -24,5 +24,6 @@
<ResourceLink name="ogoglio/simFilterPort" global="simFilterPort" type="java.lang.String"/>
<ResourceLink name="ogoglio/preferredIPAddr" global="preferredIPAddr" type="java.lang.String"/>
+ <ResourceLink name="ogoglio/preferredDomain" global="preferredDomain" type="java.lang.String"/>
</Context>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2008-02-12 03:18:35
|
Revision: 734
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=734&view=rev
Author: iansmith
Date: 2008-02-11 19:18:32 -0800 (Mon, 11 Feb 2008)
Log Message:
-----------
If successfully validated an email addr, ogoglio now redirects to /emailValidated.html
Modified Paths:
--------------
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java
maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-12 00:15:34 UTC (rev 733)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-12 03:18:32 UTC (rev 734)
@@ -223,8 +223,12 @@
assertFalse(accountDoc.isEmailValid());
String emailValidationURL = getLastEmailValidationURL(accountDoc.getEmail());
assertNotNull(emailValidationURL);
- Log.debug("CHECKING VALIDATION URL:"+emailValidationURL);
- StreamUtils.discardInput(wire1.performGET(URI.create(emailValidationURL), null));
+ try {
+ StreamUtils.discardInput(wire1.performGET(URI.create(emailValidationURL), null));
+ } catch (IOException e) {
+ //this can have a few meanings, including that you haven't
+ fail("You were unable to GET the URL for email validation: it may mean that you ROOT application's web page (/emailValidated.html) hasn't been built yet.");
+ }
accountDoc = adminWebClient.getAccountDocument(username);
assertTrue(accountDoc.isEmailValid());
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java 2008-02-12 00:15:34 UTC (rev 733)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java 2008-02-12 03:18:32 UTC (rev 734)
@@ -23,6 +23,7 @@
import javax.media.j3d.Transform3D;
import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -492,7 +493,10 @@
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
- sendStringResponse("ok", "text/plain", response);
+
+ //this isn't likely to do anything useful unless you set the crossContext=true attribute
+ //in your context decl for your root application
+ response.sendRedirect("/emailValidated.html");
}
}
Modified: maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml 2008-02-12 00:15:34 UTC (rev 733)
+++ maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml 2008-02-12 03:18:32 UTC (rev 734)
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
-<Context reloadable="true" path="/og" >
+<Context reloadable="true" path="/og">
<Realm className="org.apache.catalina.realm.MemoryRealm" />
<ResourceLink name="mail/Session" global="mailSession" type="javax.mail.Session"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2008-02-12 21:19:17
|
Revision: 741
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=741&view=rev
Author: iansmith
Date: 2008-02-12 13:19:22 -0800 (Tue, 12 Feb 2008)
Log Message:
-----------
Fixed the redirect bug properly by changing the APIWire class to understand about GET without redirect. Only tests are likely to want this feature, but it's there.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/media/WebStore.java
maven/trunk/ogoglio-server/src/main/resources/log4j/log4j.properties
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2008-02-12 05:00:32 UTC (rev 740)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2008-02-12 21:19:22 UTC (rev 741)
@@ -331,7 +331,7 @@
}
public InputStream getTemplateGeometryStream(String ownerUsername, long templateID, int lodIndex) throws IOException {
- return wire.performGET(descriptor.getTemplateGeometryURI(ownerUsername, templateID, lodIndex), authenticator.getAuthCookie(), true);
+ return wire.performGET(descriptor.getTemplateGeometryURI(ownerUsername, templateID, lodIndex), authenticator.getAuthCookie(), true, true);
}
public void uploadTemplateResourceStream(String ownerUsername, long templateID, String name, InputStream input) throws IOException {
@@ -339,7 +339,7 @@
}
public InputStream getTemplateResourceStream(String ownerUsername, long templateID, String name) throws IOException {
- return wire.performGET(descriptor.getTemplateResourceURI(ownerUsername, templateID, name), authenticator.getAuthCookie(), false);
+ return wire.performGET(descriptor.getTemplateResourceURI(ownerUsername, templateID, name), authenticator.getAuthCookie(), false, true);
}
public void updateTemplateScript(String ownerUsername, long templateID, String script) throws IOException {
@@ -396,7 +396,7 @@
public String getTemplateScript(String ownerUsername, long templateID) {
try {
- InputStream input = wire.performGET(descriptor.getTemplateScriptURI(ownerUsername, templateID), authenticator.getAuthCookie(), false);
+ InputStream input = wire.performGET(descriptor.getTemplateScriptURI(ownerUsername, templateID), authenticator.getAuthCookie(), false, true);
return StreamUtils.readInput(input);
} catch (IOException e) {
return null;
@@ -462,7 +462,7 @@
}
public InputStream getPageContents(long spaceID, long thingID, long pageID) throws IOException {
- return wire.performGET(descriptor.getPageContentsURI(spaceID, thingID, pageID), authenticator.getAuthCookie(), false);
+ return wire.performGET(descriptor.getPageContentsURI(spaceID, thingID, pageID), authenticator.getAuthCookie(), false, true);
}
public Map getSpaceSettings(long spaceID) throws IOException {
@@ -491,7 +491,7 @@
public String getSpaceSetting(long spaceID, String key) {
try {
- InputStream stream = wire.performGET(descriptor.getSettingURI(spaceID, key), authenticator.getAuthCookie(), false);
+ InputStream stream = wire.performGET(descriptor.getSettingURI(spaceID, key), authenticator.getAuthCookie(), false, true);
if (stream == null) {
return null;
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java 2008-02-12 05:00:32 UTC (rev 740)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java 2008-02-12 21:19:22 UTC (rev 741)
@@ -139,11 +139,26 @@
public XMLElement fetchAuthenticatedXML(URI uri, String authCookie) throws IOException {
XMLElement data = new XMLElement();
- data.parseFromReader(new InputStreamReader(performGET(uri, authCookie, false)));
+ data.parseFromReader(new InputStreamReader(performGET(uri, authCookie, false, true)));
return data;
}
- public DecoratedInputStream performGET(URI uri, String authCookie, boolean requestCompression) throws IOException {
+ /**
+ * This method does a get an returns an input stream connected to the supplied URI. The stream
+ * is decompressed, even if you request compression. The followRedirects switch is probably
+ * only useful to tests, as it returns null if a redirect was found (rather than the default
+ * behavior of following redirects) and the flag was false. The redirect URI cannot be
+ * recovered. There is no return path other than the redirection that returns null; other
+ * error cases cause an IOException to be thrown.
+ *
+ * @param uri URI to connect the stream to
+ * @param authCookie optional auth cookie for an authenticated URI (this can be null for no authentication)
+ * @param requestCompression pass true if you are expecting a really large object to be returned
+ * @param followRedirects pass false to cause this method to not follow redirects and return null if one is found
+ * @return a DecoratedInputStream that is connected to the URI
+ * @throws IOException thrown if an type of error is encountered trying to read the URI. Can happen due to HTTP error codes or connectivity problems.
+ */
+ public DecoratedInputStream performGET(URI uri, String authCookie, boolean requestCompression, boolean followRedirects) throws IOException {
String version = System.getProperty("java.version");
if ((version == null) || version.startsWith(BAD_SUN_VERSION)) {
//THIS IS TO WORK AROUND SUN'S ABSOLUTELY BROKEN APPLET CACHE IN JRE 1.6u1 & 2
@@ -172,15 +187,34 @@
if (requestCompression) {
connection.setRequestProperty("Accept-encoding", "gzip");
}
+ if (!followRedirects) { //switch it on, it's a static property? why?
+ HttpURLConnection.setFollowRedirects(false);
+ }
connection.setDoOutput(false);
- if (connection.getResponseCode() != 200) {
+ int code = connection.getResponseCode();
+ if (code != 200) {
+ if (!followRedirects) {
+ //we have to switch it back to prevent problems in the future
+ //XXX does this mean we can get concurrency problems in wire?
+ HttpURLConnection.setFollowRedirects(true);
+ if ((code>=300) && (code<400)) {
+ return null;
+ }
+ }
throw new IOException("Get status " + connection.getResponseCode() + " from " + uri);
}
+ DecoratedInputStream dis;
if ("gzip".equals(connection.getHeaderField("Content-encoding"))) {
- return new DecoratedInputStream(new GZIPInputStream(connection.getInputStream()), connection.getContentLength(), connection.getContentType(), connection.getLastModified());
+ dis=new DecoratedInputStream(new GZIPInputStream(connection.getInputStream()), connection.getContentLength(), connection.getContentType(), connection.getLastModified());
} else {
- return new DecoratedInputStream(connection.getInputStream(), connection.getContentLength(), connection.getContentType(), connection.getLastModified());
+ dis=new DecoratedInputStream(connection.getInputStream(), connection.getContentLength(), connection.getContentType(), connection.getLastModified());
}
+ if (!followRedirects) {
+ //we have to switch it back to prevent problems in the future
+ //XXX does this mean we can get concurrency problems in wire?
+ HttpURLConnection.setFollowRedirects(true);
+ }
+ return dis;
}
public XMLElement postAuthenticatedXML(URI uri, String body, String authCookie) throws IOException {
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-12 05:00:32 UTC (rev 740)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-12 21:19:22 UTC (rev 741)
@@ -223,13 +223,7 @@
assertFalse(accountDoc.isEmailValid());
String emailValidationURL = getLastEmailValidationURL(accountDoc.getEmail());
assertNotNull(emailValidationURL);
- try {
- StreamUtils.discardInput(wire1.performGET(URI.create(emailValidationURL), null));
- } catch (IOException e) {
- //this can have a few meanings, including that you haven't
- Log.info("TURNING OFF THIS TEST UNTIL TOMORROW BECAUSE IT BREAKS THE BUILD");
- //fail("You were unable to GET the URL for email validation: it may mean that you ROOT application's web page (/emailValidated.html) hasn't been built yet.");
- }
+ StreamUtils.discardInput(wire1.performGET(URI.create(emailValidationURL), null, false, false));
accountDoc = adminWebClient.getAccountDocument(username);
assertTrue(accountDoc.isEmailValid());
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/media/WebStore.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/media/WebStore.java 2008-02-12 05:00:32 UTC (rev 740)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/media/WebStore.java 2008-02-12 21:19:22 UTC (rev 741)
@@ -52,7 +52,7 @@
public DecoratedInputStream getData(String name) {
try {
- return new WebAPIClientWire().performGET(WebAPIUtil.appendToURI(mediaURI, name), null, false);
+ return new WebAPIClientWire().performGET(WebAPIUtil.appendToURI(mediaURI, name), null, false, true);
} catch (IOException e) {
return null;
}
@@ -78,7 +78,7 @@
//This is really expensive and probably shouldn't be used except in the most rare of circumstances
public String[] getAllNames() {
try {
- DecoratedInputStream dis = new WebAPIClientWire().performGET(WebAPIUtil.appendToURI(mediaURI, "?list=true"), null, false);
+ DecoratedInputStream dis = new WebAPIClientWire().performGET(WebAPIUtil.appendToURI(mediaURI, "?list=true"), null, false, true);
InputStreamReader isr = new InputStreamReader(dis);
BufferedReader reader = new BufferedReader(isr);
List result = new ArrayList();
Modified: maven/trunk/ogoglio-server/src/main/resources/log4j/log4j.properties
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/log4j/log4j.properties 2008-02-12 05:00:32 UTC (rev 740)
+++ maven/trunk/ogoglio-server/src/main/resources/log4j/log4j.properties 2008-02-12 21:19:22 UTC (rev 741)
@@ -4,7 +4,7 @@
log4j.logger.org.apache=ERROR, R
log4j.logger.org.hibernate=ERROR, R
-log4j.logger.com.ogoglio=DEBUG, R
+log4j.logger.com.ogoglio=WARNING, R
log4j.logger.com.ogoglio.space=ERROR, R
#
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <duc...@us...> - 2008-02-13 03:38:44
|
Revision: 742
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=742&view=rev
Author: ducheneaut
Date: 2008-02-12 19:38:49 -0800 (Tue, 12 Feb 2008)
Log Message:
-----------
Added support for a RendererListener in order to warn the client that the JVM has run out of memory. When this happens, the client now pops up an alert box explaining why the user sees question marks everywhere. If the user clicks "help" he is redirected to the appropriate support page depending on his OS.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/Renderer.java
maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java 2008-02-12 21:19:22 UTC (rev 741)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java 2008-02-13 03:38:49 UTC (rev 742)
@@ -27,7 +27,6 @@
import javax.vecmath.Vector3d;
import com.ogoglio.util.ArgumentUtils;
-import com.ogoglio.util.Log;
public class Space {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java 2008-02-12 21:19:22 UTC (rev 741)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java 2008-02-13 03:38:49 UTC (rev 742)
@@ -1,6 +1,5 @@
package com.ogoglio.viewer.j3d;
-import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.IOException;
@@ -612,6 +611,10 @@
}
return atMax;
}
+
+ public boolean maxMemoryUsed() {
+ return complainedAboutMemory;
+ }
private Obj getObj(String username, long templateID, int lodIndex) throws ObjParseException {
try {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2008-02-12 21:19:22 UTC (rev 741)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2008-02-13 03:38:49 UTC (rev 742)
@@ -22,24 +22,19 @@
import java.util.Enumeration;
import javax.media.j3d.AmbientLight;
-import javax.media.j3d.Appearance;
import javax.media.j3d.Background;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.DirectionalLight;
-import javax.media.j3d.Geometry;
import javax.media.j3d.GraphicsConfigTemplate3D;
import javax.media.j3d.Node;
-import javax.media.j3d.Shape3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
-import javax.vecmath.Point3f;
import javax.vecmath.Quat4d;
import javax.vecmath.Vector3d;
-import javax.vecmath.Vector3f;
import com.ogoglio.client.SpaceClient;
import com.ogoglio.client.UserInputListener;
@@ -58,7 +53,6 @@
import com.ogoglio.util.BodyConstants;
import com.ogoglio.util.Log;
import com.ogoglio.util.WebConstants;
-import com.ogoglio.viewer.j3d.body.Skeleton;
import com.ogoglio.viewer.render.Camera;
import com.ogoglio.viewer.render.ClickTarget;
import com.ogoglio.viewer.render.DoorRenderable;
@@ -114,6 +108,8 @@
private boolean rendererStopped = false;
private boolean completedInitialLoad = false;
+
+ private boolean memoryNotificationSent = false;
private J3DDataManager dataManager = null;
@@ -749,6 +745,12 @@
private ThingRenderable createThingRenderable(Thing thing, boolean useCache) throws IOException, RenderableParseException {
J3DRenderableLoader loader = new J3DRenderableLoader(dataManager.getTemplateData(thing.getTemplate().getOwnerUsername(), thing.getTemplate().getTemplateID(), useCache));
+
+ if (dataManager.maxMemoryUsed() && !memoryNotificationSent) {
+ notifyMaximumMemoryUsed();
+ memoryNotificationSent = true;
+ }
+
J3DThingRenderable renderable = loader.loadThing(thing);
renderable.setPosition(thing.getPosition());
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/Renderer.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/Renderer.java 2008-02-12 21:19:22 UTC (rev 741)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/Renderer.java 2008-02-13 03:38:49 UTC (rev 742)
@@ -15,6 +15,7 @@
package com.ogoglio.viewer.render;
import java.awt.Canvas;
+import java.util.Vector;
import com.ogoglio.client.model.Space;
import com.ogoglio.util.ArgumentUtils;
@@ -22,6 +23,8 @@
public abstract class Renderer {
private Space space = null;
+
+ private ListenerList listenerList = new ListenerList();
public Renderer(Space space) {
ArgumentUtils.assertNotNull(space);
@@ -48,5 +51,34 @@
return space;
}
+ public interface Listener {
+ public void ranOutOfMemory();
+ }
+
+ private class ListenerList {
+ Vector list = new Vector();
+ synchronized Listener[] getListeners() {
+ return (Listener[]) list.toArray(new Listener[0]);
+ }
+
+ synchronized void addListener(Listener listener) {
+ list.add(listener);
+ }
+
+ synchronized void removeListener(Listener listener) {
+ list.remove(listener);
+ }
+ }
+
+ public void addListener(Listener listener) {
+ listenerList.addListener(listener);
+ }
+
+ public void notifyMaximumMemoryUsed() {
+ Listener[] listeners = listenerList.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ listeners[i].ranOutOfMemory();
+ }
+ }
}
Modified: maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java
===================================================================
--- maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java 2008-02-12 21:19:22 UTC (rev 741)
+++ maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java 2008-02-13 03:38:49 UTC (rev 742)
@@ -16,17 +16,23 @@
import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.BorderLayout;
+import java.awt.Button;
import java.awt.Color;
+import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
+import java.awt.Frame;
import java.awt.MenuItem;
import java.awt.Panel;
import java.awt.PopupMenu;
+import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
@@ -62,6 +68,8 @@
private Renderer renderer = null;
private SpaceClientListener spaceClientListener = new SpaceClientListener();
+
+ private RendererListener rendererListener = new RendererListener();
private URI serviceURI = null;
@@ -80,11 +88,17 @@
private AudioClip incomingChatAudioClip = null;
private String helpMessage = null;
+
+ private ViewerApplet theApplet;
+
+ private String osType;
public ViewerApplet() {
setBackground(Color.WHITE);
setLayout(new BorderLayout());
add(splashPanel, BorderLayout.CENTER);
+ theApplet = this;
+ osType = System.getProperty("os.name");
}
public void start() {
@@ -153,6 +167,7 @@
spaceClient.getSpace().getUser(spaceClient.getUsername()).setPosition(transform);
}
renderer = new J3DRenderer(spaceClient, false);
+ renderer.addListener(rendererListener);
renderer.setMovable(movable);
removeAll();
@@ -481,7 +496,14 @@
public String getUsername() {
return spaceClient.getUsername();
}
+
+ private class RendererListener implements Renderer.Listener {
+ public void ranOutOfMemory() {
+ MemoryInfoPanel memoryBox = new MemoryInfoPanel(new Frame(""));
+ }
+ }
+
private class SpaceClientListener implements SpaceClient.Listener {
User lastTellUser = null;
@@ -710,5 +732,75 @@
add(new JLabel("Connecting..."));
}
}
+
+ private class MemoryInfoPanel extends Dialog implements ActionListener {
+ Button help,cancel;
+ TextArea text;
+ String memoryMessage =
+ "Our renderer ran out of memory and could not\n"
+ + "display all of the objects in the space -\n"
+ + "they were replaced by question marks. Click\n"
+ + "the Help button below to open a page with \n"
+ + "instructions about how to easily solve this\n"
+ + "problem in your current operating system.";
+ String helpURL;
+
+ public MemoryInfoPanel(Frame frame){
+ super(frame, "Out Of Memory Error", true);
+ setLayout(new FlowLayout());
+ text = new TextArea(memoryMessage, 6, 40, TextArea.SCROLLBARS_NONE);
+ text.setEditable(false);
+ add(text);
+ addHelpCancelPanel();
+ createFrame();
+ pack();
+ setVisible(true);
+ }
+ private void addHelpCancelPanel() {
+ Panel p = new Panel();
+ p.setLayout(new FlowLayout());
+ createButtons(p);
+ add(p);
+ }
+
+ private void createButtons(Panel p) {
+ p.add(help = new Button("Help"));
+ help.addActionListener(this);
+ p.add(cancel = new Button("Cancel"));
+ cancel.addActionListener(this);
+ }
+
+ private void createFrame() {
+ Dimension d = theApplet.getSize();
+ setLocation(d.width/4,d.height/3);
+ setPreferredSize(new Dimension(d.width, d.height/3));
+ }
+
+ public void actionPerformed(ActionEvent ae){
+ if(ae.getSource() == help) {
+
+ setVisible(false);
+
+ if (osType.startsWith("Mac")) {
+ helpURL = "http://transmutable.com/appletSettingsOSX.html";
+ } else if (osType.startsWith("Windows")) {
+ helpURL = "http://transmutable.com/appletSettingsXP.html";
+ } else {
+ // TODO: add pages for other OS
+ helpURL = "http://transmutable.com/support.html";
+ }
+
+ try {
+ theApplet.stop();
+ theApplet.getAppletContext().showDocument(new URL(helpURL), "_top");
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ }
+ else if (ae.getSource() == cancel) {
+ setVisible(false);
+ }
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2008-02-18 02:22:10
|
Revision: 752
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=752&view=rev
Author: iansmith
Date: 2008-02-17 18:22:10 -0800 (Sun, 17 Feb 2008)
Log Message:
-----------
Added support for creating records in the sim list.
Changed timeout to be 30 secs on starting up a SpaceClient.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimPersistTasks.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
maven/trunk/ogoglio-server/src/test/java/com/ogoglio/persist/test/PersistTest.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2008-02-15 00:13:12 UTC (rev 751)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2008-02-18 02:22:10 UTC (rev 752)
@@ -63,7 +63,7 @@
public class SpaceClient implements UserInputListener, Space.Context {
- private static final long START_UP_WAIT_MS = 15000;
+ private static final long START_UP_WAIT_MS = 30000;
private Listener listener = null;
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2008-02-15 00:13:12 UTC (rev 751)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2008-02-18 02:22:10 UTC (rev 752)
@@ -662,4 +662,25 @@
public boolean deleteSim(long simID) throws IOException {
return wire.sendDelete(descriptor.getSpaceSimURI(simID), authenticator.getAuthCookie());
}
+ /**
+ * This method should be used with care. It creates a record in the server that a new sim
+ * is in some state. This does NOT launch the sim! This should probably only be used when
+ * a client can do some type of independent verification that the sim is alive and working,
+ * yet it is not in the list of sims being provided by the server.
+ *
+ * @param simURI the new URI to talk to the sim on
+ * @param reachable starting reachablity (not to useful to makie this false!)
+ * @param retired starting retired state
+ * @return A sim document describing this new sim record, including the newly assigned sim ID. Returns null on failure.
+ *
+ */
+ public SimDocument createSimRecord(URI simURI, boolean reachable, boolean retired) {
+ SimDocument simDoc = new SimDocument(-1, simURI,reachable, retired);
+ try {
+ return new SimDocument(wire.sendAuthenticatedXML(descriptor.getSpaceSimURI(false /*IGNORED FOR POST*/),
+ simDoc.toString(), "POST", authenticator.getAuthCookie()));
+ } catch (IOException e) {
+ return null;
+ }
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java 2008-02-15 00:13:12 UTC (rev 751)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java 2008-02-18 02:22:10 UTC (rev 752)
@@ -139,7 +139,8 @@
public XMLElement fetchAuthenticatedXML(URI uri, String authCookie) throws IOException {
XMLElement data = new XMLElement();
- data.parseFromReader(new InputStreamReader(performGET(uri, authCookie, false, true)));
+ String remoteData = StreamUtils.readInput(performGET(uri, authCookie, false, true));
+ data.parseString(remoteData);
return data;
}
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-15 00:13:12 UTC (rev 751)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-18 02:22:10 UTC (rev 752)
@@ -437,10 +437,11 @@
//check perms and but don't actually do deletion
assertFalse(stdWebClient.deleteSim(simDoc.getSimID()));
-
+ //blow it away as admin
+ assertTrue(adminWebClient.deleteSim(simDoc.getSimID()));
+
//put back in right state
- adminWebClient.setSimReachable(sims[0].getSimID(), true);
- adminWebClient.setSimRetired(sims[0].getSimID(), false);
+ assertNotNull(adminWebClient.createSimRecord(simDoc.getSimURI(),true,false));
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimPersistTasks.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimPersistTasks.java 2008-02-15 00:13:12 UTC (rev 751)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimPersistTasks.java 2008-02-18 02:22:10 UTC (rev 752)
@@ -58,7 +58,7 @@
return (SimRecord) task.execute();
}
- public static SimRecord createSim(final URI simURI, final boolean reachable, final boolean retired, SessionFactory sessionFactory) throws PersistException {
+ public static SimRecord createSimRecord(final URI simURI, final boolean reachable, final boolean retired, SessionFactory sessionFactory) throws PersistException {
HibernateTask task = new HibernateTask() {
public Object run(Session hibernateSession) {
SimRecord record = new SimRecord(simURI, reachable, retired);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2008-02-15 00:13:12 UTC (rev 751)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2008-02-18 02:22:10 UTC (rev 752)
@@ -108,7 +108,7 @@
SimPersistTasks.update(simRecord, getSessionFactory());
} else {
Log.info("Starting up sim @ " + simURI);
- simRecord = SimPersistTasks.createSim(simURI, true, false, getSessionFactory());
+ simRecord = SimPersistTasks.createSimRecord(simURI, true, false, getSessionFactory());
}
WebAPIDescriptor descriptor;
String serviceURI = (String) envCtx.lookup("ogoglio/baseURL");
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2008-02-15 00:13:12 UTC (rev 751)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2008-02-18 02:22:10 UTC (rev 752)
@@ -877,12 +877,9 @@
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
boolean onlyServers = false;
- //check for null is superfluous?
- if (authedAccount == null || !AccountDocument.ACCOUNT_LEVEL_ADMIN.equals(authedAccount.getAccountlevel())) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return;
+ if (!verifyAuthAdmin(authedAccount, response)) {
+ return; //status set in verify
}
-
if ("true".equalsIgnoreCase(request.getParameter(ONLY_SERVERS))) {
onlyServers = true;
}
@@ -922,8 +919,38 @@
}
list.addChild(simDoc.toElement());
}
-
+ Log.info("Requested list of sims:"+list.toString());
this.sendStringResponse(list.toString(), "text/xml", response);
}
+ public void doPost(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
+ if (!verifyAuthAdmin(authedAccount, response)) {
+ return; //status set in verify
+ }
+
+ XMLElement simElement = parseXML(request.getInputStream());
+ if (!SimDocument.NAME.equals(simElement.getName())) {
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ return;
+ }
+ SimDocument clientRequested = new SimDocument(simElement);
+ SimRecord newSimRec = SimPersistTasks.createSimRecord(clientRequested.getSimURI(),
+ clientRequested.isReachable(), clientRequested.isRetired(), getSessionFactory());
+ if (newSimRec== null) {
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ return;
+ }
+ SimDocument returnedDoc = DocumentFactory.documentFromRecord(newSimRec);
+ sendStringResponse(returnedDoc.toString(), "text/xml", response);
+ }
+
+ private boolean verifyAuthAdmin(AccountRecord authedAccount, HttpServletResponse response) {
+ //check for null is superfluous?
+ if (authedAccount == null || !AccountDocument.ACCOUNT_LEVEL_ADMIN.equals(authedAccount.getAccountlevel())) {
+ response.setStatus(HttpServletResponse.SC_FORBIDDEN);
+ return false;
+ }
+ return true;
+ }
+
}
}
Modified: maven/trunk/ogoglio-server/src/test/java/com/ogoglio/persist/test/PersistTest.java
===================================================================
--- maven/trunk/ogoglio-server/src/test/java/com/ogoglio/persist/test/PersistTest.java 2008-02-15 00:13:12 UTC (rev 751)
+++ maven/trunk/ogoglio-server/src/test/java/com/ogoglio/persist/test/PersistTest.java 2008-02-18 02:22:10 UTC (rev 752)
@@ -226,7 +226,7 @@
private SpaceRecord checkSpaceAndSimTasks() throws PersistException {
SimRecord simRecord1;
// ok to create sim now on that URI
- simRecord1 = SimPersistTasks.createSim(simURI1, true, false, sessionFactory);
+ simRecord1 = SimPersistTasks.createSimRecord(simURI1, true, false, sessionFactory);
verifySimProps(simRecord1, simURI1, -1);
// better test is to load it from db
@@ -255,7 +255,7 @@
//bogus sim
URI bossaNova=ArgumentUtils.createURI("http://bossanova.example.com");
- SimRecord bogus1 = SimPersistTasks.createSim(bossaNova,true, false, sessionFactory);
+ SimRecord bogus1 = SimPersistTasks.createSimRecord(bossaNova,true, false, sessionFactory);
SimRecord[] arrayOfOne=new SimRecord[] {bogus1};
//verify that right now we are reachable
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2008-02-25 18:37:29
|
Revision: 767
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=767&view=rev
Author: trevorolio
Date: 2008-02-25 10:35:50 -0800 (Mon, 25 Feb 2008)
Log Message:
-----------
Added NONFUNCTIONAL stubs for a Flex audio client and wowza based audio space server. This checkin is mainly to lay out the modules to get the build process in place, not to provide functional code. Calm down, Beavis.
Added Paths:
-----------
maven/trunk/ogoglio-avserver/
maven/trunk/ogoglio-avserver/client/
maven/trunk/ogoglio-avserver/client/.actionScriptProperties
maven/trunk/ogoglio-avserver/client/.flexProperties
maven/trunk/ogoglio-avserver/client/.project
maven/trunk/ogoglio-avserver/client/.settings/
maven/trunk/ogoglio-avserver/client/.settings/org.eclipse.core.resources.prefs
maven/trunk/ogoglio-avserver/client/OgoglioChat.mxml
maven/trunk/ogoglio-avserver/client/com/
maven/trunk/ogoglio-avserver/client/com/ogoglio/
maven/trunk/ogoglio-avserver/client/com/ogoglio/chat/
maven/trunk/ogoglio-avserver/client/com/ogoglio/chat/client/
maven/trunk/ogoglio-avserver/client/com/ogoglio/chat/client/UserStream.as
maven/trunk/ogoglio-avserver/client/html-template/
maven/trunk/ogoglio-avserver/client/html-template/AC_OETags.js
maven/trunk/ogoglio-avserver/client/html-template/history.htm
maven/trunk/ogoglio-avserver/client/html-template/history.js
maven/trunk/ogoglio-avserver/client/html-template/history.swf
maven/trunk/ogoglio-avserver/client/html-template/index.template.html
maven/trunk/ogoglio-avserver/client/html-template/playerProductInstall.swf
maven/trunk/ogoglio-avserver/server/
maven/trunk/ogoglio-avserver/server/.classpath
maven/trunk/ogoglio-avserver/server/.externalToolBuilders/
maven/trunk/ogoglio-avserver/server/.externalToolBuilders/JAR Builder.launch
maven/trunk/ogoglio-avserver/server/.project
maven/trunk/ogoglio-avserver/server/build.xml
maven/trunk/ogoglio-avserver/server/lib/
maven/trunk/ogoglio-avserver/server/src/
maven/trunk/ogoglio-avserver/server/src/com/
maven/trunk/ogoglio-avserver/server/src/com/ogoglio/
maven/trunk/ogoglio-avserver/server/src/com/ogoglio/wowza/
maven/trunk/ogoglio-avserver/server/src/com/ogoglio/wowza/ChatSpacesModule.java
Added: maven/trunk/ogoglio-avserver/client/.actionScriptProperties
===================================================================
--- maven/trunk/ogoglio-avserver/client/.actionScriptProperties (rev 0)
+++ maven/trunk/ogoglio-avserver/client/.actionScriptProperties 2008-02-25 18:35:50 UTC (rev 767)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<actionScriptProperties mainApplicationPath="OgoglioChat.mxml" version="1">
+<compiler additionalCompilerArguments="-locale en_US" copyDependentFiles="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="true" htmlHistoryManagement="true" htmlPlayerVersion="9.0.0" htmlPlayerVersionCheck="true" outputFolderPath="bin" strict="true" warn="true">
+<compilerSourcePath/>
+<libraryPath>
+<libraryPathEntry kind="3" linkType="2" path="${FRAMEWORKS}/libs/playerglobal.swc"/>
+<libraryPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/utilities.swc"/>
+<libraryPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/flex.swc" sourcepath="${FRAMEWORKS}/source"/>
+<libraryPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/framework.swc" sourcepath="${FRAMEWORKS}/source"/>
+<libraryPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/rpc.swc"/>
+<libraryPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/charts.swc" sourcepath="${FRAMEWORKS}/source"/>
+<libraryPathEntry kind="1" linkType="1" path="${FRAMEWORKS}/locale/{locale}"/>
+</libraryPath>
+<sourceAttachmentPath>
+<sourceAttachmentPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/flex.swc" sourcepath="${FRAMEWORKS}/source"/>
+<sourceAttachmentPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/framework.swc" sourcepath="${FRAMEWORKS}/source"/>
+<sourceAttachmentPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/charts.swc" sourcepath="${FRAMEWORKS}/source"/>
+</sourceAttachmentPath>
+</compiler>
+<applications>
+<application path="OgoglioChat.mxml"/>
+</applications>
+<buildCSSFiles/>
+</actionScriptProperties>
Added: maven/trunk/ogoglio-avserver/client/.flexProperties
===================================================================
--- maven/trunk/ogoglio-avserver/client/.flexProperties (rev 0)
+++ maven/trunk/ogoglio-avserver/client/.flexProperties 2008-02-25 18:35:50 UTC (rev 767)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flexProperties flexServerType="0" toolCompile="true" version="1"/>
Added: maven/trunk/ogoglio-avserver/client/.project
===================================================================
--- maven/trunk/ogoglio-avserver/client/.project (rev 0)
+++ maven/trunk/ogoglio-avserver/client/.project 2008-02-25 18:35:50 UTC (rev 767)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>OgoglioChat</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.adobe.flexbuilder.project.flexbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.adobe.flexbuilder.project.flexnature</nature>
+ <nature>com.adobe.flexbuilder.project.actionscriptnature</nature>
+ </natures>
+</projectDescription>
Added: maven/trunk/ogoglio-avserver/client/.settings/org.eclipse.core.resources.prefs
===================================================================
--- maven/trunk/ogoglio-avserver/client/.settings/org.eclipse.core.resources.prefs (rev 0)
+++ maven/trunk/ogoglio-avserver/client/.settings/org.eclipse.core.resources.prefs 2008-02-25 18:35:50 UTC (rev 767)
@@ -0,0 +1,3 @@
+#Sun Feb 24 15:33:21 PST 2008
+eclipse.preferences.version=1
+encoding/<project>=utf-8
Added: maven/trunk/ogoglio-avserver/client/OgoglioChat.mxml
===================================================================
--- maven/trunk/ogoglio-avserver/client/OgoglioChat.mxml (rev 0)
+++ maven/trunk/ogoglio-avserver/client/OgoglioChat.mxml 2008-02-25 18:35:50 UTC (rev 767)
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="utf-8"?>
+<mx:Application creationComplete="initAudio()" backgroundGradientColors="[0xFFFFFF,0xFFFFFF]" xmlns:mx="http://www.adobe.com/2006/mxml"
+ horizontalAlign="center" verticalGap="5" horizontalGap="5" width="215" height="140" layout="vertical" verticalAlign="top">
+<mx:Script>
+ <![CDATA[
+ import com.ogoglio.chat.client.UserStream;
+
+ private var streamURL:String = "rtmp://localhost:1935/videochat/";
+ private var streamName:String = "test" + Math.random();
+
+ private var netConnection:NetConnection = null;
+
+ private var userStream:UserStream = null;
+
+ private var mic:Microphone = null;
+ private var outgoingNetStream:NetStream = null;
+
+ public function initAudio():void {
+ trace("Initializing audio");
+ initMicrophone();
+ listen();
+ }
+
+ public function initMicrophone():void {
+ mic = Microphone.getMicrophone();
+ if(mic == null){
+ trace("No available microphone");
+ pushToTalkButton.enabled = false;
+ } else {
+ mic.setUseEchoSuppression(true);
+ mic.setSilenceLevel(5);
+ mic.addEventListener(ActivityEvent.ACTIVITY, micActivityHandler);
+ mic.addEventListener(StatusEvent.STATUS, micStatusHandler);
+ }
+ }
+
+ public function startTalk():void {
+ if(mic == null){
+ return;
+ }
+ if(outgoingNetStream == null){
+ outgoingNetStream = new NetStream(netConnection);
+ prepNetStream(outgoingNetStream);
+ outgoingNetStream.attachAudio(mic);
+ outgoingNetStream.publish(streamName);
+ } else {
+ outgoingNetStream.attachAudio(mic);
+ }
+ statusLabel.text = "Talking";
+ }
+
+ public function stopTalk():void {
+ if(mic == null || outgoingNetStream == null){
+ return;
+ }
+ outgoingNetStream.attachAudio(null);
+ pushToTalkButton.label = "Push to Talk";
+ statusLabel.text = "Playing";
+ }
+
+ public function prepNetStream(stream:NetStream):void {
+ var client:Object = new Object();
+ client.onMetaData = onMetaData;
+ client.onBWDone = onBWDone;
+ stream.client = client;
+ stream.addEventListener( NetStatusEvent.NET_STATUS, onNetStatus);
+ }
+
+ private function micActivityHandler(event:ActivityEvent):void {
+ trace("activityHandler: " + event);
+ if(event.activating){
+ pushToTalkButton.label = "Sending";
+ } else {
+ pushToTalkButton.label = "Push to Talk";
+ }
+ }
+
+ private function micStatusHandler(event:StatusEvent):void {
+ switch(event.code) {
+ case "Microphone.Muted":
+ trace("mic muted");
+ break;
+ case "Microphone.Unmuted":
+ trace("mic unmuted");
+ break;
+ default:
+ trace("unknown micStatusHandler event: " + event);
+ }
+ }
+
+ public function listen():void {
+ statusLabel.text = "Setup...";
+
+ netConnection = new NetConnection();
+
+ var client:Object = new Object();
+ client.onMetaData = onMetaData;
+ client.onBWDone = onBWDone;
+ netConnection.client = client;
+
+ netConnection.objectEncoding = ObjectEncoding.AMF0;
+ netConnection.addEventListener( NetStatusEvent.NET_STATUS, onNetStatus);
+ statusLabel.text = "Connecting...";
+ netConnection.connect(streamURL);
+ }
+
+ private function onMuteChange():void {
+ trace("On mute state change: " + muteCheckBox.selected);
+
+ if(userStream == null){
+ return;
+ }
+ userStream.setMute(muteCheckBox.selected);
+ }
+
+ private function onNetStatus(evt:NetStatusEvent):void {
+ switch(evt.info.code) {
+ case "NetConnection.Connect.Success":
+ trace("Connection success!");
+ statusLabel.text = "Connected";
+
+ userStream = new UserStream(netConnection, streamName);
+ statusLabel.text = "Playing";
+
+ pushToTalkButton.enabled = true;
+ muteCheckBox.enabled = true;
+ break;
+ case "NetConnection.Connect.Failed":
+ trace("Failed to connect");
+ statusLabel.text = "Failed";
+ pushToTalkButton.enabled = false;
+ muteCheckBox.enabled = false;
+ break;
+ case "NetConnection.Connect.Rejected":
+ trace("Rejected");
+ statusLabel.text = "Rejected"
+ pushToTalkButton.enabled = false;
+ muteCheckBox.enabled = false;
+ break;
+ case "NetStream.Play.StreamNotFound":
+ trace("No Stream");
+ statusLabel.text = "No Stream"
+ pushToTalkButton.enabled = false;
+ muteCheckBox.enabled = false;
+ break;
+ case "NetStream.Play.Stop":
+ case "NetStream.Buffer.Full":
+ break;
+ default:
+ trace("Uknown event code: " + evt.info.code);
+ }
+ }
+
+ private function onMetaData(obj:Object):void {
+ trace("onMetaData");
+ }
+ private function onBWDone(obj:Object):void {
+ trace("onBWDone");
+ }
+ ]]>
+</mx:Script>
+ <mx:Button enabled="false" id="pushToTalkButton" label="Push to Talk" mouseOut="stopTalk()" mouseUp="stopTalk()" mouseDown="startTalk()"/>
+ <mx:CheckBox enabled="false" id="muteCheckBox" label="Mute Audio" click="onMuteChange()"/>
+ <mx:Label text="Loading..." id="statusLabel"/>
+</mx:Application>
Added: maven/trunk/ogoglio-avserver/client/com/ogoglio/chat/client/UserStream.as
===================================================================
--- maven/trunk/ogoglio-avserver/client/com/ogoglio/chat/client/UserStream.as (rev 0)
+++ maven/trunk/ogoglio-avserver/client/com/ogoglio/chat/client/UserStream.as 2008-02-25 18:35:50 UTC (rev 767)
@@ -0,0 +1,64 @@
+package com.ogoglio.chat.client {
+
+import flash.net.*;
+import flash.events.NetStatusEvent;
+
+public class UserStream {
+
+ private var streamName:String = null;
+
+ private var netConnection:NetConnection = null;
+
+ private var incomingNetStream:NetStream = null;
+
+ public function UserStream(connection:NetConnection, name:String) {
+ netConnection = connection;
+ streamName = name;
+
+ incomingNetStream = new NetStream(netConnection);
+ prepNetStream(incomingNetStream);
+
+ incomingNetStream.play(streamName);
+ }
+
+ public function setMute(muteIt:Boolean):void {
+ if(incomingNetStream == null){
+ return;
+ }
+ incomingNetStream..receiveAudio(!muteIt);
+ }
+
+ public function prepNetStream(stream:NetStream):void {
+ var client:Object = new Object();
+ client.onMetaData = onMetaData;
+ client.onBWDone = onBWDone;
+ stream.client = client;
+ stream.addEventListener( NetStatusEvent.NET_STATUS, onNetStatus);
+ }
+
+
+ private function onNetStatus(evt:NetStatusEvent):void {
+ switch(evt.info.code) {
+ case "NetStream.Play.StreamNotFound":
+ trace("Stream Not Found: " + streamName);
+ break;
+ case "NetStream.Play.Stop":
+ trace("Stream Stop: " + streamName);
+ break;
+ case "NetStream.Buffer.Full":
+ trace("Stream Full: " + streamName);
+ break;
+ default:
+ trace("Uknown event code: " + evt.info.code + ": " + streamName);
+ }
+ }
+
+ private function onMetaData(obj:Object):void {
+ }
+
+ private function onBWDone(obj:Object):void {
+ }
+
+} //end class
+
+} //end package
\ No newline at end of file
Added: maven/trunk/ogoglio-avserver/client/html-template/AC_OETags.js
===================================================================
--- maven/trunk/ogoglio-avserver/client/html-template/AC_OETags.js (rev 0)
+++ maven/trunk/ogoglio-avserver/client/html-template/AC_OETags.js 2008-02-25 18:35:50 UTC (rev 767)
@@ -0,0 +1,269 @@
+// Flash Player Version Detection - Rev 1.5
+// Detect Client Browser type
+// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
+var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
+var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
+var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
+
+function ControlVersion()
+{
+ var version;
+ var axo;
+ var e;
+
+ // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
+
+ try {
+ // version will be set for 7.X or greater players
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
+ version = axo.GetVariable("$version");
+ } catch (e) {
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 6.X players only
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
+
+ // installed player is some revision of 6.0
+ // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
+ // so we have to be careful.
+
+ // default to the first public version
+ version = "WIN 6,0,21,0";
+
+ // throws if AllowScripAccess does not exist (introduced in 6.0r47)
+ axo.AllowScriptAccess = "always";
+
+ // safe to call for 6.0r47 or greater
+ version = axo.GetVariable("$version");
+
+ } catch (e) {
+ }
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 4.X or 5.X player
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
+ version = axo.GetVariable("$version");
+ } catch (e) {
+ }
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 3.X player
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
+ version = "WIN 3,0,18,0";
+ } catch (e) {
+ }
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 2.X player
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
+ version = "WIN 2,0,0,11";
+ } catch (e) {
+ version = -1;
+ }
+ }
+
+ return version;
+}
+
+// JavaScript helper required to detect Flash Player PlugIn version information
+function GetSwfVer(){
+ // NS/Opera version >= 3 check for Flash plugin in plugin array
+ var flashVer = -1;
+
+ if (navigator.plugins != null && navigator.plugins.length > 0) {
+ if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
+ var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
+ var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
+ var descArray = flashDescription.split(" ");
+ var tempArrayMajor = descArray[2].split(".");
+ var versionMajor = tempArrayMajor[0];
+ var versionMinor = tempArrayMajor[1];
+ if ( descArray[3] != "" ) {
+ tempArrayMinor = descArray[3].split("r");
+ } else {
+ tempArrayMinor = descArray[4].split("r");
+ }
+ var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
+ var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
+ }
+ }
+ // MSN/WebTV 2.6 supports Flash 4
+ else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
+ // WebTV 2.5 supports Flash 3
+ else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
+ // older WebTV supports Flash 2
+ else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
+ else if ( isIE && isWin && !isOpera ) {
+ flashVer = ControlVersion();
+ }
+ return flashVer;
+}
+
+// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
+function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
+{
+ versionStr = GetSwfVer();
+ if (versionStr == -1 ) {
+ return false;
+ } else if (versionStr != 0) {
+ if(isIE && isWin && !isOpera) {
+ // Given "WIN 2,0,0,11"
+ tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"]
+ tempString = tempArray[1]; // "2,0,0,11"
+ versionArray = tempString.split(","); // ['2', '0', '0', '11']
+ } else {
+ versionArray = versionStr.split(".");
+ }
+ var versionMajor = versionArray[0];
+ var versionMinor = versionArray[1];
+ var versionRevision = versionArray[2];
+
+ // is the major.revision >= requested major.revision AND the minor version >= requested minor
+ if (versionMajor > parseFloat(reqMajorVer)) {
+ return true;
+ } else if (versionMajor == parseFloat(reqMajorVer)) {
+ if (versionMinor > parseFloat(reqMinorVer))
+ return true;
+ else if (versionMinor == parseFloat(reqMinorVer)) {
+ if (versionRevision >= parseFloat(reqRevision))
+ return true;
+ }
+ }
+ return false;
+ }
+}
+
+function AC_AddExtension(src, ext)
+{
+ if (src.indexOf('?') != -1)
+ return src.replace(/\?/, ext+'?');
+ else
+ return src + ext;
+}
+
+function AC_Generateobj(objAttrs, params, embedAttrs)
+{
+ var str = '';
+ if (isIE && isWin && !isOpera)
+ {
+ str += '<object ';
+ for (var i in objAttrs)
+ str += i + '="' + objAttrs[i] + '" ';
+ for (var i in params)
+ str += '><param name="' + i + '" value="' + params[i] + '" /> ';
+ str += '></object>';
+ } else {
+ str += '<embed ';
+ for (var i in embedAttrs)
+ str += i + '="' + embedAttrs[i] + '" ';
+ str += '> </embed>';
+ }
+
+ document.write(str);
+}
+
+function AC_FL_RunContent(){
+ var ret =
+ AC_GetArgs
+ ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
+ , "application/x-shockwave-flash"
+ );
+ AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
+}
+
+function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
+ var ret = new Object();
+ ret.embedAttrs = new Object();
+ ret.params = new Object();
+ ret.objAttrs = new Object();
+ for (var i=0; i < args.length; i=i+2){
+ var currArg = args[i].toLowerCase();
+
+ switch (currArg){
+ case "classid":
+ break;
+ case "pluginspage":
+ ret.embedAttrs[args[i]] = args[i+1];
+ break;
+ case "src":
+ case "movie":
+ args[i+1] = AC_AddExtension(args[i+1], ext);
+ ret.embedAttrs["src"] = args[i+1];
+ ret.params[srcParamName] = args[i+1];
+ break;
+ case "onafterupdate":
+ case "onbeforeupdate":
+ case "onblur":
+ case "oncellchange":
+ case "onclick":
+ case "ondblClick":
+ case "ondrag":
+ case "ondragend":
+ case "ondragenter":
+ case "ondragleave":
+ case "ondragover":
+ case "ondrop":
+ case "onfinish":
+ case "onfocus":
+ case "onhelp":
+ case "onmousedown":
+ case "onmouseup":
+ case "onmouseover":
+ case "onmousemove":
+ case "onmouseout":
+ case "onkeypress":
+ case "onkeydown":
+ case "onkeyup":
+ case "onload":
+ case "onlosecapture":
+ case "onpropertychange":
+ case "onreadystatechange":
+ case "onrowsdelete":
+ case "onrowenter":
+ case "onrowexit":
+ case "onrowsinserted":
+ case "onstart":
+ case "onscroll":
+ case "onbeforeeditfocus":
+ case "onactivate":
+ case "onbeforedeactivate":
+ case "ondeactivate":
+ case "type":
+ case "codebase":
+ ret.objAttrs[args[i]] = args[i+1];
+ break;
+ case "id":
+ case "width":
+ case "height":
+ case "align":
+ case "vspace":
+ case "hspace":
+ case "class":
+ case "title":
+ case "accesskey":
+ case "name":
+ case "tabindex":
+ ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
+ break;
+ default:
+ ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
+ }
+ }
+ ret.objAttrs["classid"] = classid;
+ if (mimeType) ret.embedAttrs["type"] = mimeType;
+ return ret;
+}
+
+
Added: maven/trunk/ogoglio-avserver/client/html-template/history.htm
===================================================================
--- maven/trunk/ogoglio-avserver/client/html-template/history.htm (rev 0)
+++ maven/trunk/ogoglio-avserver/client/html-template/history.htm 2008-02-25 18:35:50 UTC (rev 767)
@@ -0,0 +1,21 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<script type='text/javascript' language='JavaScript1.2' charset='utf-8'>
+var v = new top.Vars(top.getSearch(window));
+var fv = v.toString('$_');
+</script>
+</head>
+<body >
+<script type='text/javascript' language='JavaScript1.2' charset='utf-8'>
+document.writeln('<object id=\"utility\" name=\" \" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"" + activexDownloadURL + "#version=7,0,14,0\" width=\"100\" height=\"50\">');
+document.writeln('<param name=\"movie\" value=\"history.swf\" />');
+document.writeln('<param name=\"FlashVars\" value=\"'+fv+'&$_lconid='+top.lc_id+'\"/>');
+document.writeln('<param name=\"quality\" value=\"high\" />');
+document.writeln('<param name=\"bgcolor\" value=\"#FFFFFF\" />');
+document.writeln('<param name=\"profile\" value=\"false\" />');
+document.writeln('<embed id=\"utilityEmbed\" name=\"history.swf\" src=\"history.swf\" type=\"application/x-shockwave-flash\" flashvars=\"'+fv+'&$_lconid='+top.lc_id+'\" profile=\"false\" quality=\"high\" bgcolor=\"#FFFFFF\" width=\"100\" height=\"50\" align=\"\" pluginspage=\"" + pluginDownloadURL + "\"></embed>');
+document.writeln('</object>');
+</script>
+</body>
+</html>
\ No newline at end of file
Added: maven/trunk/ogoglio-avserver/client/html-template/history.js
===================================================================
--- maven/trunk/ogoglio-avserver/client/html-template/history.js (rev 0)
+++ maven/trunk/ogoglio-avserver/client/html-template/history.js 2008-02-25 18:35:50 UTC (rev 767)
@@ -0,0 +1,48 @@
+// $Revision: 1.49 $
+// Vars
+Vars = function(qStr) {
+ this.numVars = 0;
+ if(qStr != null) {
+ var nameValue, name;
+ var pairs = qStr.split('&');
+ var pairLen = pairs.length;
+ for(var i = 0; i < pairLen; i++) {
+ var pair = pairs[i];
+ if( (pair.indexOf('=')!= -1) && (pair.length > 3) ) {
+ var nameValue = pair.split('=');
+ var name = nameValue[0];
+ var value = nameValue[1];
+ if(this[name] == null && name.length > 0 && value.length > 0) {
+ this[name] = value;
+ this.numVars++;
+ }
+ }
+ }
+ }
+}
+Vars.prototype.toString = function(pre) {
+ var result = '';
+ if(pre == null) { pre = ''; }
+ for(var i in this) {
+ if(this[i] != null && typeof(this[i]) != 'object' && typeof(this[i]) != 'function' && i != 'numVars') {
+ result += pre + i + '=' + this[i] + '&';
+ }
+ }
+ if(result.length > 0) result = result.substr(0, result.length-1);
+ return result;
+}
+function getSearch(wRef) {
+ var searchStr = '';
+ if(wRef.location.search.length > 1) {
+ searchStr = new String(wRef.location.search);
+ searchStr = searchStr.substring(1, searchStr.length);
+ }
+ return searchStr;
+}
+var lc_id = Math.floor(Math.random() * 100000).toString(16);
+if (this != top)
+{
+ top.Vars = Vars;
+ top.getSearch = getSearch;
+ top.lc_id = lc_id;
+}
Added: maven/trunk/ogoglio-avserver/client/html-template/history.swf
===================================================================
(Binary files differ)
Property changes on: maven/trunk/ogoglio-avserver/client/html-template/history.swf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: maven/trunk/ogoglio-avserver/client/html-template/index.template.html
===================================================================
--- maven/trunk/ogoglio-avserver/client/html-template/index.template.html (rev 0)
+++ maven/trunk/ogoglio-avserver/client/html-template/index.template.html 2008-02-25 18:35:50 UTC (rev 767)
@@ -0,0 +1,107 @@
+<!-- saved from url=(0014)about:internet -->
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>${title}</title>
+<script src="AC_OETags.js" language="javascript"></script>
+<style>
+body { margin: 0px; overflow:hidden }
+</style>
+<script language="JavaScript" type="text/javascript">
+<!--
+// -----------------------------------------------------------------------------
+// Globals
+// Major version of Flash required
+var requiredMajorVersion = ${version_major};
+// Minor version of Flash required
+var requiredMinorVersion = ${version_minor};
+// Minor version of Flash required
+var requiredRevision = ${version_revision};
+// -----------------------------------------------------------------------------
+// -->
+</script>
+</head>
+
+<body scroll="no">
+<script language="JavaScript" type="text/javascript" src="history.js"></script>
+<script language="JavaScript" type="text/javascript">
+<!--
+// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
+var hasProductInstall = DetectFlashVer(6, 0, 65);
+
+// Version check based upon the values defined in globals
+var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
+
+
+// Check to see if a player with Flash Product Install is available and the version does not meet the requirements for playback
+if ( hasProductInstall && !hasRequestedVersion ) {
+ // MMdoctitle is the stored document.title value used by the installation process to close the window that started the process
+ // This is necessary in order to close browser windows that are still utilizing the older version of the player after installation has completed
+ // DO NOT MODIFY THE FOLLOWING FOUR LINES
+ // Location visited after installation is complete if installation is required
+ var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
+ var MMredirectURL = window.location;
+ document.title = document.title.slice(0, 47) + " - Flash Player Installation";
+ var MMdoctitle = document.title;
+
+ AC_FL_RunContent(
+ "src", "playerProductInstall",
+ "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
+ "width", "${width}",
+ "height", "${height}",
+ "align", "middle",
+ "id", "${application}",
+ "quality", "high",
+ "bgcolor", "${bgcolor}",
+ "name", "${application}",
+ "allowScriptAccess","sameDomain",
+ "type", "application/x-shockwave-flash",
+ "pluginspage", "http://www.adobe.com/go/getflashplayer"
+ );
+} else if (hasRequestedVersion) {
+ // if we've detected an acceptable version
+ // embed the Flash Content SWF when all tests are passed
+ AC_FL_RunContent(
+ "src", "${swf}",
+ "width", "${width}",
+ "height", "${height}",
+ "align", "middle",
+ "id", "${application}",
+ "quality", "high",
+ "bgcolor", "${bgcolor}",
+ "name", "${application}",
+ "flashvars",'historyUrl=history.htm%3F&lconid=' + lc_id + '',
+ "allowScriptAccess","sameDomain",
+ "type", "application/x-shockwave-flash",
+ "pluginspage", "http://www.adobe.com/go/getflashplayer"
+ );
+ } else { // flash is too old or we can't detect the plugin
+ var alternateContent = 'Alternate HTML content should be placed here. '
+ + 'This content requires the Adobe Flash Player. '
+ + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
+ document.write(alternateContent); // insert non-flash content
+ }
+// -->
+</script>
+<noscript>
+ <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+ id="${application}" width="${width}" height="${height}"
+ codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
+ <param name="movie" value="${swf}.swf" />
+ <param name="quality" value="high" />
+ <param name="bgcolor" value="${bgcolor}" />
+ <param name="allowScriptAccess" value="sameDomain" />
+ <embed src="${swf}.swf" quality="high" bgcolor="${bgcolor}"
+ width="${width}" height="${height}" name="${application}" align="middle"
+ play="true"
+ loop="false"
+ quality="high"
+ allowScriptAccess="sameDomain"
+ type="application/x-shockwave-flash"
+ pluginspage="http://www.adobe.com/go/getflashplayer">
+ </embed>
+ </object>
+</noscript>
+<iframe name="_history" src="history.htm" frameborder="0" scrolling="no" width="22" height="0"></iframe>
+</body>
+</html>
Added...
[truncated message content] |
|
From: <tre...@us...> - 2008-02-26 17:33:25
|
Revision: 772
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=772&view=rev
Author: trevorolio
Date: 2008-02-26 09:32:44 -0800 (Tue, 26 Feb 2008)
Log Message:
-----------
Though it looks like a lot of changes because someone who shall remain named Ian isn't using the standard code formatter, this is just a couple of changes.
Fixed the broken email test which only worked if you had /emailValidated.html in a ROOT webapp on the same machine.
Made the viewer display the scene before your body arrives, which should give people more feedback during the process of loading bodies which now takes too long thanks to attachments and morphs.
Logged when an email address is validated.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java
maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2008-02-26 17:03:05 UTC (rev 771)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2008-02-26 17:32:44 UTC (rev 772)
@@ -113,6 +113,8 @@
private J3DDataManager dataManager = null;
+ private BranchGroup tempCameraGroup = new BranchGroup();
+
public J3DRenderer(SpaceClient spaceClient, boolean offScreen) {
this(spaceClient.getSpace(), spaceClient.getUsername(), spaceClient, spaceClient.getTemplateDataProvider(), spaceClient.getBodyDataProvider(), offScreen);
}
@@ -127,6 +129,7 @@
setCapabilities(sceneRoot);
setCapabilities(usersGroup);
setCapabilities(worldGroup);
+ setCapabilities(tempCameraGroup);
GraphicsConfiguration graphicsConfig = getGraphicsConfiguration(offScreen);
if (graphicsConfig == null) {
throw new IllegalStateException("Cannot create a 3D graphics configuration.");
@@ -242,8 +245,15 @@
picker = new J3DPicker(this);
+ float cameraHeight = (float) (2 - 2 / 5);
+ camera.setDefaultLocation(0, 0, 0);
+ camera.setRelativePosition(0, cameraHeight, 3f);
+
+ tempCameraGroup.addChild(camera.getNode());
+
new Thread() {
public void run() {
+ worldGroup.addChild(tempCameraGroup);
getSpace().addListener(new SpaceListener(), true);
completedInitialLoad = true;
}
@@ -713,6 +723,8 @@
boolean isLocalUser = username != null && user.getUsername().equals(username);
if (isLocalUser) {
+ worldGroup.removeChild(tempCameraGroup);
+ tempCameraGroup.removeAllChildren();
float cameraHeight = (float) (renderable.getHeight() - renderable.getHeight() / 5);
camera.setDefaultLocation(0, 0, 0);
camera.setRelativePosition(0, cameraHeight, 3f);
@@ -743,6 +755,8 @@
}
public void setSimCamera() {
+ worldGroup.removeChild(tempCameraGroup);
+ tempCameraGroup.removeAllChildren();
BranchGroup cameraBranch = new BranchGroup();
camera.setRelativePosition(0f, 2f, 2f);
cameraBranch.addChild(camera.getNode());
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-26 17:03:05 UTC (rev 771)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-26 17:32:44 UTC (rev 772)
@@ -224,10 +224,10 @@
String emailValidationURL = getLastEmailValidationURL(accountDoc.getEmail());
assertNotNull(emailValidationURL);
try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
+ StreamUtils.discardInput(wire1.performGET(URI.create(emailValidationURL), null, false, true));
+ } catch (IOException e) {
+ //this will happen if you don't have a ROOT webapp with /emailValidated.html in it. Looking the other way.
}
- StreamUtils.discardInput(wire1.performGET(URI.create(emailValidationURL), null, false, false));
accountDoc = adminWebClient.getAccountDocument(username);
assertTrue(accountDoc.isEmailValid());
@@ -407,7 +407,7 @@
checkUserSitting(spaceDocument, thingDocs, spaceClient1, guestSpaceClient1);
checkAttachments(spaceDocument, thingDocs, spaceClient1, advancedClient);
-
+
checkDeletingSpaceDestroysThings(spaceDocument.getSpaceID(), advancedClient, USERNAME1);
} finally {
@@ -422,38 +422,37 @@
}
public void testSimDocumentAndRetirement() throws AuthenticationFailedException, IOException {
- if(true){
+ if (true) {
Log.warn("TEMPORARILY TURNING OFF testSimDocumentAndRetirement TEST AS IT BREAKS SPACE SHUTDOWN");
return;
}
-
+
WebAPIClient adminWebClient = createAdminWebClient();
WebAPIClient stdWebClient = createStandardWebClient();
-
- SimDocument[] sims=adminWebClient.getSimDocuments(false);
+
+ SimDocument[] sims = adminWebClient.getSimDocuments(false);
assertNotNull(sims);
- assertEquals(1,sims.length);
-
- SimDocument simDoc= adminWebClient.getSimDocument(sims[0].getSimID());
- boolean origRetired=simDoc.isRetired();
+ assertEquals(1, sims.length);
+
+ SimDocument simDoc = adminWebClient.getSimDocument(sims[0].getSimID());
+ boolean origRetired = simDoc.isRetired();
boolean origReachable = simDoc.isReachable();
- adminWebClient.setSimRetired(simDoc.getSimID(),!origRetired);
- simDoc=adminWebClient.getSimDocument(sims[0].getSimID());
- assertEquals(simDoc.isRetired(),!origRetired);
- adminWebClient.setSimReachable(simDoc.getSimID(),!origReachable);
- simDoc=adminWebClient.getSimDocument(sims[0].getSimID());
- assertEquals(simDoc.isReachable(),!origReachable);
-
+ adminWebClient.setSimRetired(simDoc.getSimID(), !origRetired);
+ simDoc = adminWebClient.getSimDocument(sims[0].getSimID());
+ assertEquals(simDoc.isRetired(), !origRetired);
+ adminWebClient.setSimReachable(simDoc.getSimID(), !origReachable);
+ simDoc = adminWebClient.getSimDocument(sims[0].getSimID());
+ assertEquals(simDoc.isReachable(), !origReachable);
+
//check perms and but don't actually do deletion
assertFalse(stdWebClient.deleteSim(simDoc.getSimID()));
//blow it away as admin
assertTrue(adminWebClient.deleteSim(simDoc.getSimID()));
//put back in right state
- assertNotNull(adminWebClient.createSimRecord(simDoc.getSimURI(),true,false));
+ assertNotNull(adminWebClient.createSimRecord(simDoc.getSimURI(), true, false));
}
-
private WebAPIClient createStandardWebClient() throws IOException, AuthenticationFailedException {
WebAPIAuthenticator basicAuthenticator = new WebAPIAuthenticatorFactory().authenticate(wire1, descriptor1, USERNAME1, PASSWORD1);
assertNotNull("got null auth cookie", basicAuthenticator.getAuthCookie());
@@ -482,23 +481,23 @@
attachmentDocs = confDoc.getAttachmentDocuments();
assertEquals(1, attachmentDocs.length);
assertEquals(templateDoc.getTemplateID(), attachmentDocs[0].getTemplateID());
-
+
confDoc.removeAttachment(attachmentDocs[0].getAttachmentID());
advancedClient.updateBodyConfiguration(confDoc);
confDoc = advancedClient.getDefaultBodyConfiguration(advancedClient.getAuthenticator().getUsername());
attachmentDocs = confDoc.getAttachmentDocuments();
assertEquals(0, attachmentDocs.length);
-
+
TemplateDocument[] attachmentTemplateDocs = advancedClient.getAttachmentTemplateDocuments();
boolean foundNewTemplate = false;
for (int i = 0; i < attachmentTemplateDocs.length; i++) {
- if(attachmentTemplateDocs[i].getTemplateID() == templateDoc.getTemplateID()){
+ if (attachmentTemplateDocs[i].getTemplateID() == templateDoc.getTemplateID()) {
foundNewTemplate = true;
break;
}
}
assertTrue(foundNewTemplate);
-
+
advancedClient.deleteTemplate(templateDoc.getTemplateID());
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java 2008-02-26 17:03:05 UTC (rev 771)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java 2008-02-26 17:32:44 UTC (rev 772)
@@ -493,7 +493,7 @@
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
-
+ Log.info("Validated email address: " + validationRecord.getEmail());
//this isn't likely to do anything useful unless you set the crossContext=true attribute
//in your context decl for your root application
response.sendRedirect("/emailValidated.html");
Modified: maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java
===================================================================
--- maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java 2008-02-26 17:03:05 UTC (rev 771)
+++ maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java 2008-02-26 17:32:44 UTC (rev 772)
@@ -68,13 +68,13 @@
private Renderer renderer = null;
private SpaceClientListener spaceClientListener = new SpaceClientListener();
-
+
private RendererListener rendererListener = new RendererListener();
private URI serviceURI = null;
private String serverIP = null;
-
+
private String authCookie = null;
private Map popupMap = new HashMap();
@@ -88,9 +88,9 @@
private AudioClip incomingChatAudioClip = null;
private String helpMessage = null;
-
+
private ViewerApplet theApplet;
-
+
private String osType;
public ViewerApplet() {
@@ -98,7 +98,7 @@
setLayout(new BorderLayout());
add(splashPanel, BorderLayout.CENTER);
theApplet = this;
- osType = System.getProperty("os.name");
+ osType = System.getProperty("os.name");
}
public void start() {
@@ -120,7 +120,7 @@
}
serverIP = getParameter("serverIP");
- if(serverIP == null || serverIP.length() == 0){
+ if (serverIP == null || serverIP.length() == 0) {
removeAll();
validate();
add(new ErrorPanel("I can't find the server IP."), BorderLayout.CENTER);
@@ -128,7 +128,7 @@
repaint();
return;
}
-
+
float x = getFloatParameter("x", 0);
float y = getFloatParameter("y", 0);
float z = getFloatParameter("z", 0);
@@ -163,8 +163,9 @@
}
if (spaceClient.getSpace().getUser(spaceClient.getUsername()) == null) {
Log.warn("No user by that name in the space!");
+ } else {
+ spaceClient.getSpace().getUser(spaceClient.getUsername()).setPosition(transform);
}
- spaceClient.getSpace().getUser(spaceClient.getUsername()).setPosition(transform);
}
renderer = new J3DRenderer(spaceClient, false);
renderer.addListener(rendererListener);
@@ -291,23 +292,23 @@
imUser(message.substring(4));
} else if ("/debugChatter".equals(message)) {
new ChatterBoxThread().start();
- } else if(message.startsWith("/r ")){
- if(message.length() < 4){
+ } else if (message.startsWith("/r ")) {
+ if (message.length() < 4) {
return;
}
- if(spaceClientListener.lastTellUser == null){
+ if (spaceClientListener.lastTellUser == null) {
chatPanel.displayMessage(null, "I don't know to whom to reply.");
return;
}
String clippedMessage = message.substring(3);
spaceClient.userSentPrivateMessage(spaceClientListener.lastTellUser, clippedMessage);
String username = spaceClientListener.lastTellUser.getUsername();
- if(username.startsWith(WebConstants.GUEST_COOKIE_PREFIX)){
+ if (username.startsWith(WebConstants.GUEST_COOKIE_PREFIX)) {
username = J3DUserRenderable.convertGuestCookieToDisplayName(username);
}
chatPanel.displayMessage(null, "you told " + username + ": " + clippedMessage);
- } else if (message.startsWith("/t ")){
- if(message.length() < 6 || message.substring(3).indexOf(" ") == -1){
+ } else if (message.startsWith("/t ")) {
+ if (message.length() < 6 || message.substring(3).indexOf(" ") == -1) {
return;
}
String clippedMessage = message.substring(3);
@@ -316,16 +317,16 @@
String displayUsername = null;
for (int i = 0; i < users.length; i++) {
String testUsername = users[i].getUsername();
- if(testUsername.startsWith(WebConstants.GUEST_COOKIE_PREFIX)) {
+ if (testUsername.startsWith(WebConstants.GUEST_COOKIE_PREFIX)) {
testUsername = J3DUserRenderable.convertGuestCookieToDisplayName(testUsername);
}
- if(clippedMessage.startsWith(testUsername + " ")){
+ if (clippedMessage.startsWith(testUsername + " ")) {
namedUser = users[i];
displayUsername = testUsername;
break;
}
}
- if(namedUser == null){
+ if (namedUser == null) {
chatPanel.displayMessage(null, "No such user.");
return;
}
@@ -496,18 +497,18 @@
public String getUsername() {
return spaceClient.getUsername();
}
-
+
private class RendererListener implements Renderer.Listener {
- public void ranOutOfMemory() {
- MemoryInfoPanel memoryBox = new MemoryInfoPanel(new Frame(""));
- }
+ public void ranOutOfMemory() {
+ MemoryInfoPanel memoryBox = new MemoryInfoPanel(new Frame(""));
+ }
}
private class SpaceClientListener implements SpaceClient.Listener {
User lastTellUser = null;
-
+
public void disconnected() {
chatPanel.displayMessage(null, "Disconnected.");
}
@@ -524,13 +525,13 @@
incomingChatAudioClip.play();
}
}
-
+
public void receivedTellMessage(String username, String message) {
- if(!showChat){
+ if (!showChat) {
return;
}
User user = spaceClient.getSpace().getUser(username);
- if(user == null){
+ if (user == null) {
System.err.println("Received tell from unknown user: " + username);
return;
}
@@ -732,81 +733,75 @@
add(new JLabel("Connecting..."));
}
}
-
+
private class MemoryInfoPanel extends Dialog implements ActionListener {
- Button help,cancel;
- TextArea text;
- String memoryMessage =
- "\n"
- + "Our renderer ran out of memory and could not "
- + "display all of the objects in the space - "
- + "they were replaced by question marks. Click "
- + "the Help button below to open a page with "
- + "instructions about how to easily solve this "
- + "problem in your current operating system."
- + "\n";
- String helpURL;
-
- public MemoryInfoPanel(Frame frame){
- super(frame, "Out Of Memory Error", true);
- setLayout(new BorderLayout());
- text = new TextArea(memoryMessage, 8, 30, TextArea.SCROLLBARS_NONE);
- text.setEditable(false);
- text.setBackground(Color.LIGHT_GRAY);
- add(text, BorderLayout.CENTER);
- addHelpCancelPanel();
- createFrame();
- pack();
- setVisible(true);
- }
+ Button help, cancel;
- private void addHelpCancelPanel() {
- Panel p = new Panel();
- p.setLayout(new FlowLayout());
- createButtons(p);
- add(p, BorderLayout.SOUTH);
- }
+ TextArea text;
- private void createButtons(Panel p) {
- p.add(help = new Button("Help"));
- help.addActionListener(this);
- p.add(cancel = new Button("Cancel"));
- cancel.addActionListener(this);
- }
+ String memoryMessage = "\n" + "Our renderer ran out of memory and could not " + "display all of the objects in the space - " + "they were replaced by question marks. Click " + "the Help button below to open a page with " + "instructions about how to easily solve this " + "problem in your current operating system." + "\n";
- private void createFrame() {
- Dimension d = theApplet.getSize();
- setLocation(d.width/4,d.height/3);
- }
+ String helpURL;
- public void actionPerformed(ActionEvent ae){
- if(ae.getSource() == help) {
-
- setVisible(false);
-
- String protocol = theApplet.getCodeBase().getProtocol();
- int port = theApplet.getCodeBase().getPort();
- String host = theApplet.getCodeBase().getHost();
+ public MemoryInfoPanel(Frame frame) {
+ super(frame, "Out Of Memory Error", true);
+ setLayout(new BorderLayout());
+ text = new TextArea(memoryMessage, 8, 30, TextArea.SCROLLBARS_NONE);
+ text.setEditable(false);
+ text.setBackground(Color.LIGHT_GRAY);
+ add(text, BorderLayout.CENTER);
+ addHelpCancelPanel();
+ createFrame();
+ pack();
+ setVisible(true);
+ }
- if (osType.startsWith("Mac")) {
- helpURL = protocol + "://" + host + ":" + port + "/appletSettingsOSX.html";
- } else if (osType.startsWith("Windows")) {
- helpURL = protocol + "://" + host + ":" + port + "/appletSettingsXP.html";
- } else {
- // TODO: add pages for other OS
- helpURL = protocol + "://" + host + ":" + port + "/support.html";
- }
-
- try {
- theApplet.stop();
- theApplet.getAppletContext().showDocument(new URL(helpURL), "_top");
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- }
- else if (ae.getSource() == cancel) {
- setVisible(false);
- }
- }
- }
+ private void addHelpCancelPanel() {
+ Panel p = new Panel();
+ p.setLayout(new FlowLayout());
+ createButtons(p);
+ add(p, BorderLayout.SOUTH);
+ }
+
+ private void createButtons(Panel p) {
+ p.add(help = new Button("Help"));
+ help.addActionListener(this);
+ p.add(cancel = new Button("Cancel"));
+ cancel.addActionListener(this);
+ }
+
+ private void createFrame() {
+ Dimension d = theApplet.getSize();
+ setLocation(d.width / 4, d.height / 3);
+ }
+
+ public void actionPerformed(ActionEvent ae) {
+ if (ae.getSource() == help) {
+
+ setVisible(false);
+
+ String protocol = theApplet.getCodeBase().getProtocol();
+ int port = theApplet.getCodeBase().getPort();
+ String host = theApplet.getCodeBase().getHost();
+
+ if (osType.startsWith("Mac")) {
+ helpURL = protocol + "://" + host + ":" + port + "/appletSettingsOSX.html";
+ } else if (osType.startsWith("Windows")) {
+ helpURL = protocol + "://" + host + ":" + port + "/appletSettingsXP.html";
+ } else {
+ // TODO: add pages for other OS
+ helpURL = protocol + "://" + host + ":" + port + "/support.html";
+ }
+
+ try {
+ theApplet.stop();
+ theApplet.getAppletContext().showDocument(new URL(helpURL), "_top");
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ } else if (ae.getSource() == cancel) {
+ setVisible(false);
+ }
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2008-02-27 02:40:33
|
Revision: 777
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=777&view=rev
Author: iansmith
Date: 2008-02-26 18:40:31 -0800 (Tue, 26 Feb 2008)
Log Message:
-----------
Added log4j cruft to allow sensible debugging.
Added support for finding possessions by ID from the java api.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java
Added Paths:
-----------
maven/trunk/ogoglio-integration-test/src/main/resources/log4j/
maven/trunk/ogoglio-integration-test/src/main/resources/log4j/log4j.properties
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2008-02-27 01:45:14 UTC (rev 776)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2008-02-27 02:40:31 UTC (rev 777)
@@ -162,6 +162,10 @@
return (PossessionDocument[]) results.toArray(new PossessionDocument[0]);
}
+ public PossessionDocument getPossessionDocument(long possessionID) throws IOException {
+ return new PossessionDocument(wire.fetchAuthenticatedXML(descriptor.getPossessionURI(authenticator.getUsername(),possessionID), authenticator.getAuthCookie()));
+ }
+
public PossessionDocument addPossessionToSpace(long possessionID, long spaceID) throws IOException {
PossessionDocument doc = new PossessionDocument(possessionID, null, -1, spaceID, -1);
XMLElement result = wire.sendAuthenticatedXML(descriptor.getPossessionURI(authenticator.getUsername(), possessionID), doc.toString(), "POST", authenticator.getAuthCookie());
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java 2008-02-27 01:45:14 UTC (rev 776)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClientWire.java 2008-02-27 02:40:31 UTC (rev 777)
@@ -195,6 +195,7 @@
int code = connection.getResponseCode();
if (code != 200) {
if (!followRedirects) {
+ Log.info("About to set redirects back on, but code was:"+code);
//we have to switch it back to prevent problems in the future
//XXX does this mean we can get concurrency problems in wire?
HttpURLConnection.setFollowRedirects(true);
Added: maven/trunk/ogoglio-integration-test/src/main/resources/log4j/log4j.properties
===================================================================
--- maven/trunk/ogoglio-integration-test/src/main/resources/log4j/log4j.properties (rev 0)
+++ maven/trunk/ogoglio-integration-test/src/main/resources/log4j/log4j.properties 2008-02-27 02:40:31 UTC (rev 777)
@@ -0,0 +1,22 @@
+# if you want to have any hope of debugging things, you need this file
+log4j.rootLogger=DEBUG, R
+
+log4j.logger.org.apache=ERROR, R
+log4j.logger.org.hibernate=ERROR, R
+
+log4j.logger.com.ogoglio=DEBUG, R
+log4j.logger.com.ogoglio.space=ERROR, R
+
+#
+# do not want extra copies
+#
+log4j.additivity.com.ogoglio=false
+log4j.additivity.com.ogoglio.space=false
+log4j.additivity.org.apache=false
+
+#R appender, only should be used for stuff not configured here
+log4j.appender.R=org.apache.log4j.ConsoleAppender
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%d [%p] %c - %m%n
+
+
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-27 01:45:14 UTC (rev 776)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-02-27 02:40:31 UTC (rev 777)
@@ -80,6 +80,7 @@
import com.ogoglio.xml.ThingDocument;
import com.ogoglio.xml.UserDocument;
import com.sun.org.apache.xalan.internal.xsltc.compiler.Template;
+import com.sun.swing.internal.plaf.basic.resources.basic;
public class ClientTest extends TestCase {
@@ -220,6 +221,7 @@
assertEquals("Test", accountDoc.getFirstName());
assertEquals("Sims", accountDoc.getLastName());
+
assertFalse(accountDoc.isEmailValid());
String emailValidationURL = getLastEmailValidationURL(accountDoc.getEmail());
assertNotNull(emailValidationURL);
@@ -563,6 +565,12 @@
possDoc = basicWebClient.addPossessionToSpace(possDoc.getPossessionID(), spaceDocument.getSpaceID());
assertTrue(possDoc.getThingID() != -1);
+ long pid=possDoc.getPossessionID();
+ //just call the api one other way to get the same document...
+ possDoc=basicWebClient.getPossessionDocument(pid);
+ assertEquals(pid,possDoc.getPossessionID());
+ assertEquals(spaceDocument.getSpaceID(),possDoc.getSpaceID());
+
ThingDocument thingDoc = basicWebClient.getThingDocument(spaceDocument.getSpaceID(), possDoc.getThingID());
thingDoc.setZ(-10);
basicWebClient.updateThing(spaceDocument.getSpaceID(), thingDoc);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java 2008-02-27 01:45:14 UTC (rev 776)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java 2008-02-27 02:40:31 UTC (rev 777)
@@ -476,12 +476,14 @@
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
String requestedSecret = request.getParameter(SECRET_PARAMETER);
+ Log.info("Got a email validation GET on "+requestedSecret);
if (requestedSecret == null || requestedSecret.length() == 0) {
Log.error("Requested validation with no secret");
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
PendingEmailValidationRecord validationRecord = PendingEmailValidationTasks.findPendingEmailValidationBySecret(requestedSecret, getSessionFactory());
+ Log.info("Email validation "+requestedSecret+" and "+(validationRecord==null));
if (validationRecord == null) {
Log.error("Requested validation with unknown secret: " + requestedSecret);
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2008-03-04 21:44:51
|
Revision: 787
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=787&view=rev
Author: iansmith
Date: 2008-03-04 13:44:54 -0800 (Tue, 04 Mar 2008)
Log Message:
-----------
Fixed problems where we were printing errors to standard out rather than logging them.
Fixed parser to handle XML that has comma-based floating point.
Modified Paths:
--------------
maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/servlet/AbstractResourceServlet.java
maven/trunk/ogoglio-common/src/main/java/nanoxml/XMLElement.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/media/WebStore.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometChannelManager.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/NetworkChannelServer.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/SimpleSocketWaiterThread.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpacePersistTasks.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AuthenticatedSiteResource.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/MessageProxy.java
Modified: maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/servlet/AbstractResourceServlet.java
===================================================================
--- maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/servlet/AbstractResourceServlet.java 2008-03-02 14:10:50 UTC (rev 786)
+++ maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/servlet/AbstractResourceServlet.java 2008-03-04 21:44:54 UTC (rev 787)
@@ -208,7 +208,7 @@
try {
return new URI(request.getRequestURL().toString());
} catch (URISyntaxException e) {
- e.printStackTrace();
+ Log.error("Couldn't get request URI!",e);
throw new IllegalStateException("Bad request URI?!? " + request.getRequestURI());
}
}
Modified: maven/trunk/ogoglio-common/src/main/java/nanoxml/XMLElement.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/nanoxml/XMLElement.java 2008-03-02 14:10:50 UTC (rev 786)
+++ maven/trunk/ogoglio-common/src/main/java/nanoxml/XMLElement.java 2008-03-04 21:44:54 UTC (rev 787)
@@ -1113,7 +1113,13 @@
try {
return Float.parseFloat(value);
} catch (NumberFormatException e) {
- throw this.invalidValue(name, value);
+ //for people in other locales
+ value = value.replace(',', '.');
+ try {
+ return Float.parseFloat(value);
+ } catch (NumberFormatException f) {
+ throw this.invalidValue(name, value);
+ }
}
}
}
@@ -1385,7 +1391,13 @@
try {
return Double.valueOf(value).doubleValue();
} catch (NumberFormatException e) {
- throw this.invalidValue(name, value);
+ //other locales
+ value = value.replace(',', '.');
+ try {
+ return Double.valueOf(value).doubleValue();
+ } catch (NumberFormatException f) {
+ throw this.invalidValue(name, value);
+ }
}
}
}
Modified: maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java 2008-03-02 14:10:50 UTC (rev 786)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java 2008-03-04 21:44:54 UTC (rev 787)
@@ -313,4 +313,20 @@
assertEquals(3, possDoc.getSpaceID());
assertEquals(4, possDoc.getThingID());
}
+
+ public void testEuroNumbers() {
+ String source="<foo bar=\"5.678\" grik=\"1,234\"/>";
+ XMLElement elem=new XMLElement();
+ elem.parseString(source);
+ assertEquals(5.678,elem.getFloatAttribute("bar"),0.0001);
+ assertEquals(1.234,elem.getFloatAttribute("grik"),0.0001);
+
+ source="<football><euro cost=\"1,45\"/><american cost=\"145.1\"/></football>";
+ elem.parseString(source);
+ XMLElement euro=elem.getChild("euro");
+ XMLElement american=elem.getChild("american");
+
+ assertEquals(1.45,euro.getDoubleAttribute("cost"),0.0001);
+ assertEquals(145.1,american.getDoubleAttribute("cost"),0.0001);
+ }
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/media/WebStore.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/media/WebStore.java 2008-03-02 14:10:50 UTC (rev 786)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/media/WebStore.java 2008-03-04 21:44:54 UTC (rev 787)
@@ -26,6 +26,7 @@
import com.ogoglio.client.WebAPIClientWire;
import com.ogoglio.client.WebAPIUtil;
import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.util.Log;
public class WebStore implements MediaStore {
@@ -70,7 +71,8 @@
try {
return new WebAPIClientWire().sendDelete(WebAPIUtil.appendToURI(mediaURI, name), null);
} catch (IOException e) {
- e.printStackTrace();
+ Log.error("Error in delete!",e);
+ //e.printStackTrace();
return false;
}
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometChannelManager.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometChannelManager.java 2008-03-02 14:10:50 UTC (rev 786)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometChannelManager.java 2008-03-04 21:44:54 UTC (rev 787)
@@ -119,7 +119,7 @@
Log.error("No Such Destination!" + msg, e);
}
} catch (Throwable t) {
- t.printStackTrace();
+ Log.error("Error in CometChannelManager.messageDone",t);
}
}
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/NetworkChannelServer.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/NetworkChannelServer.java 2008-03-02 14:10:50 UTC (rev 786)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/NetworkChannelServer.java 2008-03-04 21:44:54 UTC (rev 787)
@@ -71,9 +71,9 @@
try {
channels[i].sendMessage(message);
} catch (NoSuchDestinationException e) {
- e.printStackTrace();
+ Log.error("distribute() of network channel server, no such destination:",e);
} catch (BlockingQueue.QueueClosedException e) {
- e.printStackTrace();
+ Log.error("distribute() of network channel server, blockingqueue.queueclosed:",e);
}
}
}
@@ -86,7 +86,7 @@
try {
channels[i].sendMessage(message);
} catch (NoSuchDestinationException e) {
- e.printStackTrace();
+ Log.error("distributeExclusively() of network channel server, no such destination:",e);
}
}
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/SimpleSocketWaiterThread.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/SimpleSocketWaiterThread.java 2008-03-02 14:10:50 UTC (rev 786)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/SimpleSocketWaiterThread.java 2008-03-04 21:44:54 UTC (rev 787)
@@ -49,7 +49,7 @@
ready.clientReady(clientProto);
} catch (IOException e) {
if (!cleaned) {
- e.printStackTrace();
+ Log.error("IOException waiting for client in SimpleSocketWaiter:",e);
}
break;
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpacePersistTasks.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpacePersistTasks.java 2008-03-02 14:10:50 UTC (rev 786)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpacePersistTasks.java 2008-03-04 21:44:54 UTC (rev 787)
@@ -40,10 +40,6 @@
public static final Random RANDOM = new Random();
- private static final long TEST_SIM_INTERVAL_MS = 15000;
-
- private static long lastTestOfSimServers=0L;
-
public static SpaceRecord updateSpace(final long spaceID, final SpaceDocument spaceDocument, SessionFactory sessionFactory) throws PersistException {
HibernateTask task = new HibernateTask() {
public Object run(Session hibernateSession) {
@@ -201,35 +197,45 @@
return findOrAssignSim(spaceRecord, sessionFactory, true);
}
- public static void verifyReachableSims(SimRecord[] puportedReachable, SessionFactory sessionFactory) throws PersistException {
+ public static void verifyReachableSims(SimRecord[] purportedReachable, SessionFactory sessionFactory) throws PersistException {
//let's see if they are ok
- for (int i=0; i<puportedReachable.length;++i) {
- try {
- URI simURI=puportedReachable[i].getSimURI();
- HttpURLConnection connection = (HttpURLConnection) simURI.toURL().openConnection();
- connection.setRequestMethod("GET");
- connection.setAllowUserInteraction(false);
- connection.setConnectTimeout(2000);
- connection.setReadTimeout(3000);
- if (connection.getResponseCode()!=200) {
- Log.warn("Can't get a connection to "+simURI+"! Marking inactive!");
- markNotReachable(puportedReachable[i], sessionFactory);
- } else {
- Log.info("Verified connection to "+simURI);
- }
- } catch (MalformedURLException e) {
- Log.warn("Can't understand the URI "+puportedReachable[i].getSimURI()+"! Marking inactive!");
- markNotReachable(puportedReachable[i], sessionFactory);
- } catch (ProtocolException e) {
- Log.warn("Can't understand the URI protocol "+puportedReachable[i].getSimURI()+"! Marking inactive!");
- markNotReachable(puportedReachable[i], sessionFactory);
- } catch (IOException e) {
- Log.warn("Can't connect to "+puportedReachable[i].getSimURI()+"! Marking inactive! IOException:"+e.getMessage());
- markNotReachable(puportedReachable[i], sessionFactory);
- }
+ for (int i=0; i<purportedReachable.length;++i) {
+ SimRecord someSimRec=purportedReachable[i];
+ verifySingleSimAsReachable(sessionFactory, someSimRec);
}
}
+
+ private static boolean verifySingleSimAsReachable(SessionFactory sessionFactory, SimRecord someSimRec) throws PersistException {
+ try {
+ URI simURI=someSimRec.getSimURI();
+ HttpURLConnection connection = (HttpURLConnection) simURI.toURL().openConnection();
+ connection.setRequestMethod("GET");
+ connection.setAllowUserInteraction(false);
+ connection.setConnectTimeout(2000);
+ connection.setReadTimeout(3000);
+ if (connection.getResponseCode()!=200) {
+ Log.warn("Can't get a connection to "+simURI+"! Marking inactive!");
+ markNotReachable(someSimRec, sessionFactory);
+ return false;
+ } else {
+ Log.info("Verified connection to "+simURI);
+ return true;
+ }
+ } catch (MalformedURLException e) {
+ Log.warn("Can't understand the URI "+someSimRec.getSimURI()+"! Marking inactive!");
+ markNotReachable(someSimRec, sessionFactory);
+ return false;
+ } catch (ProtocolException e) {
+ Log.warn("Can't understand the URI protocol "+someSimRec.getSimURI()+"! Marking inactive!");
+ markNotReachable(someSimRec, sessionFactory);
+ return false;
+ } catch (IOException e) {
+ Log.warn("Can't connect to "+someSimRec.getSimURI()+"! Marking inactive! IOException:"+e.getMessage());
+ markNotReachable(someSimRec, sessionFactory);
+ return false;
+ }
+ }
public static SimRecord findOrAssignSim(final SpaceRecord spaceRecord, SessionFactory sessionFactory, boolean use_network) throws PersistException {
SimRecord rec = findSimFromSpaceIfReachable(spaceRecord, sessionFactory);
@@ -241,14 +247,15 @@
if (assignable.length==0) {
throw new UnableToAssignSimException("Unable to find any sims that we can assign to!");
}
- //has it been a while?
- long now=System.currentTimeMillis();
- if ((now-lastTestOfSimServers<TEST_SIM_INTERVAL_MS) || (!use_network)) {
- return pickSimRandomly(spaceRecord, sessionFactory, assignable);
+ // first check this sim, if it's ok or no network then we just bail out
+ SimRecord randomChoice = pickSimRandomly(spaceRecord, sessionFactory, assignable);
+ if (!use_network) {
+ return randomChoice;
}
- //update the time check
- lastTestOfSimServers=now;
-
+ if (verifySingleSimAsReachable(sessionFactory, randomChoice)) {
+ return randomChoice;
+ }
+ //if we reach here, we have failed on that sim verification, so check ALL of them
verifyReachableSims(findAllReachableSims(spaceRecord, sessionFactory),sessionFactory);
assignable=findAllReachableAndNotRetiredSims(spaceRecord, sessionFactory);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java 2008-03-02 14:10:50 UTC (rev 786)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java 2008-03-04 21:44:54 UTC (rev 787)
@@ -122,7 +122,7 @@
try {
saveSpaceDocument(spaceSim.toSpaceDocument());
} catch (IOException e) {
- e.printStackTrace();
+ Log.error("IOException trying to save space document!",e);
}
}
}
@@ -194,7 +194,7 @@
}
return null;
} catch (PersistException e) {
- e.printStackTrace();
+ Log.error("Persist exception trying to getUserRole",e);
return null;
}
}
@@ -223,7 +223,7 @@
mediaService.write(MediaService.getPageContentName(spaceID, thingID, pageID), content);
return true;
} catch (IOException e) {
- e.printStackTrace();
+ Log.error("IOException trying to set page content",e);
return false;
}
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2008-03-02 14:10:50 UTC (rev 786)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2008-03-04 21:44:54 UTC (rev 787)
@@ -195,7 +195,7 @@
listener.requestSave(this);
}
} catch (Throwable e) {
- e.printStackTrace();
+ Log.error("Error during cleanup of space "+space.getSpaceID()+"!",e);
}
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java 2008-03-02 14:10:50 UTC (rev 786)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java 2008-03-04 21:44:54 UTC (rev 787)
@@ -109,11 +109,14 @@
ScriptMath math = (ScriptMath) constructorContext.newObject(globalScope, "Math", new Object[0]);
globalScope.put("math", globalScope, math);
} catch (IllegalAccessException e) {
- e.printStackTrace();
+ Log.error("Illegal access in constructor SpaceScriptEngine",e);
+ //e.printStackTrace();
} catch (InstantiationException e) {
- e.printStackTrace();
+ Log.error("InstantiationException in constructor of SpaceScriptEngine",e);
+ //e.printStackTrace();
} catch (InvocationTargetException e) {
- e.printStackTrace();
+ Log.error("Invocation target exception in constructor of SpaceScriptEngine",e);
+ //e.printStackTrace();
} finally {
Context.exit();
}
@@ -364,7 +367,8 @@
constructThingScript(thing);
}
} catch (Throwable e) {
- e.printStackTrace();
+ Log.error("Error in handle space event, trying to run thing script",e);
+ //e.printStackTrace();
}
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2008-03-02 14:10:50 UTC (rev 786)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2008-03-04 21:44:54 UTC (rev 787)
@@ -470,7 +470,7 @@
sendStringResponse(newDoc.toString(), "text/xml", response);
} catch (PersistException e) {
- e.printStackTrace();
+ Log.error("Persist exception in post of ThingsResource",e);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
@@ -1007,7 +1007,7 @@
sendStringResponse(newDoc.toString(), "text/xml", response);
} catch (PersistException e) {
- e.printStackTrace();
+ Log.error("Persist exception in post of Doors resource",e);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AuthenticatedSiteResource.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AuthenticatedSiteResource.java 2008-03-02 14:10:50 UTC (rev 786)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AuthenticatedSiteResource.java 2008-03-04 21:44:54 UTC (rev 787)
@@ -25,6 +25,7 @@
import com.ogoglio.appdev.servlet.SiteResource;
import com.ogoglio.persist.AccountRecord;
import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.util.Log;
public abstract class AuthenticatedSiteResource extends SiteResource {
@@ -72,7 +73,7 @@
}
doPost(request, response, pathElements, authedAccount);
} catch (PersistException e) {
- e.printStackTrace();
+ Log.error("Persist exception in post of Authenticated site resource!",e);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/MessageProxy.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/MessageProxy.java 2008-03-02 14:10:50 UTC (rev 786)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/MessageProxy.java 2008-03-04 21:44:54 UTC (rev 787)
@@ -228,7 +228,7 @@
Log.error("Unknown request payload: " + request.getPayload());
}
} catch (Throwable e) {
- e.printStackTrace();
+ Log.error("Error is MessageProxy.ClientMessageHandler.handleEvent!",e);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2008-03-11 23:18:50
|
Revision: 789
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=789&view=rev
Author: trevorolio
Date: 2008-03-11 16:18:53 -0700 (Tue, 11 Mar 2008)
Log Message:
-----------
Pleased as punch to check in the first contribution from Matt Kimmel at the Electric Sheep Company (http://www.electricsheepcompany.com/)
Matt's introduced a way to plug in new message codecs and wire protocols for world events. Not all scenarios work well with XML over Comet, so being able to negotiate between different protocols depending on firewalls and applications will be a Good Thing.
Thanks, Matt!
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/MeasPerfClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/SenderQueue.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/TCPChannel.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/TCPMessageReader.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/AsyncProto.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/AsyncProtoFactory.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometProto.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/Locator.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/SimpleSocketAsync.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/AsyncClientReady.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/AsyncProtoServerFactory.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/AsyncProtoShutdownHandle.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometChannelManager.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/NetworkChannelServer.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/SimpleSocketAsyncServer.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/SimpleSocketWaiterThread.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/MessageProxy.java
Added Paths:
-----------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/ChunkedStreamNetworkTransporter.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/MessageEncoder.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/MessageStack.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/MessageStackFactory.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/MessageStackType.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/MessagingException.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/NetworkTransporter.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/NullWireFormatEncoder.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/StreamNetworkTransporter.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/WireFormatEncoder.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/XMLMessageEncoder.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/message/
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/message/plugin/
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/message/plugin/test/
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/message/plugin/test/ChunkedStreamNetworkTransporterTest.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/message/plugin/test/MessageStackTest.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/message/plugin/test/NullWireFormatEncoderTest.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/message/plugin/test/StreamNetworkTransporterTest.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/message/plugin/test/XMLMessageEncoderTest.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2008-03-11 17:41:45 UTC (rev 788)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2008-03-11 23:18:53 UTC (rev 789)
@@ -13,6 +13,17 @@
limitations under the License. */
package com.ogoglio.client;
+import com.ogoglio.client.model.*;
+import com.ogoglio.message.*;
+import com.ogoglio.message.plugin.MessageStackFactory;
+import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.util.Log;
+import com.ogoglio.util.WebConstants;
+import com.ogoglio.xml.*;
+
+import javax.media.j3d.Transform3D;
+import javax.vecmath.Color3f;
+import javax.vecmath.Point3d;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
@@ -22,45 +33,6 @@
import java.util.Vector;
import java.util.zip.ZipInputStream;
-import javax.media.j3d.Transform3D;
-import javax.vecmath.Color3f;
-import javax.vecmath.Point3d;
-
-import com.ogoglio.client.model.Attachment;
-import com.ogoglio.client.model.BodyConfiguration;
-import com.ogoglio.client.model.BodyDataProvider;
-import com.ogoglio.client.model.Door;
-import com.ogoglio.client.model.Page;
-import com.ogoglio.client.model.Shape;
-import com.ogoglio.client.model.Space;
-import com.ogoglio.client.model.SplinePath;
-import com.ogoglio.client.model.Template;
-import com.ogoglio.client.model.TemplateDataProvider;
-import com.ogoglio.client.model.Thing;
-import com.ogoglio.client.model.User;
-import com.ogoglio.message.Message;
-import com.ogoglio.message.MessageHandler;
-import com.ogoglio.message.NoSuchDestinationException;
-import com.ogoglio.message.PayloadFactory;
-import com.ogoglio.message.TCPChannel;
-import com.ogoglio.message.proto.AsyncProtoFactory;
-import com.ogoglio.util.ArgumentUtils;
-import com.ogoglio.util.Log;
-import com.ogoglio.util.WebConstants;
-import com.ogoglio.xml.AccountDocument;
-import com.ogoglio.xml.AttachmentDocument;
-import com.ogoglio.xml.BodyConfigurationDocument;
-import com.ogoglio.xml.BodyDataDocument;
-import com.ogoglio.xml.BodySettingDocument;
-import com.ogoglio.xml.DoorDocument;
-import com.ogoglio.xml.PageDocument;
-import com.ogoglio.xml.ShapeDocument;
-import com.ogoglio.xml.SpaceDocument;
-import com.ogoglio.xml.SpaceEvent;
-import com.ogoglio.xml.TemplateDocument;
-import com.ogoglio.xml.ThingDocument;
-import com.ogoglio.xml.UserDocument;
-
public class SpaceClient implements UserInputListener, Space.Context {
private static final long START_UP_WAIT_MS = 30000;
@@ -117,7 +89,7 @@
space = new Space(this, spaceDoc.getSpaceID(), spaceDoc.getDisplayName(), spaceDoc.getOwnerUsername(), spaceDoc.getDisplaySea(), spaceDoc.getSeaLevel(), backgroundColor);
//create the event channel and start queuing events
- messageChannel = new TCPChannel(AsyncProtoFactory.getDefaultClient(descriptor, true), messenger, true, new ChannelListener(), true, "space-client");
+ messageChannel = new TCPChannel(MessageStackFactory.getDefaultStack(descriptor, true), messenger, true, new ChannelListener(), true, "space-client");
messenger.authenticate(authCookie);
long startWait = System.currentTimeMillis();
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/MeasPerfClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/MeasPerfClient.java 2008-03-11 17:41:45 UTC (rev 788)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/MeasPerfClient.java 2008-03-11 23:18:53 UTC (rev 789)
@@ -1,46 +1,48 @@
package com.ogoglio.message;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
+import com.ogoglio.message.plugin.MessageStack;
-import com.ogoglio.message.proto.AsyncProto;
-import com.ogoglio.message.proto.AsyncProtoFactory;
+import java.util.*;
-
public class MeasPerfClient extends Thread implements MessageHandler, TCPChannel.Listener {
- private static final double THRESHOLD_DANGER= 2.0; //make a note if it takes longer than this
- private static final int MAX_SLEEP_TIME_MS= 5000; //avg 2.5secs
- private static final int RAMP_UP_TIME= 250; //time btwn two thread creations
+ private static final double THRESHOLD_DANGER = 2.0; //make a note if it takes longer than this
+
+ private static final int MAX_SLEEP_TIME_MS = 5000; //avg 2.5secs
+
+ private static final int RAMP_UP_TIME = 250; //time btwn two thread creations
+
private static final int THRESHOLD_TERMINATE = 10; //we start culling senders if we see this many over THRESHOLD_DANGER
-
+
private TCPChannel channel;
- private static Map timeMap=Collections.synchronizedMap(new HashMap());
- private static Map senderMap=new HashMap();
- private static List deathList=Collections.synchronizedList(new ArrayList());
+ private static Map timeMap = Collections.synchronizedMap(new HashMap());
+
+ private static Map senderMap = new HashMap();
+
+ private static List deathList = Collections.synchronizedList(new ArrayList());
+
private static double totalTime = 0.0;
- private static double totalSamples=0.0;
- private static Object totalTimeLock=new Object();
- private static int warningCounter =0;
+ private static double totalSamples = 0.0;
+
+ private static Object totalTimeLock = new Object();
+
+ private static int warningCounter = 0;
+
private static Object warningCounterLock = new Object();
-
- private Random r=new Random();
-
+
+ private Random r = new Random();
+
public static void main(String[] argv) {
int n = Integer.parseInt(argv[0]);
try {
for (int i = 0; i < n; ++i) {
-// AsyncProto proto=AsyncProtoFactory.getDefaultClient(argv[1], AsyncProtoFactory.getDefaultInfo().getSimSpecificSelector());
- AsyncProto proto=null;/*AsyncProtoFactory.getDefaultClient(argv[1], "/fart/poop");*/
- Thread t =new MeasPerfClient(proto);
+ // AsyncProto proto=AsyncProtoFactory.getDefaultClient(argv[1], AsyncProtoFactory.getDefaultInfo().getSimSpecificSelector());
+ // AsyncProto proto=null;/*AsyncProtoFactory.getDefaultClient(argv[1], "/fart/poop");*/
+ MessageStack stack = null;
+ Thread t = new MeasPerfClient(stack);
t.start();
try {
Thread.sleep(RAMP_UP_TIME);
@@ -53,26 +55,26 @@
}
}
- public MeasPerfClient(AsyncProto proto) {
- System.out.println("FOUND A CLIENT PROTO:"+(proto!=null));
- channel = new TCPChannel(proto,this,false,this,true,"measure-perf-client");
+ public MeasPerfClient(MessageStack stack) {
+ System.out.println("FOUND A CLIENT PROTO:" + (stack != null));
+ channel = new TCPChannel(stack, this, false, this, true, "measure-perf-client");
}
public void run() {
while (true) {
- Payload p ;
+ Payload p;
Message m;
-
+
try {
- Long me=new Long(Thread.currentThread().getId());
+ Long me = new Long(Thread.currentThread().getId());
while (true) {
- p=new PayloadFactory.HeartbeatPayload();
- long id=r.nextLong();
- m=new Message(channel.getLocalLocator(),channel.getRemoteLocator(),id,p);
- timeMap.put(new Long(id),new Long(System.currentTimeMillis()));
- senderMap.put(new Long(id),me);
+ p = new PayloadFactory.HeartbeatPayload();
+ long id = r.nextLong();
+ m = new Message(channel.getLocalLocator(), channel.getRemoteLocator(), id, p);
+ timeMap.put(new Long(id), new Long(System.currentTimeMillis()));
+ senderMap.put(new Long(id), me);
channel.sendMessage(m);
- int ms=r.nextInt(MAX_SLEEP_TIME_MS);
+ int ms = r.nextInt(MAX_SLEEP_TIME_MS);
Thread.yield();
Thread.sleep(ms);
synchronized (deathList) {
@@ -82,7 +84,7 @@
}
}
//did somebody close this?
- if (channel==null) {
+ if (channel == null) {
return;
}
}
@@ -95,34 +97,34 @@
}
public void handleMessage(Message message, TCPChannel sourceChannel) throws NoSuchDestinationException {
- Long id=new Long(message.getSpaceID());
- long now=System.currentTimeMillis();
+ Long id = new Long(message.getSpaceID());
+ long now = System.currentTimeMillis();
if (!timeMap.containsKey(id)) {
- System.out.println("Can't find id in time map! Ignoring id:"+id);
+ System.out.println("Can't find id in time map! Ignoring id:" + id);
return;
}
- Long before=(Long)timeMap.get(id);
- long diff = now-before.longValue();
- double secs = ((double)diff)/1000.0;
+ Long before = (Long) timeMap.get(id);
+ long diff = now - before.longValue();
+ double secs = ((double) diff) / 1000.0;
synchronized (totalTimeLock) {
- totalTime+=secs;
- totalSamples+=1.0;
+ totalTime += secs;
+ totalSamples += 1.0;
}
- if (r.nextInt(100)==0) {
+ if (r.nextInt(100) == 0) {
double avg;
synchronized (totalTimeLock) {
- avg=totalTime/totalSamples;
+ avg = totalTime / totalSamples;
}
- System.out.println(""+ channel.getLocalLocator() +" Sample Turnaround time on heartbeat:"+secs+" and avg:"+avg);
- }
- if (secs>THRESHOLD_DANGER) {
- boolean cull=false;
-
+ System.out.println("" + channel.getLocalLocator() + " Sample Turnaround time on heartbeat:" + secs + " and avg:" + avg);
+ }
+ if (secs > THRESHOLD_DANGER) {
+ boolean cull = false;
+
synchronized (warningCounterLock) {
warningCounter++;
- if (warningCounter>THRESHOLD_TERMINATE) {
- cull=true;
- warningCounter=0;
+ if (warningCounter > THRESHOLD_TERMINATE) {
+ cull = true;
+ warningCounter = 0;
}
}
//not enough to convince us to blow up somebody?
@@ -130,10 +132,10 @@
return;
}
//ok, the sender of the message should die if it took too long...
- Long die = (Long)senderMap.get(id);
+ Long die = (Long) senderMap.get(id);
synchronized (deathList) {
if (!deathList.contains(die)) {
- System.out.println("Killing sender "+die+" because of too much time elapsed:"+secs);
+ System.out.println("Killing sender " + die + " because of too much time elapsed:" + secs);
deathList.add(die);
}
}
@@ -141,6 +143,6 @@
}
public void channelClosed(TCPChannel channel) {
- System.out.println("Got a message about closing channel:"+channel.hashCode()+ " vs. "+this.channel.hashCode());
+ System.out.println("Got a message about closing channel:" + channel.hashCode() + " vs. " + this.channel.hashCode());
}
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/SenderQueue.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/SenderQueue.java 2008-03-11 17:41:45 UTC (rev 788)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/SenderQueue.java 2008-03-11 23:18:53 UTC (rev 789)
@@ -14,26 +14,25 @@
package com.ogoglio.message;
+import com.ogoglio.message.plugin.MessageStack;
+import com.ogoglio.util.BlockingQueue;
+
import java.io.IOException;
-import com.ogoglio.message.proto.AsyncProto;
-import com.ogoglio.util.BlockingQueue;
-import com.ogoglio.util.Log;
-
public class SenderQueue {
private SenderThread senderThread = new SenderThread();
private BlockingQueue messageQueue = new BlockingQueue();
- private AsyncProto clientProto;
+ private MessageStack clientStack;
private boolean cleaned = false;
- public SenderQueue(AsyncProto clientProto, int maxSize) {
+ public SenderQueue(MessageStack clientStack, int maxSize) {
messageQueue.setMaxSize(maxSize);
- this.clientProto = clientProto;
+ this.clientStack = clientStack;
try {
- this.clientProto.prepareOutput();
+ this.clientStack.prepareOutput();
} catch (IOException e) {
throw new IllegalStateException("Could not get socket output stream: " + e);
}
@@ -46,7 +45,7 @@
public void cleanup() {
cleaned = true;
- clientProto.shutdown();
+ clientStack.shutdown();
if (messageQueue != null) {
messageQueue.close();
}
@@ -57,10 +56,11 @@
}
private void unsafeSendMessage(Message message) {
- String messageString = message.toString();
- Command command = new Command(Command.MESSAGE, messageString.length());
+// String messageString = message.toString();
+// Command command = new Command(Command.MESSAGE, messageString.length());
try {
- clientProto.sendMessage(command.toString(),messageString);
+// clientStack.sendMessage(command.toString(),messageString);
+ clientStack.sendMessage(message);
} catch (IOException e) {
if (!cleaned) {
throw new IllegalStateException("Error writing to client:" + message);
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/TCPChannel.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/TCPChannel.java 2008-03-11 17:41:45 UTC (rev 788)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/TCPChannel.java 2008-03-11 23:18:53 UTC (rev 789)
@@ -14,15 +14,15 @@
package com.ogoglio.message;
-import com.ogoglio.message.proto.AsyncProto;
+import com.ogoglio.message.plugin.MessageStack;
import com.ogoglio.message.proto.Locator;
-import com.ogoglio.util.Log;
import com.ogoglio.util.BlockingQueue.QueueClosedException;
import com.ogoglio.util.BlockingQueue.QueueOverflowException;
+import com.ogoglio.util.Log;
public class TCPChannel implements TCPMessageReader.Listener {
- private AsyncProto clientProto = null;
+ private MessageStack clientStack = null;
// private String remoteHostName = null;
@@ -40,12 +40,12 @@
private boolean ensureOrigin = false;
- public TCPChannel(AsyncProto proto, MessageHandler message_handler, boolean ensureOrigin,
+ public TCPChannel(MessageStack stack, MessageHandler message_handler, boolean ensureOrigin,
Listener listener, boolean needAReaderThread, String debugInfo) {
- this.clientProto= proto;
- //remoteHostName = clientProto.getRemoteAddress().getAddress().getHostAddress();
- //remoteHostPort = clientProto.getRemoteAddress().getPort();
+ this.clientStack = stack;
+ //remoteHostName = clientStack.getRemoteAddress().getAddress().getHostAddress();
+ //remoteHostPort = clientStack.getRemoteAddress().getPort();
if (message_handler == null) {
throw new IllegalArgumentException("bad message handler " + message_handler);
}
@@ -57,14 +57,14 @@
this.listener = listener;
// TODO Don't spand two threads for each socket! No effing way!
- senderQueue = new SenderQueue(clientProto, 1000); //TODO what should the max queue size be?
+ senderQueue = new SenderQueue(clientStack, 1000); //TODO what should the max queue size be?
senderQueue.start(debugInfo);
//this is a wee bit hairy. all clients need a reader thread. servers need a reader
//thread depending on their protocol.
if (needAReaderThread) {
- readerThread = new TCPMessageReader(clientProto, message_handler, this);
+ readerThread = new TCPMessageReader(clientStack, message_handler, this);
readerThread.setName("tcp-reader-"+debugInfo+"-"+readerThread.getId());
readerThread.start();
}
@@ -72,19 +72,19 @@
this.messageHandler=message_handler;
}
- public void clientReady(AsyncProto newlyConnectedProto) {
- Log.debug("Client connected from: "+newlyConnectedProto.getRemoteLocator());
+ public void clientReady(MessageStack newlyConnectedStack) {
+ Log.debug("Client connected from: "+newlyConnectedStack.getRemoteLocator());
}
public interface Listener {
public void channelClosed(TCPChannel channel);
}
public Locator getLocalLocator() {
- return clientProto.getLocalLocator();
+ return clientStack.getLocalLocator();
}
public Locator getRemoteLocator() {
- return clientProto.getRemoteLocator();
+ return clientStack.getRemoteLocator();
}
public void cleanup() {
@@ -108,26 +108,26 @@
public void sendMessage(Message message) throws NoSuchDestinationException {
if(message.getProxy() != null) {
- if (!message.getProxy().equals(clientProto.getRemoteLocator())) {
+ if (!message.getProxy().equals(clientStack.getRemoteLocator())) {
throw new NoSuchDestinationException("Passed a message to a TCPChannel with the wrong proxy: " + message.getProxy());
}
- } else if (!message.getDestination().equals(clientProto.getRemoteLocator())){
- throw new NoSuchDestinationException("Passed a message to a TCPChannel with the wrong destination: " + message.getDestination() + " but should be " + clientProto.getRemoteLocator());
+ } else if (!message.getDestination().equals(clientStack.getRemoteLocator())){
+ throw new NoSuchDestinationException("Passed a message to a TCPChannel with the wrong destination: " + message.getDestination() + " but should be " + clientStack.getRemoteLocator());
}
try {
senderQueue.sendMessage(message);
} catch (QueueOverflowException e) {
- Log.error("Queue overflow: " + clientProto.getRemoteLocator(),e);
+ Log.error("Queue overflow: " + clientStack.getRemoteLocator(),e);
cleanup();
} catch (QueueClosedException e) {
- Log.error("Queue closed: " + clientProto.getRemoteLocator(),e);
+ Log.error("Queue closed: " + clientStack.getRemoteLocator(),e);
cleanup();
}
}
public String toString() {
- return "TCPChannel from " + clientProto.getLocalLocator() + " to " +clientProto.getRemoteLocator();
+ return "TCPChannel from " + clientStack.getLocalLocator() + " to " + clientStack.getRemoteLocator();
}
public void socketClosed() {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/TCPMessageReader.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/TCPMessageReader.java 2008-03-11 17:41:45 UTC (rev 788)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/TCPMessageReader.java 2008-03-11 23:18:53 UTC (rev 789)
@@ -14,12 +14,12 @@
package com.ogoglio.message;
-import java.io.IOException;
-
-import com.ogoglio.message.proto.AsyncProto;
+import com.ogoglio.message.plugin.MessageStack;
import com.ogoglio.message.proto.NegativeReadValueException;
import com.ogoglio.util.Log;
+import java.io.IOException;
+
public class TCPMessageReader extends Thread {
private boolean cleaned = false;
@@ -32,16 +32,16 @@
//private int remotePort = -1;
- private AsyncProto clientProto=null;
+ private MessageStack clientStack =null;
- public TCPMessageReader(AsyncProto clientProto, MessageHandler messageHandler, TCPChannel channel) {
+ public TCPMessageReader(MessageStack clientStack, MessageHandler messageHandler, TCPChannel channel) {
super("TCPMessageReader");
setDaemon(true);
- if (clientProto == null) {
- throw new IllegalArgumentException("bad protocol to TCPMessageReader" + clientProto);
+ if (clientStack == null) {
+ throw new IllegalArgumentException("bad protocol to TCPMessageReader" + clientStack);
}
- //remoteHostName = clientProto.getRemoteAddress().getAddress().getHostAddress();
- //remotePort = clientProto.getRemoteAddress().getPort();
+ //remoteHostName = clientStack.getRemoteAddress().getAddress().getHostAddress();
+ //remotePort = clientStack.getRemoteAddress().getPort();
if (messageHandler == null) {
throw new IllegalArgumentException("bad message handler: " + messageHandler);
}
@@ -50,10 +50,10 @@
throw new IllegalArgumentException("bad listener " + channel);
}
this.channel = channel;
- this.clientProto = clientProto;
+ this.clientStack = clientStack;
try {
- this.clientProto.prepareInput();
+ this.clientStack.prepareInput();
} catch (IOException e) {
throw new IllegalStateException("Couldn't get client socket input stream " + e);
}
@@ -67,28 +67,27 @@
public void cleanup() {
cleaned = true;
- clientProto.shutdown();
+ clientStack.shutdown();
}
public void run() {
try {
while (!cleaned) {
- String msg=clientProto.readLine();
- if (msg!=null) {
- //Log.info("TCP Message Reader:"+msg);
- Message message = Message.parseMessage(msg);
- if (channel.ensureOrigin()) {
- message.setOrigin(clientProto.getRemoteLocator());
- //message.getOrigin().setHost(remoteHostName);
- //message.getOrigin().setPort(remotePort);
- }
- try {
- messageHandler.handleMessage(message, channel);
- } catch (Throwable e) {
- Log.error("Error handling our message",e);
- e.printStackTrace();
- }
+// String msg=clientStack.readLine();
+ //Log.info("TCP Message Reader:"+msg);
+// Message message = Message.parseMessage(msg);
+ Message message = clientStack.readMessage();
+ if (channel.ensureOrigin()) {
+ message.setOrigin(clientStack.getRemoteLocator());
+ //message.getOrigin().setHost(remoteHostName);
+ //message.getOrigin().setPort(remotePort);
}
+ try {
+ messageHandler.handleMessage(message, channel);
+ } catch (Throwable e) {
+ Log.error("Error handling our message",e);
+ e.printStackTrace();
+ }
}
} catch (NegativeReadValueException e) {
//Log.info("Negative value from read, assuming server closed connection!");
Added: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/ChunkedStreamNetworkTransporter.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/ChunkedStreamNetworkTransporter.java (rev 0)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/ChunkedStreamNetworkTransporter.java 2008-03-11 23:18:53 UTC (rev 789)
@@ -0,0 +1,132 @@
+/* Copyright 2008, The Electric Sheep Company, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
+package com.ogoglio.message.plugin;
+
+import com.ogoglio.message.proto.NegativeReadValueException;
+import com.ogoglio.util.Log;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * A NetworkTransporter plugin class that uses arbitrary input/output streams to read and write
+ * network traffic. HTTP chunking information is written and parsed in order to communicate message
+ * lengths.
+ *
+ * @author Matt Kimmel
+ */
+public class ChunkedStreamNetworkTransporter extends StreamNetworkTransporter {
+ /**
+ * Construct an instance of ChunkedStreamNetworkTransporter using the given streams.
+ *
+ * @param input Stream to read incoming network traffic from.
+ * @param output Stream to write outgoing network traffic to.
+ */
+ public ChunkedStreamNetworkTranspor...
[truncated message content] |
|
From: <tre...@us...> - 2008-03-14 21:43:02
|
Revision: 791
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=791&view=rev
Author: trevorolio
Date: 2008-03-14 14:43:02 -0700 (Fri, 14 Mar 2008)
Log Message:
-----------
Fixed up the populate mojo so that it's smarter about updating templates and spaces which already exist instead of deleting them and building a new one from scratch.
Also, fixed a shutdown error caused due to a bad cast in CometChannelManager.
Modified Paths:
--------------
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometChannelManager.java
Modified: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java 2008-03-13 22:05:00 UTC (rev 790)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java 2008-03-14 21:43:02 UTC (rev 791)
@@ -7,7 +7,6 @@
import java.io.InputStream;
import java.text.DateFormat;
import java.text.ParseException;
-import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
@@ -22,6 +21,7 @@
import org.apache.maven.plugin.MojoExecutionException;
+import com.ogoglio.client.SpaceDuplicator;
import com.ogoglio.client.WebAPIClient;
import com.ogoglio.util.StreamUtils;
import com.ogoglio.xml.DoorDocument;
@@ -29,7 +29,6 @@
import com.ogoglio.xml.SettingDocument;
import com.ogoglio.xml.SpaceDocument;
import com.ogoglio.xml.TemplateDocument;
-import com.ogoglio.xml.TemplateSupportFileDocument;
import com.ogoglio.xml.ThingDocument;
/**
@@ -37,7 +36,9 @@
*/
public class PopulateMojo extends OgServiceMojoBase {
public static final String PROPERTIES_FILE_NAME = "template.properties";
-
+
+ public static final String[] RESOURCE_FILES_EXTENSIONS = { "js", "gif", "jpg", "png", "mtl" };
+
private Map<Long, Long> templateIdMap = new HashMap<Long, Long>();
private Map<Long, SpaceDocument> localSpaces = new HashMap<Long, SpaceDocument>();
@@ -65,9 +66,9 @@
for (int i = 0; i < templates.length; ++i) {
File candidate = templates[i];
if (candidate.getName().startsWith(TEMPLATE_PREFIX)) {
- uploadTemplate(client, candidate, existingServerTemplates);
+ handleTemplate(client, candidate, existingServerTemplates);
} else if (candidate.getName().startsWith(SPACE_PREFIX)) {
- readSpace(client, candidate, i);
+ handleSpace(client, candidate, i);
} else {
if (!candidate.getName().equals(".svn")) {
getLog().warn("Unable to process in populate:" + candidate.getAbsolutePath());
@@ -103,38 +104,28 @@
}
private void patchSpaces(WebAPIClient client) throws MojoExecutionException {
- SpaceDocument fakeSpaceDoc, realSpaceDoc;
Iterator<Long> iter = localSpaces.keySet().iterator();
while (iter.hasNext()) {
try {
long localModTime = iter.next();
- fakeSpaceDoc = localSpaces.get(localModTime);
- if (serverSpaceNameToSpaceDoc.containsKey(fakeSpaceDoc.getDisplayName())) {
- realSpaceDoc = serverSpaceNameToSpaceDoc.get(fakeSpaceDoc.getDisplayName());
-
- Date fileModified = new Date(localModTime);
- Date serverModified = TemplateSupportFileDocument.fmt.parse(realSpaceDoc.getLastModifiedAsUTC());
- if (fileModified.before(serverModified)) {
- getLog().info("Not patching space document " + realSpaceDoc.getDisplayName() + ". Server copy is newer.");
- continue;
- } else {
- //need to torch the server version b/c it's too old
- client.deleteSpace(realSpaceDoc.getSpaceID());
- getLog().info("Deleted old server version of " + realSpaceDoc.getDisplayName() + " [" + realSpaceDoc.getSpaceID() + "]");
+ SpaceDocument fakeSpaceDoc = localSpaces.get(localModTime);
+ SpaceDocument realSpaceDoc = serverSpaceNameToSpaceDoc.get(fakeSpaceDoc.getDisplayName());
+ if (realSpaceDoc != null) {
+ SpaceDuplicator.emptySpace(realSpaceDoc.getSpaceID(), client, true);
+ } else {
+ realSpaceDoc = client.createSpace(fakeSpaceDoc.getDisplayName());
+ if (realSpaceDoc == null) {
+ throw new MojoExecutionException("Could not create a space for population: " + fakeSpaceDoc.getDisplayName());
}
}
- realSpaceDoc = client.createSpace(fakeSpaceDoc.getDisplayName());
- if (realSpaceDoc == null) {
- throw new MojoExecutionException("Could not create a space for population: " + fakeSpaceDoc.getDisplayName());
- }
long realSpaceID = realSpaceDoc.getSpaceID();
client.setSpaceMaxGuests(realSpaceID, fakeSpaceDoc.getMaxGuests());
client.setSpacePublished(realSpaceID, fakeSpaceDoc.isPublished());
client.setSpaceSeaLevel(realSpaceID, fakeSpaceDoc.getSeaLevel());
client.setSpaceDisplaySea(realSpaceID, fakeSpaceDoc.getDisplaySea());
client.setSpaceBackgroundColor(realSpaceID, fakeSpaceDoc.getBackgroundColor());
-
+
ThingDocument things[] = fakeSpaceDoc.getThingDocuments();
for (int j = 0; j < things.length; ++j) {
ThingDocument thing = things[j];
@@ -159,15 +150,13 @@
}
getLog().info("Patched up space " + realSpaceDoc.getDisplayName() + " [" + realSpaceDoc.getSpaceID() + "]");
- } catch (ParseException e) {
- throw new MojoExecutionException("Parse exception patching space", e);
} catch (IOException e) {
throw new MojoExecutionException("IOException patching space", e);
}
}
}
- private void readSpace(WebAPIClient client, File candidate, int fileNumber) throws MojoExecutionException {
+ private void handleSpace(WebAPIClient client, File candidate, int fileNumber) throws MojoExecutionException {
String name = candidate.getName();
String num = name.substring(SPACE_PREFIX.length());
int spaceFakeId = -189;
@@ -184,10 +173,10 @@
String docContent = StreamUtils.readInput(inputStream);
SpaceDocument doc = new SpaceDocument(XMLElement.parseElementFromString(docContent));
long timeStamp = candidate.lastModified();
- if(localSpaces.get(timeStamp) != null){
- // Rare occurrence: sometimes files checked out by SVN on MacOS X end up having exactly the same timestamp
- // Simply increment it by a few milliseconds and use the new value for the index
- timeStamp = candidate.lastModified() + fileNumber;
+ if (localSpaces.get(timeStamp) != null) {
+ // Rare occurrence: sometimes files checked out by SVN on MacOS X end up having exactly the same timestamp
+ // Simply increment it by a few milliseconds and use the new value for the index
+ timeStamp = candidate.lastModified() + fileNumber;
}
localSpaces.put(timeStamp, doc);
inputStream.close();
@@ -197,69 +186,59 @@
}
- private void uploadTemplate(WebAPIClient client, File candidate, Map<String, TemplateDocument> existing) throws MojoExecutionException {
- String name = candidate.getName();
- long templateFakeId = dirNameToTemplateNumber(candidate);
+ private void handleTemplate(WebAPIClient client, File candidate, Map<String, TemplateDocument> existing) throws MojoExecutionException {
+ try {
+ long templateFakeId = dirNameToTemplateNumber(candidate);
- File[] objs = candidate.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".obj");
+ File[] objs = candidate.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".obj");
+ }
+ });
+ if (objs.length != 1) {
+ throw new MojoExecutionException("Badly formed directory " + candidate.getName() + ". Should have 1 obj file but has " + objs.length);
}
- });
- if (objs.length != 1) {
- throw new MojoExecutionException("Badly formed directory " + name + ". Should have 1 obj file but has " + objs.length);
- }
- String templateVisibleName = fileToTemplateName(objs[0]);
- if (!checkFileTemplateIsNewer(client, candidate, existing, templateVisibleName)) {
- getLog().info("Not uploading template " + templateVisibleName + ". Server copy is newer.");
- templateIdMap.put(templateFakeId, existing.get(templateVisibleName).getTemplateID());
- return;
- } else {
- getLog().info("Uploading template #" + templateFakeId + " to " + serviceURI);
- }
+ String templateVisibleName = fileToTemplateName(objs[0]);
+ long templateRealID = checkForExistingTemplate(client, existing, templateVisibleName);
+ TemplateDocument doc = null;
+ if (templateRealID == -1) {
+ doc = fileNameToTemplateDocument(client, objs[0]);
+ getLog().info("Uploading new template with fakeID [" + templateFakeId + "] (" + templateVisibleName + ") to " + serviceURI);
+ } else {
+ doc = client.getTemplateDocument(client.getAuthenticator().getUsername(), templateRealID);
+ getLog().info("Updating existing template with fakeID [" + templateFakeId + "] (" + templateVisibleName + ") to " + serviceURI);
+ //TODO delete the files we no longer need from the existing template
+ }
- try {
- TemplateDocument doc = fileNameToTemplateDocument(client, objs[0]);
-
+ templateIdMap.put(templateFakeId, doc.getTemplateID());
+ Properties templateProperties = new Properties();
File propertiesFile = new File(candidate, PROPERTIES_FILE_NAME);
if (propertiesFile.exists() && propertiesFile.canRead()) {
- Properties templateProperties = new Properties();
templateProperties.load(new FileInputStream(propertiesFile));
- if (templateProperties.size() > 0) {
- updateTemplateDoc(client, doc, templateProperties);
- }
}
+ updateTemplateDoc(client, doc, templateProperties);
InputStream objStream = new FileInputStream(objs[0]);
client.uploadTemplateGeometryStream(username, doc.getTemplateID(), 0, objStream);
- templateIdMap.put(templateFakeId, doc.getTemplateID());
- getLog().info("Created template from " + objs[0].getName() + " [" + templateFakeId + " -> " + doc.getTemplateID() + "]");
-
- File[] notObjs = candidate.listFiles(new FilenameFilter() {
+ File[] resourceFiles = candidate.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
- return !name.endsWith(".obj");
+ for (int i = 0; i < RESOURCE_FILES_EXTENSIONS.length; i++) {
+ if (name != null && name.endsWith("." + RESOURCE_FILES_EXTENSIONS[i])) {
+ return true;
+ }
+ }
+ return false;
}
});
- for (int i = 0; i < notObjs.length; ++i) {
- File supportFile = notObjs[i];
- String supportName = supportFile.getName();
- if (supportFile.getName().endsWith(".js")) {
- String script = StreamUtils.readInput(new FileInputStream(supportFile));
+ for (int i = 0; i < resourceFiles.length; ++i) {
+ if (resourceFiles[i].getName().endsWith(".js")) {
+ String script = StreamUtils.readInput(new FileInputStream(resourceFiles[i]));
client.updateTemplateScript(username, doc.getTemplateID(), script);
- getLog().info("Uploaded script file:" + supportName);
} else {
- if ((!(supportName.endsWith(".gif"))) && (!(supportName.endsWith(".jpg"))) && (!(supportName.endsWith(".png"))) && (!(supportName.endsWith(".mtl")))) {
-
- if ((!(supportName.endsWith(".blend"))) && (!(supportName.endsWith(".3DS"))) && (!(supportName.endsWith(".txt"))) && (!(supportName.equals(".svn"))) && !supportName.equals(PROPERTIES_FILE_NAME)) {
- getLog().warn("Don't know what to do with file " + supportName + ". Ignoring.");
- }
- continue;
- }
- FileInputStream supportStream = new FileInputStream(supportFile);
- client.uploadTemplateResourceStream(username, doc.getTemplateID(), supportName, supportStream);
- getLog().info("Uploaded support file:" + supportName);
+ FileInputStream supportStream = new FileInputStream(resourceFiles[i]);
+ client.uploadTemplateResourceStream(username, doc.getTemplateID(), resourceFiles[i].getName(), supportStream);
}
}
@@ -269,151 +248,54 @@
}
private void updateTemplateDoc(WebAPIClient client, TemplateDocument doc, Properties templateProperties) throws IOException {
- String[] keys = (String[])templateProperties.keySet().toArray(new String[0]);
- double rotX = 0, rotY = 0, rotZ = 0;
-
- for (int i = 0; i < keys.length; i++) {
- if("seat".equals(keys[i])){
- doc.setSeat("true".equals(templateProperties.get(keys[i])));
- } else if("seatX".equals(keys[i])){
- doc.setSeatPosition(Double.parseDouble((String)templateProperties.get(keys[i])), doc.getSeatPosition().y, doc.getSeatPosition().z);
- } else if("seatY".equals(keys[i])){
- doc.setSeatPosition(doc.getSeatPosition().x, Double.parseDouble((String)templateProperties.get(keys[i])), doc.getSeatPosition().z);
- } else if("seatZ".equals(keys[i])){
- doc.setSeatPosition(doc.getSeatPosition().x, doc.getSeatPosition().y, Double.parseDouble((String)templateProperties.get(keys[i])));
- } else if("seatRotX".equals(keys[i])){
- rotX = Double.parseDouble(templateProperties.getProperty(keys[i]));
- } else if("seatRotY".equals(keys[i])){
- rotY = Double.parseDouble(templateProperties.getProperty(keys[i]));
- } else if("seatRotZ".equals(keys[i])){
- rotZ = Double.parseDouble(templateProperties.getProperty(keys[i]));
- } else if("attachment".equals(keys[i])){
- doc.setAttachment("true".equals(templateProperties.get(keys[i])));
- } else {
- System.err.println("Unknown properties in template.properties: " + keys[i]);
- }
- }
-
- if(rotX != 0 || rotY != 0 || rotZ != 0){
- Transform3D transform = new Transform3D();
- transform.setEuler(new Vector3d(rotX, rotY, rotZ));
- Quat4d quat = new Quat4d();
- transform.get(quat);
- doc.setSeatRotation(quat);
- }
+ if (templateProperties == null) {
+ doc.setAttachment(false);
+ doc.setSeat(false);
+ doc.setSeatPosition(0, 0, 0);
+ doc.setSeatRotation(0, 0, 0, 0);
+ } else {
+ String[] keys = (String[]) templateProperties.keySet().toArray(new String[0]);
+ double rotX = 0, rotY = 0, rotZ = 0;
- getLog().info("Updating template " + doc.getDisplayName() + " with properties from template.properties");
- client.updateTemplate(doc);
- }
-
- private boolean checkFileTemplateIsNewer(WebAPIClient client, File candidate, Map<String, TemplateDocument> existing, String displayName) throws MojoExecutionException {
- //is it even on server?
- if (!existing.containsKey(displayName)) {
- return true;
- }
-
- TemplateDocument serverCopy = existing.get(displayName);
-
- //first check support files
- File[] notObjs = candidate.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return !name.endsWith(".obj");
+ for (int i = 0; i < keys.length; i++) {
+ if ("seat".equals(keys[i])) {
+ doc.setSeat("true".equals(templateProperties.get(keys[i])));
+ } else if ("seatX".equals(keys[i])) {
+ doc.setSeatPosition(Double.parseDouble((String) templateProperties.get(keys[i])), doc.getSeatPosition().y, doc.getSeatPosition().z);
+ } else if ("seatY".equals(keys[i])) {
+ doc.setSeatPosition(doc.getSeatPosition().x, Double.parseDouble((String) templateProperties.get(keys[i])), doc.getSeatPosition().z);
+ } else if ("seatZ".equals(keys[i])) {
+ doc.setSeatPosition(doc.getSeatPosition().x, doc.getSeatPosition().y, Double.parseDouble((String) templateProperties.get(keys[i])));
+ } else if ("seatRotX".equals(keys[i])) {
+ rotX = Double.parseDouble(templateProperties.getProperty(keys[i]));
+ } else if ("seatRotY".equals(keys[i])) {
+ rotY = Double.parseDouble(templateProperties.getProperty(keys[i]));
+ } else if ("seatRotZ".equals(keys[i])) {
+ rotZ = Double.parseDouble(templateProperties.getProperty(keys[i]));
+ } else if ("attachment".equals(keys[i])) {
+ doc.setAttachment("true".equals(templateProperties.get(keys[i])));
+ } else {
+ System.err.println("Unknown properties in template.properties: " + keys[i]);
+ }
}
- });
- //walk support files
- for (int i = 0; i < notObjs.length; ++i) {
- File supportFile = notObjs[i];
- String supportName = supportFile.getName();
- String modTime = null;
- if (supportName.endsWith(".js")) {
- if (!serverCopy.hasScriptFile()) {
- getLog().info("You have added a javascript file since the last server update.");
- return true;
- }
- modTime = serverCopy.getScriptModifiedTime();
- } else if ((!(supportName.endsWith(".gif"))) && (!(supportName.endsWith(".jpg"))) && (!(supportName.endsWith(".png"))) && (!(supportName.endsWith(".mtl")))) {
- continue;
- } else {
- modTime = serverCopy.getSupportFileModifiedTime(supportName);
+ if (rotX != 0 || rotY != 0 || rotZ != 0) {
+ Transform3D transform = new Transform3D();
+ transform.setEuler(new Vector3d(rotX, rotY, rotZ));
+ Quat4d quat = new Quat4d();
+ transform.get(quat);
+ doc.setSeatRotation(quat);
}
- try {
- //if there is no modtime, then the file doesn't exist on the server
- if (modTime == null) {
- getLog().info("Added support file " + supportName + " to template since server copy created");
- client.deleteTemplate(serverCopy.getTemplateID());
- return true;
- }
- //modtime is now set to what the server thinks the modtime is
- Date serverTime = fmt.parse(modTime);
- if (serverTime.before(new Date(supportFile.lastModified()))) {
- getLog().info("File " + supportFile + " has been modified since last upload to server...");
- client.deleteTemplate(serverCopy.getTemplateID());
- return true; //we can bail out now
- }
- } catch (IOException e) {
- throw new MojoExecutionException("unable to delete server copy of template " + serverCopy.getDisplayName(), e);
- } catch (ParseException e) {
- throw new MojoExecutionException("unable to comprehend modified time", e);
- }
}
+ client.updateTemplate(doc);
+ }
- //at this point we've checked the files that exist on the client side, but we might
- //have deleted one
- boolean destroyServerTemplate = false;
- //special case for js
- if (serverCopy.hasScriptFile()) {
- File[] jsFiles = candidate.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".js");
- }
- });
- if (jsFiles.length > 1) {
- throw new MojoExecutionException("Only one script file is allowed per template (" + candidate.getPath() + ")");
- }
- if (jsFiles.length == 0) {
- getLog().info("Javascript file removed since last server update.");
- destroyServerTemplate = true;
- }
+ private long checkForExistingTemplate(WebAPIClient client, Map<String, TemplateDocument> existing, String displayName) throws MojoExecutionException {
+ TemplateDocument doc = existing.get(displayName);
+ if (doc != null) {
+ return doc.getTemplateID();
}
- //now support files
- String name[] = serverCopy.getAllSupportFileNames();
- for (int i = 0; i < name.length; ++i) {
- File f = new File(candidate, name[i]);
- if (!f.exists()) {
- getLog().info("You have removed the file " + name[i] + " from the template.");
- destroyServerTemplate = true;
- break;
- }
- }
- //check the obj file
- File[] objs = candidate.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".obj");
- }
- });
- if (objs.length != 1) {
- throw new MojoExecutionException("You should have exactly one object (geometry) file per template directory (was " + objs.length + ")");
- }
- try {
- Date fileMod = new Date(objs[0].lastModified());
- Date onServerMod = fmt.parse(serverCopy.getGeometryModifiedTime(0));
- if (onServerMod.before(fileMod)) {
- getLog().info("Local geometry file is newer than server copy.");
- destroyServerTemplate = true;
- }
- //implement destruction
- if (destroyServerTemplate) {
- client.deleteTemplate(serverCopy.getTemplateID());
- return true;
- } else {
- return false;
- }
- } catch (IOException e) {
- throw new MojoExecutionException("unable to delete server copy of template " + serverCopy.getDisplayName(), e);
- } catch (ParseException e) {
- throw new MojoExecutionException("unable to comprehend modified time", e);
- }
+ return -1;
}
}
\ No newline at end of file
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java 2008-03-13 22:05:00 UTC (rev 790)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java 2008-03-14 21:43:02 UTC (rev 791)
@@ -104,9 +104,17 @@
}
public static void emptySpace(long spaceID, WebAPIClient client) throws IOException {
+ emptySpace(spaceID, client, false);
+ }
+
+ public static void emptySpace(long spaceID, WebAPIClient client, boolean deleteRemovedPossessions) throws IOException {
ThingDocument[] thingDocs = client.getThingDocuments(spaceID);
for (int i = 0; i < thingDocs.length; i++) {
+ long possessionID = thingDocs[i].getPossessionID();
client.removePossessionFromSpace(thingDocs[i].getPossessionID());
+ if(deleteRemovedPossessions){
+ client.deletePossession(possessionID);
+ }
}
DoorDocument[] doorDocs = client.getDoorDocuments(spaceID);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometChannelManager.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometChannelManager.java 2008-03-13 22:05:00 UTC (rev 790)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/message/server/CometChannelManager.java 2008-03-14 21:43:02 UTC (rev 791)
@@ -93,7 +93,7 @@
public void shutdown() {
Iterator iter = sessionToChannel.keySet().iterator();
while (iter.hasNext()) {
- String key = (String) iter.next();
+ CometEvent key = (CometEvent)iter.next();
TCPChannel channel = (TCPChannel) sessionToChannel.get(key);
channel.cleanup();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2008-03-21 22:45:00
|
Revision: 794
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=794&view=rev
Author: iansmith
Date: 2008-03-21 15:44:46 -0700 (Fri, 21 Mar 2008)
Log Message:
-----------
Improved error handling in PopulateMojo (detect more error cases).
Fixed small possible bug in SpaceDuplicator (negative value).
Added some better error information who object insertion into a space goes wrong (better error messages).
Modified Paths:
--------------
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java
Modified: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java 2008-03-19 03:05:25 UTC (rev 793)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java 2008-03-21 22:44:46 UTC (rev 794)
@@ -131,6 +131,10 @@
ThingDocument thing = things[j];
PossessionDocument possDoc = client.createPossession(templateIdMap.get(thing.getTemplateID()));
possDoc = client.addPossessionToSpace(possDoc.getPossessionID(), realSpaceDoc.getSpaceID());
+ if ((possDoc.getSpaceID()==PossessionDocument.NO_SPACE)||
+ (possDoc.getThingID()==PossessionDocument.NO_THING)) {
+ throw new MojoExecutionException("Unable to make a copy of possession [adding]:"+possDoc);
+ }
ThingDocument newThingDoc = client.getThingDocument(realSpaceDoc.getSpaceID(), possDoc.getThingID());
newThingDoc.setOrientation(thing.getOrientation());
newThingDoc.setTranslation(thing.getTranslation());
@@ -151,6 +155,7 @@
getLog().info("Patched up space " + realSpaceDoc.getDisplayName() + " [" + realSpaceDoc.getSpaceID() + "]");
} catch (IOException e) {
+ e.printStackTrace();
throw new MojoExecutionException("IOException patching space", e);
}
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java 2008-03-19 03:05:25 UTC (rev 793)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java 2008-03-21 22:44:46 UTC (rev 794)
@@ -56,7 +56,7 @@
PossessionDocument[] possDocuments = client.getPossessionDocuments();
PossessionDocument possToUse = null;
for (int j = 0; j < possDocuments.length; j++) {
- if (possDocuments[j].getThingID() == -1 && possDocuments[j].getTemplateID() == thingDocs[i].getTemplateID()) {
+ if (possDocuments[j].getThingID() == PossessionDocument.NO_THING && possDocuments[j].getTemplateID() == thingDocs[i].getTemplateID()) {
possToUse = possDocuments[j];
break;
}
@@ -108,27 +108,49 @@
}
public static void emptySpace(long spaceID, WebAPIClient client, boolean deleteRemovedPossessions) throws IOException {
- ThingDocument[] thingDocs = client.getThingDocuments(spaceID);
- for (int i = 0; i < thingDocs.length; i++) {
- long possessionID = thingDocs[i].getPossessionID();
- client.removePossessionFromSpace(thingDocs[i].getPossessionID());
- if(deleteRemovedPossessions){
- client.deletePossession(possessionID);
+ ThingDocument[] thingDocs;
+ try {
+ thingDocs = client.getThingDocuments(spaceID);
+ } catch (IOException e) {
+ thingDocs =null;
+ System.err.println("Trying to empty space, but can't find any things! Ignoring IOException!");
+ }
+ if (thingDocs!=null){
+ for (int i = 0; i < thingDocs.length; i++) {
+ long possessionID = thingDocs[i].getPossessionID();
+ client.removePossessionFromSpace(thingDocs[i].getPossessionID());
+ if(deleteRemovedPossessions){
+ client.deletePossession(possessionID);
+ }
}
}
-
- DoorDocument[] doorDocs = client.getDoorDocuments(spaceID);
- for (int i = 0; i < doorDocs.length; i++) {
- client.deleteDoor(spaceID, doorDocs[i].getDoorID());
+ DoorDocument[] doorDocs;
+ try {
+ doorDocs = client.getDoorDocuments(spaceID);
+ } catch (IOException e) {
+ doorDocs =null;
+ System.err.println("Trying to empty space, but can't find any doors! Ignoring IOException!");
}
-
- Map settings = client.getSpaceSettings(spaceID);
- String[] keys = (String[]) settings.keySet().toArray(new String[0]);
- for (int i = 0; i < keys.length; i++) {
- client.removeSpaceSetting(spaceID, keys[i]);
+ if (doorDocs!=null) {
+ for (int i = 0; i < doorDocs.length; i++) {
+ client.deleteDoor(spaceID, doorDocs[i].getDoorID());
+ }
}
+ Map settings;
+ try {
+ settings = client.getSpaceSettings(spaceID);
+ } catch (IOException e) {
+ settings=null;
+ System.err.println("Trying to empty space, but can't find any settings! Ignoring IOException!");
+ }
+ if (settings!=null) {
+ String[] keys = (String[]) settings.keySet().toArray(new String[0]);
+ for (int i = 0; i < keys.length; i++) {
+ client.removeSpaceSetting(spaceID, keys[i]);
+ }
+ }
+
}
-
public static void main(String[] args) {
if (args.length != 4) {
printUsage();
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java 2008-03-19 03:05:25 UTC (rev 793)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java 2008-03-21 22:44:46 UTC (rev 794)
@@ -957,7 +957,6 @@
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
-
PossessionDocument updatedDoc = new PossessionDocument(parseXML(request.getInputStream()));
long oldSpaceID = record.getSpaceID();
long oldThingID = record.getThingID();
@@ -965,7 +964,6 @@
sendStringResponse(DocumentFactory.documentFromRecord(record).toString(), "text/xml", response);
return;
}
-
if (oldSpaceID != PossessionDocument.NO_SPACE) {
SpaceRecord oldSpaceRecord = SpacePersistTasks.findSpaceBySpaceID(oldSpaceID, getSessionFactory());
if (oldSpaceRecord != null) {
@@ -984,12 +982,12 @@
}
}
}
-
record = PossessionPersistTasks.update(record, updatedDoc, getSessionFactory());
if (record.getSpaceID() != PossessionDocument.NO_SPACE) {
SpaceRecord spaceRecord = SpacePersistTasks.findSpaceBySpaceID(record.getSpaceID(), getSessionFactory());
if (spaceRecord == null) {
+ Log.error("Whoa! Space record was null when looking for spaceID:"+record.getSpaceID()+"!");
record.setSpaceID(-1);
record = PossessionPersistTasks.update(record, updatedDoc, getSessionFactory());
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
@@ -997,27 +995,27 @@
}
SimRecord simRecord = SpacePersistTasks.findOrAssignSim(spaceRecord, getSessionFactory());
if (simRecord == null) {
+ Log.error("Whoa! Sim record was null when trying to get a sim for "+spaceRecord.getSpaceID());
record.setSpaceID(-1);
record = PossessionPersistTasks.update(record, updatedDoc, getSessionFactory());
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
-
TemplateRecord templateRecord = TemplatePersistTasks.findTemplateByTemplateID(record.getTemplateID(), sessionFactory);
if (templateRecord == null) {
+ Log.error("Whoa! Template record was null when looking for:"+record.getTemplateID());
record.setSpaceID(-1);
record = PossessionPersistTasks.update(record, updatedDoc, getSessionFactory());
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
-
URI thingsURI = WebAPIUtil.appendToURI(simRecord.getSimURI(), "space/" + record.getSpaceID() + "/thing/");
ThingDocument thingDoc = new ThingDocument(-1, templateRecord.getDisplayName(), templateRecord.getTemplateID(), templateRecord.getOwnerUsername(), record.getOwnerUsername(), record.getPossessionID(), new Transform3D(), null);
try {
XMLElement element = new WebAPIClientWire().sendAuthenticatedXML(thingsURI, thingDoc.toString(), "POST", null);
long thingID = element.getLongAttribute(ThingDocument.THING_ID, -1);
if (thingID == -1) {
- Log.error("Received a -1 thingID for some reason, bailing: " + element);
+ Log.error("Whoa! thing id was -1 in thing doc:"+element);
record.setSpaceID(-1);
record = PossessionPersistTasks.update(record, updatedDoc, getSessionFactory());
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
@@ -1026,6 +1024,7 @@
record.setThingID(thingID);
PossessionPersistTasks.update(record, getSessionFactory());
} catch (IOException e) {
+ Log.error("IOException putting thing in space:"+e.getMessage());
record.setSpaceID(PossessionDocument.NO_SPACE);
record = PossessionPersistTasks.update(record, updatedDoc, getSessionFactory());
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2008-03-24 19:53:40
|
Revision: 795
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=795&view=rev
Author: trevorolio
Date: 2008-03-24 12:53:28 -0700 (Mon, 24 Mar 2008)
Log Message:
-----------
Introducing a fast binary message encoder from Matt Kimmel at the Electric Sheep Company.
He also refactored the event code which was long in the tooth and needed a good kick.
Thanks, Matt!
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultiuserTests.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/MeasPerfClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/Message.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/Payload.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/PayloadFactory.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/MessageStackFactory.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/MessageStackType.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceEvent.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/message/plugin/test/MessageStackTest.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/message/plugin/test/XMLMessageEncoderTest.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SimMessageHandler.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/MessageProxy.java
Added Paths:
-----------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/payload/
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/payload/AuthenticatedPayload.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/payload/AuthenticationFailurePayload.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/payload/AuthenticationRequestPayload.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/payload/AuthenticationSuccessPayload.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/payload/HeartbeatPayload.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/payload/LoggedOutPayload.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/payload/LogoutPayload.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/payload/ProxiedSpaceEventPayload.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/payload/SpaceEventPayload.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/BinaryMementoEncodable.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/plugin/BinaryMementoMessageEncoder.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/message/plugin/test/BinaryMementoMessageEncoderTest.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/message/test/
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/message/test/MessageBinaryMementoTest.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/message/test/PayloadBinaryMementoTest.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/SpaceEventBinaryMementoTest.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2008-03-21 22:44:46 UTC (rev 794)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2008-03-24 19:53:28 UTC (rev 795)
@@ -15,6 +15,7 @@
import com.ogoglio.client.model.*;
import com.ogoglio.message.*;
+import com.ogoglio.message.payload.*;
import com.ogoglio.message.plugin.MessageStackFactory;
import com.ogoglio.util.ArgumentUtils;
import com.ogoglio.util.Log;
@@ -230,7 +231,7 @@
private void attemptToSendSpaceEventToServer(SpaceEvent event) {
try {
- Message message = new Message(messageChannel.getLocalLocator(), messageChannel.getRemoteLocator(), space.getSpaceID(), new PayloadFactory.SpaceEventPayload(event));
+ Message message = new Message(messageChannel.getLocalLocator(), messageChannel.getRemoteLocator(), space.getSpaceID(), new SpaceEventPayload(event));
messageChannel.sendMessage(message);
} catch (NoSuchDestinationException e) {
e.printStackTrace();
@@ -283,7 +284,7 @@
event.setProperty(SpaceEvent.USERNAME, accountDoc.getUsername());
event.setProperty(SpaceEvent.SOURCE, accountDoc.getUsername());
event.setSplinePath(newPath);
- Message message = new Message(messageChannel.getLocalLocator(), messageChannel.getRemoteLocator(), space.getSpaceID(), new PayloadFactory.SpaceEventPayload(event));
+ Message message = new Message(messageChannel.getLocalLocator(), messageChannel.getRemoteLocator(), space.getSpaceID(), new SpaceEventPayload(event));
try {
messageChannel.sendMessage(message);
} catch (NoSuchDestinationException e) {
@@ -309,7 +310,7 @@
}
private void sendSpaceEvent(SpaceEvent event) {
- Message message = new Message(messageChannel.getLocalLocator(), messageChannel.getRemoteLocator(), space.getSpaceID(), new PayloadFactory.SpaceEventPayload(event));
+ Message message = new Message(messageChannel.getLocalLocator(), messageChannel.getRemoteLocator(), space.getSpaceID(), new SpaceEventPayload(event));
try {
messageChannel.sendMessage(message);
} catch (NoSuchDestinationException e) {
@@ -349,8 +350,8 @@
}
private void handleMessageFromService(Message message) {
- if (message.getPayload() instanceof PayloadFactory.SpaceEventPayload) {
- SpaceEvent event = ((PayloadFactory.SpaceEventPayload) message.getPayload()).getSpaceEvent();
+ if (message.getPayload() instanceof SpaceEventPayload) {
+ SpaceEvent event = ((SpaceEventPayload) message.getPayload()).getSpaceEvent();
if (SpaceEvent.ADD_USER_EVENT.equals(event.getName())) {
BodyConfigurationDocument bodyConfigDoc = event.getBodyConfigurationDocument();
BodyConfiguration bodyConfig = null;
@@ -667,7 +668,7 @@
} else {
Log.warn("Client received (and ignored) event: " + event);
}
- } else if (message.getPayload() instanceof PayloadFactory.HeartbeatPayload) {
+ } else if (message.getPayload() instanceof HeartbeatPayload) {
//ignore it
} else {
Log.error("Client received (and ignored) message: " + message);
@@ -693,12 +694,12 @@
public void handleMessage(Message message, TCPChannel sourceChannel) throws NoSuchDestinationException {
synchronized (this) {
if (waiting) {
- if (message.getPayload() instanceof PayloadFactory.AuthenticationSuccessPayload) {
+ if (message.getPayload() instanceof AuthenticationSuccessPayload) {
authStatus = SUCCESS_STATUS;
return;
- } else if (message.getPayload() instanceof PayloadFactory.AuthenticationFailurePayload) {
+ } else if (message.getPayload() instanceof AuthenticationFailurePayload) {
authStatus = FAILED_STATUS;
- errorMessage = ((PayloadFactory.AuthenticationFailurePayload) message.getPayload()).getMessage();
+ errorMessage = ((AuthenticationFailurePayload) message.getPayload()).getMessage();
return;
}
waitingMessages.add(message);
@@ -721,7 +722,7 @@
void authenticate(String authCookie) throws IOException {
try {
- Message message = new Message(messageChannel.getLocalLocator(), messageChannel.getRemoteLocator(), space.getSpaceID(), new PayloadFactory.AuthenticationRequestPayload(authCookie, space.getSpaceID()));
+ Message message = new Message(messageChannel.getLocalLocator(), messageChannel.getRemoteLocator(), space.getSpaceID(), new AuthenticationRequestPayload(authCookie, space.getSpaceID()));
messageChannel.sendMessage(message);
} catch (NoSuchDestinationException e) {
throw new IOException("Could not send authentication message");
@@ -737,7 +738,7 @@
}
public void heartbeat() throws IOException {
- Message message = new Message(messageChannel.getLocalLocator(), messageChannel.getRemoteLocator(), space.getSpaceID(), new PayloadFactory.HeartbeatPayload());
+ Message message = new Message(messageChannel.getLocalLocator(), messageChannel.getRemoteLocator(), space.getSpaceID(), new HeartbeatPayload());
try {
messageChannel.sendMessage(message);
} catch (NoSuchDestinationException e) {
@@ -794,7 +795,7 @@
cleanedUp = true;
try {
Log.info("In space client cleanup, about to send logout message:" + accountDoc.getUsername());
- messageChannel.sendMessage(new Message(messageChannel.getLocalLocator(), messageChannel.getRemoteLocator(), space.getSpaceID(), new PayloadFactory.LogoutPayload(accountDoc.getUsername())));
+ messageChannel.sendMessage(new Message(messageChannel.getLocalLocator(), messageChannel.getRemoteLocator(), space.getSpaceID(), new LogoutPayload(accountDoc.getUsername())));
Log.info("Success sending logout message");
} catch (Exception e) {
Log.error("Problem sending logout message:" + e.getMessage());
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultiuserTests.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultiuserTests.java 2008-03-21 22:44:46 UTC (rev 794)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultiuserTests.java 2008-03-24 19:53:28 UTC (rev 795)
@@ -46,6 +46,7 @@
}
public static void main(String[] args) {
+ org.apache.log4j.BasicConfigurator.configure();
if (args.length != 4) {
Log.error("usage: ... spaceID serviceURI numRobots duration");
return;
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/MeasPerfClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/MeasPerfClient.java 2008-03-21 22:44:46 UTC (rev 794)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/MeasPerfClient.java 2008-03-24 19:53:28 UTC (rev 795)
@@ -1,6 +1,7 @@
package com.ogoglio.message;
import com.ogoglio.message.plugin.MessageStack;
+import com.ogoglio.message.payload.HeartbeatPayload;
import java.util.*;
@@ -68,7 +69,7 @@
try {
Long me = new Long(Thread.currentThread().getId());
while (true) {
- p = new PayloadFactory.HeartbeatPayload();
+ p = new HeartbeatPayload();
long id = r.nextLong();
m = new Message(channel.getLocalLocator(), channel.getRemoteLocator(), id, p);
timeMap.put(new Long(id), new Long(System.currentTimeMillis()));
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/Message.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/Message.java 2008-03-21 22:44:46 UTC (rev 794)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/Message.java 2008-03-24 19:53:28 UTC (rev 795)
@@ -17,10 +17,15 @@
import nanoxml.XMLElement;
import com.ogoglio.message.proto.Locator;
+import com.ogoglio.message.plugin.BinaryMementoEncodable;
+import com.ogoglio.message.plugin.MessagingException;
import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.util.Log;
-public class Message {
+import java.io.*;
+public class Message implements BinaryMementoEncodable {
+
public static final String MESSAGE = "Message";
private static final String PROXY = "proxy";
@@ -41,6 +46,10 @@
private long spaceID = -1;
+ // Default constructor required for memento pattern
+ public Message() {
+ }
+
public Message(Locator origin, Locator proxy, Locator destination, long spaceID, Payload payload) {
ArgumentUtils.assertNotNull(origin);
this.origin = origin;
@@ -131,4 +140,95 @@
public void setOrigin(Locator origin) {
this.origin = origin;
}
+
+ public String getMementoClassID() {
+ return MESSAGE;
+ }
+
+ public byte[] getBinaryMemento() throws MessagingException {
+ // Before doing anything else, ensure that our payload is encodable. If not, throw
+ // an exception.
+ if (!(payload instanceof BinaryMementoEncodable)) {
+ throw new MessagingException("Attempted to get memento for Message with non-mementoable payload: " + payload);
+ }
+
+ // Create a ByteArrayOutputStream, wrap it in a DataOutputStream and serialize into it.
+ // TODO: Decrease number of buffer allocs/copies?
+ ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+ DataOutputStream dataOutput = new DataOutputStream(byteStream);
+
+ // Write data
+ try {
+ dataOutput.writeUTF(origin.toString());
+ // If there's a proxy, write a boolean true and the proxy;
+ // otherwise, write a boolean false
+ if (proxy != null) {
+ dataOutput.writeBoolean(true);
+ dataOutput.writeUTF(proxy.toString());
+ } else {
+ dataOutput.writeBoolean(false);
+ }
+ dataOutput.writeUTF(destination.toString());
+ dataOutput.writeLong(spaceID);
+ BinaryMementoEncodable encodablePayload = (BinaryMementoEncodable) payload;
+ byte[] payloadMemento = encodablePayload.getBinaryMemento();
+ dataOutput.writeUTF(encodablePayload.getMementoClassID());
+ dataOutput.writeInt(payloadMemento.length);
+ dataOutput.write(payloadMemento);
+ dataOutput.flush();
+ } catch (IOException e) {
+ Log.error("Encountered IOException while encoding message: " + e);
+ throw new MessagingException("Encountered IOException while encoding message", e);
+ }
+
+ return byteStream.toByteArray();
+ }
+
+ public void setBinaryMemento(byte[] memento) throws MessagingException {
+ // Create a ByteArrayInputStream, wrap it in a DataInputStream, and deserialize from it.
+ ByteArrayInputStream byteStream = new ByteArrayInputStream(memento);
+ DataInputStream dataInput = new DataInputStream(byteStream);
+
+ // Read data
+ String originString;
+ String proxyString;
+ String destinationString;
+ long incomingSpaceID;
+ String payloadClassID;
+ byte[] payloadMemento;
+ try {
+ originString = dataInput.readUTF();
+ boolean containsProxy = dataInput.readBoolean();
+ if (containsProxy) {
+ proxyString = dataInput.readUTF();
+ } else {
+ proxyString = null;
+ }
+ destinationString = dataInput.readUTF();
+ incomingSpaceID = dataInput.readLong();
+ payloadClassID = dataInput.readUTF();
+ int payloadMementoSize = dataInput.readInt();
+ payloadMemento = new byte[payloadMementoSize];
+ dataInput.read(payloadMemento);
+ } catch (IOException e) {
+ Log.error("Encountered IOException while decoding message: " + e);
+ throw new MessagingException("Encountered IOException while decoding message", e);
+ }
+
+ // Decode payload
+ Payload incomingPayload = PayloadFactory.createPayloadFromMementoID(payloadClassID);
+
+ ((BinaryMementoEncodable) incomingPayload).setBinaryMemento(payloadMemento);
+
+ // Now that everything's in place, populate the object
+ setOrigin(new Locator(originString));
+ if (proxyString != null) {
+ setProxy(new Locator(proxyString));
+ } else {
+ setProxy(null);
+ }
+ setDestination(new Locator(destinationString));
+ setSpaceID(incomingSpaceID);
+ payload = incomingPayload;
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/Payload.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/Payload.java 2008-03-21 22:44:46 UTC (rev 794)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/Payload.java 2008-03-24 19:53:28 UTC (rev 795)
@@ -15,30 +15,34 @@
package com.ogoglio.message;
import nanoxml.XMLElement;
+import com.ogoglio.message.payload.AuthenticatedPayload;
+import com.ogoglio.util.Log;
-public class Payload {
+public abstract class Payload {
public static final String PAYLOAD = "Payload";
- private XMLElement data = null;
-
- public Payload(XMLElement data) {
- if (data == null) {
- throw new IllegalArgumentException("bad data: " + data);
- }
- if (data.getName().equals(PAYLOAD)) {
- throw new IllegalStateException("Cannot nest payloads: " + data);
- }
- this.data = data;
+ public Payload() {
+ // Does nothing for now
}
+
+ /**
+ * Parse the given Payload XML into variables in the implementing class.
+ *
+ * @param data XML data to parse
+ */
+ public abstract void parseData(XMLElement data);
- public XMLElement getData() {
- return data;
- }
+ /**
+ * Create Payload XML data on the fly from variables in the implementing class.
+ *
+ * @return XML data representing data contained in class
+ */
+ public abstract XMLElement getData();
public XMLElement toElement() {
XMLElement element = new XMLElement(PAYLOAD);
- element.addChild(data);
+ element.addChild(getData());
return element;
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/PayloadFactory.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/PayloadFactory.java 2008-03-21 22:44:46 UTC (rev 794)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/PayloadFactory.java 2008-03-24 19:53:28 UTC (rev 795)
@@ -14,7 +14,9 @@
package com.ogoglio.message;
-import com.ogoglio.xml.SpaceEvent;
+import com.ogoglio.message.payload.*;
+import com.ogoglio.message.plugin.MessagingException;
+import com.ogoglio.util.Log;
import nanoxml.XMLElement;
@@ -55,230 +57,40 @@
}
}
- public static class HeartbeatPayload extends Payload {
- public static final String NAME = "HeartbeatPayload";
-
- public HeartbeatPayload() {
- super(new XMLElement(NAME));
+ /**
+ * Instantiate a subclass of Payload based on the supplied payloadClassID (as returned
+ * by BinaryMementoEncodable.getMementoClassID), using the default constructor.
+ *
+ * TODO: Make this a dynamic repository so new class IDs can be added without code change.
+ *
+ * @param payloadClassID Memento class ID of Payload to instantiate
+ * @return An instance of the Payload subclass corresponding to payloadClassID.
+ * @throws com.ogoglio.message.plugin.MessagingException if the payloadClassID is unrecognized.
+ */
+ public static Payload createPayloadFromMementoID(String payloadClassID) throws MessagingException {
+ Payload payload;
+ if (payloadClassID.equals(AuthenticatedPayload.NAME)) {
+ payload = new AuthenticatedPayload();
+ } else if (payloadClassID.equals(AuthenticationFailurePayload.NAME)) {
+ payload = new AuthenticationFailurePayload();
+ } else if (payloadClassID.equals(AuthenticationRequestPayload.NAME)) {
+ payload = new AuthenticationRequestPayload();
+ } else if (payloadClassID.equals(AuthenticationSuccessPayload.NAME)) {
+ payload = new AuthenticationSuccessPayload();
+ } else if (payloadClassID.equals(HeartbeatPayload.NAME)) {
+ payload = new HeartbeatPayload();
+ } else if (payloadClassID.equals(LoggedOutPayload.NAME)) {
+ payload = new LoggedOutPayload();
+ } else if (payloadClassID.equals(LogoutPayload.NAME)) {
+ payload = new LogoutPayload();
+ } else if (payloadClassID.equals(ProxiedSpaceEventPayload.NAME)) {
+ payload = new ProxiedSpaceEventPayload();
+ } else if (payloadClassID.equals(SpaceEventPayload.NAME)) {
+ payload = new SpaceEventPayload();
+ } else {
+ Log.error("Received Message with unknown class ID: " + payloadClassID);
+ throw new MessagingException("Received Message with unknown class ID: " + payloadClassID);
}
-
- public HeartbeatPayload(XMLElement data) {
- super(data);
- }
+ return payload;
}
-
- public static class SpaceEventPayload extends Payload {
- public static final String NAME = "SpaceEventPayload";
-
- public SpaceEventPayload(SpaceEvent spaceEvent) {
- super(create(spaceEvent));
- }
-
- public SpaceEventPayload(XMLElement data) {
- super(data);
- }
-
- public SpaceEvent getSpaceEvent() {
- return new SpaceEvent(getData().getChild(SpaceEvent.SPACE_EVENT));
- }
-
- public static XMLElement create(SpaceEvent spaceEvent) {
- XMLElement data = new XMLElement(NAME);
- data.addChild(spaceEvent.toElement());
- return data;
- }
-
- public void setSpaceEvent(SpaceEvent event) {
- getData().removeChildren(SpaceEvent.SPACE_EVENT);
- getData().addChild(event.toElement());
- }
- }
-
- public static class ProxiedSpaceEventPayload extends Payload {
- public static final String NAME = "ProxiedSpaceEventPayload";
-
- public static final String USERNAME = "username";
-
- public ProxiedSpaceEventPayload(String username, SpaceEvent spaceEvent) {
- super(create(username, spaceEvent));
- }
-
- public ProxiedSpaceEventPayload(XMLElement data) {
- super(data);
- }
-
- public SpaceEvent getSpaceEvent() {
- return new SpaceEvent(getData().getChild(SpaceEvent.SPACE_EVENT));
- }
-
- public static XMLElement create(String username, SpaceEvent spaceEvent) {
- XMLElement data = new XMLElement(NAME);
- data.setAttribute(USERNAME, username);
- data.addChild(spaceEvent.toElement());
- return data;
- }
-
- public String getUsername() {
- return getData().getStringAttribute(USERNAME);
- }
-
- public void setSpaceEvent(SpaceEvent event) {
- getData().removeChildren(SpaceEvent.SPACE_EVENT);
- getData().addChild(event.toElement());
- }
- }
-
- public static class LogoutPayload extends Payload {
- public static final String NAME = "Logout";
-
- public static final String USERNAME = "username";
-
- public LogoutPayload() {
- super(create(null));
- }
-
- public LogoutPayload(String username) {
- super(create(username));
- }
-
- public LogoutPayload(XMLElement data) {
- super(data);
- }
-
- public static XMLElement create(String username) {
- XMLElement data = new XMLElement(NAME);
- if (username != null) {
- data.setAttribute(USERNAME, username);
- }
- return data;
- }
- }
-
- public static class AuthenticationRequestPayload extends Payload {
- public static final String NAME = "AuthenticationRequest";
-
- public static final String LOGIN_COOKIE = "loginCookie";
-
- public static final String SPACE_ID = "spaceID";
-
- public AuthenticationRequestPayload(XMLElement element) {
- super(element);
- }
-
- public AuthenticationRequestPayload(String loginCookie, long spaceID) {
- super(create(loginCookie, spaceID));
- }
-
- public String getLoginCookie() {
- return getData().getStringAttribute(LOGIN_COOKIE);
- }
-
- public long getSpaceID() {
- return getData().getLongAttribute(SPACE_ID);
- }
-
- public static XMLElement create(String loginCookie, long spaceID) {
- XMLElement element = new XMLElement(NAME);
- element.setAttribute(LOGIN_COOKIE, loginCookie);
- element.setAttribute(SPACE_ID, spaceID);
- return element;
- }
- }
-
- public static class AuthenticationSuccessPayload extends Payload {
- public static final String NAME = "AuthenticationSuccess";
-
- public static final String USERNAME = "username";
-
- public AuthenticationSuccessPayload(String username) {
- super(create(username));
- }
-
- public AuthenticationSuccessPayload(XMLElement data) {
- super(data);
- }
-
- public String getUsername() {
- return getData().getStringAttribute(USERNAME);
- }
-
- public static XMLElement create(String username) {
- XMLElement data = new XMLElement(NAME);
- data.setAttribute(USERNAME, username);
- return data;
- }
- }
-
- public static class AuthenticationFailurePayload extends Payload {
- public static final String NAME = "AuthenticationFailure";
- public static final String MESSAGE = "message";
-
- public AuthenticationFailurePayload(String message) {
- super(create(message));
- }
-
- public AuthenticationFailurePayload(XMLElement element) {
- super(element);
- }
-
- private static XMLElement create(String message) {
- XMLElement element = new XMLElement(NAME);
- element.setAttribute(MESSAGE, message);
- return element;
- }
-
- public String getMessage() {
- return getData().getStringAttribute(MESSAGE);
- }
- }
-
- // This is sent to the space simulator when a client is authenticated
- public static class AuthenticatedPayload extends Payload {
- public static final String NAME = "Authenticated";
-
- public static final String USERNAME = "username";
-
- public AuthenticatedPayload(String username) {
- super(create(username));
- }
-
- public AuthenticatedPayload(XMLElement data) {
- super(data);
- }
-
- public String getUsername() {
- return getData().getStringAttribute(USERNAME);
- }
-
- public static XMLElement create(String username) {
- XMLElement data = new XMLElement(NAME);
- data.setAttribute(USERNAME, username);
- return data;
- }
- }
-
- // This is sent to the space simulator when a client logs out
- public static class LoggedOutPayload extends Payload {
- public static final String NAME = "LoggedOut";
-
- public static final String USERNAME = "username";
-
- public LoggedOutPayload(String username) {
- super(create(username));
- }
-
- public LoggedOutPayload(XMLElement data) {
- super(data);
- }
-
- public String getUsername() {
- return getData().getStringAttribute(USERNAME);
- }
-
- public static XMLElement create(String username) {
- XMLElement data = new XMLElement(NAME);
- data.setAttribute(USERNAME, username);
- return data;
- }
- }
}
Added: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/payload/AuthenticatedPayload.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/payload/AuthenticatedPayload.java (rev 0)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/payload/AuthenticatedPayload.java 2008-03-24 19:53:28 UTC (rev 795)
@@ -0,0 +1,77 @@
+/* Copyright 2007 Transmutable (http://transmutable.com/)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
+package com.ogoglio.message.payload;
+
+import com.ogoglio.message.Payload;
+import com.ogoglio.message.plugin.BinaryMementoEncodable;
+import com.ogoglio.message.plugin.MessagingException;
+import nanoxml.XMLElement;
+
+// This is sent to the space simulator when a client is authenticated
+public class AuthenticatedPayload extends Payload implements BinaryMementoEncodable {
+ public static final String NAME = "Authenticated";
+
+ public static final String USERNAME = "username";
+
+ protected String username = "";
+
+ public AuthenticatedPayload() {
+ }
+
+ public AuthenticatedPayload(String username) {
+ this.username = username;
+ }
+
+ public AuthenticatedPayload(XMLElement data) {
+ parseData(data);
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUserna...
[truncated message content] |
|
From: <tre...@us...> - 2008-07-15 03:38:01
|
Revision: 798
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=798&view=rev
Author: trevorolio
Date: 2008-07-14 20:38:05 -0700 (Mon, 14 Jul 2008)
Log Message:
-----------
Framed out the new Flash based 3D viewer. Does not actually do anything yet.
Added Paths:
-----------
maven/trunk/ogoglio-viewer/
maven/trunk/ogoglio-viewer/.actionScriptProperties
maven/trunk/ogoglio-viewer/.flexProperties
maven/trunk/ogoglio-viewer/.project
maven/trunk/ogoglio-viewer/.settings/
maven/trunk/ogoglio-viewer/.settings/org.eclipse.core.resources.prefs
maven/trunk/ogoglio-viewer/OgoglioView3D.as
maven/trunk/ogoglio-viewer/away3d/
maven/trunk/ogoglio-viewer/away3d/animation/
maven/trunk/ogoglio-viewer/away3d/animation/Animator.as
maven/trunk/ogoglio-viewer/away3d/away3d-license.txt
maven/trunk/ogoglio-viewer/away3d/cameras/
maven/trunk/ogoglio-viewer/away3d/cameras/Camera3D.as
maven/trunk/ogoglio-viewer/away3d/cameras/HoverCamera3D.as
maven/trunk/ogoglio-viewer/away3d/cameras/TargetCamera3D.as
maven/trunk/ogoglio-viewer/away3d/containers/
maven/trunk/ogoglio-viewer/away3d/containers/DebugObjectContainer3D.as
maven/trunk/ogoglio-viewer/away3d/containers/ILODObject.as
maven/trunk/ogoglio-viewer/away3d/containers/IPhysicsScene.as
maven/trunk/ogoglio-viewer/away3d/containers/LODObject.as
maven/trunk/ogoglio-viewer/away3d/containers/ObjectContainer3D.as
maven/trunk/ogoglio-viewer/away3d/containers/Scene3D.as
maven/trunk/ogoglio-viewer/away3d/containers/View3D.as
maven/trunk/ogoglio-viewer/away3d/core/
maven/trunk/ogoglio-viewer/away3d/core/arcane.as
maven/trunk/ogoglio-viewer/away3d/core/base/
maven/trunk/ogoglio-viewer/away3d/core/base/Animation.as
maven/trunk/ogoglio-viewer/away3d/core/base/AnimationFrame.as
maven/trunk/ogoglio-viewer/away3d/core/base/BaseMesh.as
maven/trunk/ogoglio-viewer/away3d/core/base/BaseMeshElement.as
maven/trunk/ogoglio-viewer/away3d/core/base/Face.as
maven/trunk/ogoglio-viewer/away3d/core/base/Frame.as
maven/trunk/ogoglio-viewer/away3d/core/base/IAnimation.as
maven/trunk/ogoglio-viewer/away3d/core/base/IFrame.as
maven/trunk/ogoglio-viewer/away3d/core/base/IMeshElement.as
maven/trunk/ogoglio-viewer/away3d/core/base/Mesh.as
maven/trunk/ogoglio-viewer/away3d/core/base/Morpher.as
maven/trunk/ogoglio-viewer/away3d/core/base/Object3D.as
maven/trunk/ogoglio-viewer/away3d/core/base/Segment.as
maven/trunk/ogoglio-viewer/away3d/core/base/UV.as
maven/trunk/ogoglio-viewer/away3d/core/base/Vertex.as
maven/trunk/ogoglio-viewer/away3d/core/base/VertexPosition.as
maven/trunk/ogoglio-viewer/away3d/core/base/WireMesh.as
maven/trunk/ogoglio-viewer/away3d/core/block/
maven/trunk/ogoglio-viewer/away3d/core/block/Blocker.as
maven/trunk/ogoglio-viewer/away3d/core/block/BlockerArray.as
maven/trunk/ogoglio-viewer/away3d/core/block/ConvexBlock.as
maven/trunk/ogoglio-viewer/away3d/core/block/ConvexBlocker.as
maven/trunk/ogoglio-viewer/away3d/core/block/IBlockerConsumer.as
maven/trunk/ogoglio-viewer/away3d/core/block/IBlockerProvider.as
maven/trunk/ogoglio-viewer/away3d/core/draw/
maven/trunk/ogoglio-viewer/away3d/core/draw/DrawBitmap.as
maven/trunk/ogoglio-viewer/away3d/core/draw/DrawDisplayObject.as
maven/trunk/ogoglio-viewer/away3d/core/draw/DrawFog.as
maven/trunk/ogoglio-viewer/away3d/core/draw/DrawGroup.as
maven/trunk/ogoglio-viewer/away3d/core/draw/DrawPrimitive.as
maven/trunk/ogoglio-viewer/away3d/core/draw/DrawScaledBitmap.as
maven/trunk/ogoglio-viewer/away3d/core/draw/DrawSegment.as
maven/trunk/ogoglio-viewer/away3d/core/draw/DrawTriangle.as
maven/trunk/ogoglio-viewer/away3d/core/draw/IPrimitiveConsumer.as
maven/trunk/ogoglio-viewer/away3d/core/draw/IPrimitiveProvider.as
maven/trunk/ogoglio-viewer/away3d/core/draw/Line2D.as
maven/trunk/ogoglio-viewer/away3d/core/draw/Plane3D.as
maven/trunk/ogoglio-viewer/away3d/core/draw/PrimitiveArray.as
maven/trunk/ogoglio-viewer/away3d/core/draw/PrimitiveQuadrantTree.as
maven/trunk/ogoglio-viewer/away3d/core/draw/PrimitiveQuadrantTreeNode.as
maven/trunk/ogoglio-viewer/away3d/core/draw/PrimitiveVolumeBlock.as
maven/trunk/ogoglio-viewer/away3d/core/draw/PrimitiveVolumeBlockList.as
maven/trunk/ogoglio-viewer/away3d/core/draw/ScreenVertex.as
maven/trunk/ogoglio-viewer/away3d/core/filter/
maven/trunk/ogoglio-viewer/away3d/core/filter/AnotherRivalFilter.as
maven/trunk/ogoglio-viewer/away3d/core/filter/FogFilter.as
maven/trunk/ogoglio-viewer/away3d/core/filter/IPrimitiveFilter.as
maven/trunk/ogoglio-viewer/away3d/core/filter/IPrimitiveQuadrantFilter.as
maven/trunk/ogoglio-viewer/away3d/core/filter/IPrimitiveVolumeBlockFilter.as
maven/trunk/ogoglio-viewer/away3d/core/filter/QuadrantRiddleFilter.as
maven/trunk/ogoglio-viewer/away3d/core/filter/ZDepthFilter.as
maven/trunk/ogoglio-viewer/away3d/core/filter/ZSortFilter.as
maven/trunk/ogoglio-viewer/away3d/core/light/
maven/trunk/ogoglio-viewer/away3d/core/light/AbstractLightSource.as
maven/trunk/ogoglio-viewer/away3d/core/light/AmbientLightSource.as
maven/trunk/ogoglio-viewer/away3d/core/light/DirectionalLightSource.as
maven/trunk/ogoglio-viewer/away3d/core/light/ILightConsumer.as
maven/trunk/ogoglio-viewer/away3d/core/light/ILightProvider.as
maven/trunk/ogoglio-viewer/away3d/core/light/LightArray.as
maven/trunk/ogoglio-viewer/away3d/core/light/PointLightSource.as
maven/trunk/ogoglio-viewer/away3d/core/math/
maven/trunk/ogoglio-viewer/away3d/core/math/Matrix3D.as
maven/trunk/ogoglio-viewer/away3d/core/math/Number2D.as
maven/trunk/ogoglio-viewer/away3d/core/math/Number3D.as
maven/trunk/ogoglio-viewer/away3d/core/math/Quaternion.as
maven/trunk/ogoglio-viewer/away3d/core/render/
maven/trunk/ogoglio-viewer/away3d/core/render/AbstractRenderSession.as
maven/trunk/ogoglio-viewer/away3d/core/render/BasicRenderer.as
maven/trunk/ogoglio-viewer/away3d/core/render/BitmapRenderSession.as
maven/trunk/ogoglio-viewer/away3d/core/render/Clipping.as
maven/trunk/ogoglio-viewer/away3d/core/render/FindHit.as
maven/trunk/ogoglio-viewer/away3d/core/render/IRenderer.as
maven/trunk/ogoglio-viewer/away3d/core/render/Projection.as
maven/trunk/ogoglio-viewer/away3d/core/render/QuadrantRenderer.as
maven/trunk/ogoglio-viewer/away3d/core/render/RectangleClipping.as
maven/trunk/ogoglio-viewer/away3d/core/render/Renderer.as
maven/trunk/ogoglio-viewer/away3d/core/render/SpriteRenderSession.as
maven/trunk/ogoglio-viewer/away3d/core/stats/
maven/trunk/ogoglio-viewer/away3d/core/stats/Stats.as
maven/trunk/ogoglio-viewer/away3d/core/traverse/
maven/trunk/ogoglio-viewer/away3d/core/traverse/BlockerTraverser.as
maven/trunk/ogoglio-viewer/away3d/core/traverse/PrimitiveTraverser.as
maven/trunk/ogoglio-viewer/away3d/core/traverse/ProjectionTraverser.as
maven/trunk/ogoglio-viewer/away3d/core/traverse/TickTraverser.as
maven/trunk/ogoglio-viewer/away3d/core/traverse/Traverser.as
maven/trunk/ogoglio-viewer/away3d/core/utils/
maven/trunk/ogoglio-viewer/away3d/core/utils/Cast.as
maven/trunk/ogoglio-viewer/away3d/core/utils/CastError.as
maven/trunk/ogoglio-viewer/away3d/core/utils/Color.as
maven/trunk/ogoglio-viewer/away3d/core/utils/Debug.as
maven/trunk/ogoglio-viewer/away3d/core/utils/FaceDictionaryVO.as
maven/trunk/ogoglio-viewer/away3d/core/utils/FaceVO.as
maven/trunk/ogoglio-viewer/away3d/core/utils/IClonable.as
maven/trunk/ogoglio-viewer/away3d/core/utils/Init.as
maven/trunk/ogoglio-viewer/away3d/core/utils/LazyEventDispatcher.as
maven/trunk/ogoglio-viewer/away3d/core/utils/ValueObject.as
maven/trunk/ogoglio-viewer/away3d/events/
maven/trunk/ogoglio-viewer/away3d/events/FaceEvent.as
maven/trunk/ogoglio-viewer/away3d/events/MeshElementEvent.as
maven/trunk/ogoglio-viewer/away3d/events/MouseEvent3D.as
maven/trunk/ogoglio-viewer/away3d/events/Object3DEvent.as
maven/trunk/ogoglio-viewer/away3d/events/SegmentEvent.as
maven/trunk/ogoglio-viewer/away3d/extrusions/
maven/trunk/ogoglio-viewer/away3d/extrusions/CollisionMap.as
maven/trunk/ogoglio-viewer/away3d/extrusions/Elevation.as
maven/trunk/ogoglio-viewer/away3d/extrusions/ElevationReader.as
maven/trunk/ogoglio-viewer/away3d/extrusions/Lathe.as
maven/trunk/ogoglio-viewer/away3d/extrusions/PathExtrude.as
maven/trunk/ogoglio-viewer/away3d/extrusions/SegmentsExtrude.as
maven/trunk/ogoglio-viewer/away3d/extrusions/SkinExtrude.as
maven/trunk/ogoglio-viewer/away3d/lights/
maven/trunk/ogoglio-viewer/away3d/lights/AmbientLight3D.as
maven/trunk/ogoglio-viewer/away3d/lights/DirectionalLight3D.as
maven/trunk/ogoglio-viewer/away3d/lights/PointLight3D.as
maven/trunk/ogoglio-viewer/away3d/loaders/
maven/trunk/ogoglio-viewer/away3d/loaders/Ase.as
maven/trunk/ogoglio-viewer/away3d/loaders/Collada.as
maven/trunk/ogoglio-viewer/away3d/loaders/CubeLoader.as
maven/trunk/ogoglio-viewer/away3d/loaders/Kmz.as
maven/trunk/ogoglio-viewer/away3d/loaders/MaterialLibrary.as
maven/trunk/ogoglio-viewer/away3d/loaders/Max3DS.as
maven/trunk/ogoglio-viewer/away3d/loaders/Md2.as
maven/trunk/ogoglio-viewer/away3d/loaders/Md2still.as
maven/trunk/ogoglio-viewer/away3d/loaders/Obj.as
maven/trunk/ogoglio-viewer/away3d/loaders/Object3DLoader.as
maven/trunk/ogoglio-viewer/away3d/loaders/data/
maven/trunk/ogoglio-viewer/away3d/loaders/data/ContainerData.as
maven/trunk/ogoglio-viewer/away3d/loaders/data/FaceData.as
maven/trunk/ogoglio-viewer/away3d/loaders/data/MaterialData.as
maven/trunk/ogoglio-viewer/away3d/loaders/data/MeshData.as
maven/trunk/ogoglio-viewer/away3d/loaders/data/MeshMaterialData.as
maven/trunk/ogoglio-viewer/away3d/loaders/data/ObjectData.as
maven/trunk/ogoglio-viewer/away3d/loaders/utils/
maven/trunk/ogoglio-viewer/away3d/loaders/utils/TextureLoadQueue.as
maven/trunk/ogoglio-viewer/away3d/loaders/utils/TextureLoader.as
maven/trunk/ogoglio-viewer/away3d/materials/
maven/trunk/ogoglio-viewer/away3d/materials/AlphaBitmapMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/AnimatedBitmapMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/BitmapFileMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/BitmapMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/BitmapMaterialContainer.as
maven/trunk/ogoglio-viewer/away3d/materials/CenterLightingMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/ColorMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/CompositeMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/Dot3BitmapMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/Dot3BitmapMaterialCache.as
maven/trunk/ogoglio-viewer/away3d/materials/Dot3MovieMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/EnviroBitmapMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/EnviroBitmapMaterialCache.as
maven/trunk/ogoglio-viewer/away3d/materials/EnviroColorMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/IFogMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/ILayerMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/IMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/ISegmentMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/ITriangleMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/IUVMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/IUpdatingMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/MovieMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/PhongBitmapMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/PhongBitmapMaterialCache.as
maven/trunk/ogoglio-viewer/away3d/materials/PhongColorMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/PhongColorMaterialCache.as
maven/trunk/ogoglio-viewer/away3d/materials/PhongMovieMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/ShadingColorMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/TransformBitmapMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/TransparentMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/WhiteShadingBitmapMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/WireColorMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/WireframeMaterial.as
maven/trunk/ogoglio-viewer/away3d/materials/shaders/
maven/trunk/ogoglio-viewer/away3d/materials/shaders/AbstractShader.as
maven/trunk/ogoglio-viewer/away3d/materials/shaders/AmbientShader.as
maven/trunk/ogoglio-viewer/away3d/materials/shaders/DiffuseDot3Shader.as
maven/trunk/ogoglio-viewer/away3d/materials/shaders/DiffusePhongShader.as
maven/trunk/ogoglio-viewer/away3d/materials/shaders/EnviroShader.as
maven/trunk/ogoglio-viewer/away3d/materials/shaders/SpecularPhongShader.as
maven/trunk/ogoglio-viewer/away3d/primitives/
maven/trunk/ogoglio-viewer/away3d/primitives/Cone.as
maven/trunk/ogoglio-viewer/away3d/primitives/Cube.as
maven/trunk/ogoglio-viewer/away3d/primitives/Cylinder.as
maven/trunk/ogoglio-viewer/away3d/primitives/GeodesicSphere.as
maven/trunk/ogoglio-viewer/away3d/primitives/GridPlane.as
maven/trunk/ogoglio-viewer/away3d/primitives/LineSegment.as
maven/trunk/ogoglio-viewer/away3d/primitives/LogoCube.as
maven/trunk/ogoglio-viewer/away3d/primitives/Plane.as
maven/trunk/ogoglio-viewer/away3d/primitives/RegularPolygon.as
maven/trunk/ogoglio-viewer/away3d/primitives/SeaTurtle.as
maven/trunk/ogoglio-viewer/away3d/primitives/Skybox.as
maven/trunk/ogoglio-viewer/away3d/primitives/Skybox6.as
maven/trunk/ogoglio-viewer/away3d/primitives/Sphere.as
maven/trunk/ogoglio-viewer/away3d/primitives/Torus.as
maven/trunk/ogoglio-viewer/away3d/primitives/Triangle.as
maven/trunk/ogoglio-viewer/away3d/primitives/Trident.as
maven/trunk/ogoglio-viewer/away3d/primitives/WireCircle.as
maven/trunk/ogoglio-viewer/away3d/primitives/WireCone.as
maven/trunk/ogoglio-viewer/away3d/primitives/WireCube.as
maven/trunk/ogoglio-viewer/away3d/primitives/WireCylinder.as
maven/trunk/ogoglio-viewer/away3d/primitives/WirePlane.as
maven/trunk/ogoglio-viewer/away3d/primitives/WireSphere.as
maven/trunk/ogoglio-viewer/away3d/primitives/WireTorus.as
maven/trunk/ogoglio-viewer/away3d/sprites/
maven/trunk/ogoglio-viewer/away3d/sprites/MovieClipSprite.as
maven/trunk/ogoglio-viewer/away3d/sprites/Sprite2D.as
maven/trunk/ogoglio-viewer/away3d/sprites/Sprite2DDir.as
maven/trunk/ogoglio-viewer/away3d/sprites/dof/
maven/trunk/ogoglio-viewer/away3d/sprites/dof/DofCache.as
maven/trunk/ogoglio-viewer/away3d/sprites/dof/DofSprite2D.as
maven/trunk/ogoglio-viewer/away3d/test/
maven/trunk/ogoglio-viewer/away3d/test/BaseDemo.as
maven/trunk/ogoglio-viewer/away3d/test/Button.as
maven/trunk/ogoglio-viewer/away3d/test/Panel.as
maven/trunk/ogoglio-viewer/away3d/test/Slide.as
maven/trunk/ogoglio-viewer/body.jpg
maven/trunk/ogoglio-viewer/com/
maven/trunk/ogoglio-viewer/com/ogoglio/
maven/trunk/ogoglio-viewer/com/ogoglio/viewer/
maven/trunk/ogoglio-viewer/html-template/
maven/trunk/ogoglio-viewer/html-template/AC_OETags.js
maven/trunk/ogoglio-viewer/html-template/history.htm
maven/trunk/ogoglio-viewer/html-template/history.js
maven/trunk/ogoglio-viewer/html-template/history.swf
maven/trunk/ogoglio-viewer/html-template/index.template.html
maven/trunk/ogoglio-viewer/html-template/playerProductInstall.swf
maven/trunk/ogoglio-viewer/jane.jpg
maven/trunk/ogoglio-viewer/jane.obj
maven/trunk/ogoglio-viewer/main.mxml
maven/trunk/ogoglio-viewer/nochump/
maven/trunk/ogoglio-viewer/nochump/lgpl.txt
maven/trunk/ogoglio-viewer/nochump/util/
maven/trunk/ogoglio-viewer/nochump/util/zip/
maven/trunk/ogoglio-viewer/nochump/util/zip/CRC32.as
maven/trunk/ogoglio-viewer/nochump/util/zip/Deflater.as
maven/trunk/ogoglio-viewer/nochump/util/zip/Inflater.as
maven/trunk/ogoglio-viewer/nochump/util/zip/ZipConstants.as
maven/trunk/ogoglio-viewer/nochump/util/zip/ZipEntry.as
maven/trunk/ogoglio-viewer/nochump/util/zip/ZipError.as
maven/trunk/ogoglio-viewer/nochump/util/zip/ZipFile.as
maven/trunk/ogoglio-viewer/nochump/util/zip/ZipOutput.as
maven/trunk/ogoglio-viewer/test.mtl
maven/trunk/ogoglio-viewer/test.obj
Added: maven/trunk/ogoglio-viewer/.actionScriptProperties
===================================================================
--- maven/trunk/ogoglio-viewer/.actionScriptProperties (rev 0)
+++ maven/trunk/ogoglio-viewer/.actionScriptProperties 2008-07-15 03:38:05 UTC (rev 798)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<actionScriptProperties mainApplicationPath="main.mxml" version="1">
+<compiler additionalCompilerArguments="-locale en_US" copyDependentFiles="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="true" htmlHistoryManagement="true" htmlPlayerVersion="9.0.0" htmlPlayerVersionCheck="true" outputFolderPath="bin" strict="true" warn="true">
+<compilerSourcePath/>
+<libraryPath>
+<libraryPathEntry kind="3" linkType="2" path="${FRAMEWORKS}/libs/playerglobal.swc"/>
+<libraryPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/utilities.swc"/>
+<libraryPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/flex.swc" sourcepath="${FRAMEWORKS}/source"/>
+<libraryPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/framework.swc" sourcepath="${FRAMEWORKS}/source"/>
+<libraryPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/rpc.swc"/>
+<libraryPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/charts.swc" sourcepath="${FRAMEWORKS}/source"/>
+<libraryPathEntry kind="1" linkType="1" path="${FRAMEWORKS}/locale/{locale}"/>
+</libraryPath>
+<sourceAttachmentPath>
+<sourceAttachmentPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/flex.swc" sourcepath="${FRAMEWORKS}/source"/>
+<sourceAttachmentPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/framework.swc" sourcepath="${FRAMEWORKS}/source"/>
+<sourceAttachmentPathEntry kind="3" linkType="1" path="${FRAMEWORKS}/libs/charts.swc" sourcepath="${FRAMEWORKS}/source"/>
+</sourceAttachmentPath>
+</compiler>
+<applications>
+<application path="main.mxml"/>
+</applications>
+<buildCSSFiles/>
+</actionScriptProperties>
Added: maven/trunk/ogoglio-viewer/.flexProperties
===================================================================
--- maven/trunk/ogoglio-viewer/.flexProperties (rev 0)
+++ maven/trunk/ogoglio-viewer/.flexProperties 2008-07-15 03:38:05 UTC (rev 798)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flexProperties flexServerType="0" toolCompile="true" version="1"/>
Added: maven/trunk/ogoglio-viewer/.project
===================================================================
--- maven/trunk/ogoglio-viewer/.project (rev 0)
+++ maven/trunk/ogoglio-viewer/.project 2008-07-15 03:38:05 UTC (rev 798)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ogoglio-viewer</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.adobe.flexbuilder.project.flexbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.adobe.flexbuilder.project.flexnature</nature>
+ <nature>com.adobe.flexbuilder.project.actionscriptnature</nature>
+ </natures>
+</projectDescription>
Added: maven/trunk/ogoglio-viewer/.settings/org.eclipse.core.resources.prefs
===================================================================
--- maven/trunk/ogoglio-viewer/.settings/org.eclipse.core.resources.prefs (rev 0)
+++ maven/trunk/ogoglio-viewer/.settings/org.eclipse.core.resources.prefs 2008-07-15 03:38:05 UTC (rev 798)
@@ -0,0 +1,3 @@
+#Mon Jul 14 19:41:27 PDT 2008
+eclipse.preferences.version=1
+encoding/<project>=utf-8
Added: maven/trunk/ogoglio-viewer/OgoglioView3D.as
===================================================================
--- maven/trunk/ogoglio-viewer/OgoglioView3D.as (rev 0)
+++ maven/trunk/ogoglio-viewer/OgoglioView3D.as 2008-07-15 03:38:05 UTC (rev 798)
@@ -0,0 +1,84 @@
+package
+{
+ import away3d.materials.BitmapFileMaterial;
+ import away3d.core.math.Number3D;
+ import away3d.containers.View3D;
+ import away3d.primitives.Cube;
+
+ import flash.events.Event;
+
+ import mx.core.UIComponent;
+ import away3d.core.base.Object3D;
+ import away3d.loaders.Obj;
+ import away3d.loaders.Object3DLoader;
+ import away3d.containers.ObjectContainer3D;
+ import away3d.loaders.MaterialLibrary;
+
+ public class OgoglioView3D extends UIComponent
+ {
+ private var view:View3D;
+
+ private var objLoader:Object3DLoader;
+
+ private var janeLoader:Object3DLoader;
+
+ public function OgoglioView3D()
+ {
+ super();
+ this.addEventListener(Event.ENTER_FRAME, onFrameEnter);
+ }
+
+ override protected function createChildren():void
+ {
+ super.createChildren();
+
+ if(!this.view)
+ {
+ this.view = new View3D();
+
+ this.view.camera.moveTo(new Number3D(0, 0, -300));
+ this.view.camera.lookAt(new Number3D(0, 0, 0));
+ }
+ this.addChild(this.view);
+
+ if(!this.objLoader){
+ this.objLoader = Obj.load("test.obj", { material:new BitmapFileMaterial("body.jpg"), name:"joe", scaling:10 } );
+ this.objLoader.rotationY = 180;
+ this.objLoader.rotationX = -90;
+ }
+ this.view.scene.addChild(this.objLoader);
+
+ if(!this.janeLoader){
+ this.janeLoader = Obj.load("jane.obj", { material:new BitmapFileMaterial("jane.jpg"), name:"jane", scaling:10 } );
+ this.janeLoader.rotationY = 180;
+ this.janeLoader.rotationX = -90;
+ }
+ this.view.scene.addChild(this.janeLoader);
+
+ }
+
+ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+ super.updateDisplayList(unscaledWidth, unscaledHeight);
+
+ if(this.width / 2 != this.view.x)
+ this.view.x = this.width / 2;
+ if(this.height / 2 != this.view.y)
+ this.view.y = this.height / 2;
+ }
+
+ private function onFrameEnter(event:Event):void
+ {
+ if(this.view && this.view.stage)
+ {
+ this.objLoader.result.transform.tx = -100;
+ this.objLoader.result.rotationY += 1;
+
+ this.janeLoader.result.rotationY -= 1;
+ this.janeLoader.result.transform.tx = 100;
+
+ this.view.render();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: maven/trunk/ogoglio-viewer/away3d/animation/Animator.as
===================================================================
--- maven/trunk/ogoglio-viewer/away3d/animation/Animator.as (rev 0)
+++ maven/trunk/ogoglio-viewer/away3d/animation/Animator.as 2008-07-15 03:38:05 UTC (rev 798)
@@ -0,0 +1,145 @@
+package away3d.animation
+{
+ import away3d.core.base.*;
+
+ import flash.utils.Dictionary;
+
+ public class Animator extends Mesh
+ {
+ private var varr:Array = [];
+ private var uvarr:Array = [];
+ private var fnarr:Array = [];
+
+
+ public function Animator(baseObject:Mesh, aFrames:Array, init:Object = null, doloop:Boolean = false)
+ {
+ super(init);
+ generate(baseObject, aFrames, doloop);
+
+ type = "Animator";
+ url = "Mesh";
+
+ }
+
+ //Array aFrames properties: vertices:Array[vertex.x,y and z positions], prefix:String
+ public function generate(baseObject:Mesh, aFrames:Array, doloop:Boolean):void
+ {
+ var i:int ;
+ var j:int ;
+ var k:int ;
+
+ // export requirement
+ indexes = new Array();
+
+ if(doloop){
+ var fr:Object = new Object();
+ fr.vertices = aFrames[0].vertices;
+ fr.prefix = aFrames[0].prefix;
+ var pref:String = "";
+ for(i=0; i<fr.prefix.length;i++){
+ if(isNaN(fr.prefix.substring(i,i+1)) ){
+ pref += fr.prefix.substring(i,i+1);
+ } else{
+ break;
+ }
+ }
+ fr.prefix = pref+(aFrames.length+1);
+ aFrames.push(fr);
+ }
+
+ var face:Face;
+ varr = varr.concat(baseObject.vertices);
+
+ for(i=0;i<baseObject.faces.length;i++){
+ face = baseObject.faces[i];
+ uvarr.push(face.uv0, face.uv1, face.uv2);
+ addFace(face);
+ }
+
+ frames = new Dictionary();
+ framenames = new Dictionary();
+ fnarr = [];
+ var oFrames:Object = new Object();
+ var arr:Array;
+
+ for(i=0;i<aFrames.length;i++){
+ oFrames[aFrames[i].prefix]=new Array();
+ fnarr.push(aFrames[i].prefix);
+ arr = aFrames[i].vertices;
+ for(j=0;j<arr.length;j++){
+ oFrames[aFrames[i].prefix].push(arr[j], arr[j], arr[j]);
+ }
+
+ }
+
+ var frame:Frame;
+ for(i = 0;i<fnarr.length; i++){
+ trace("[ "+fnarr[i]+" ]");
+ frame = new Frame();
+ framenames[fnarr[i]] = i;
+ frames[i] = frame;
+ k=0;
+ for (j = 0; j < oFrames[fnarr[i]].length; j+=3){
+ var vp:VertexPosition = new VertexPosition(varr[k]);
+ k++;
+ vp.x = oFrames[fnarr[i]][j].x;
+ vp.y = oFrames[fnarr[i]][j+1].y;
+ vp.z = oFrames[fnarr[i]][j+2].z;
+ frame.vertexpositions.push(vp);
+ }
+
+ if (i == 0)
+ frame.adjust();
+ }
+
+ }
+
+ public function get framelist():Array{
+ return fnarr;
+ }
+
+
+ // not tested yet, should allow to add a frame or more at runtime too... array
+ // contains same object vertices and prefix as constructor.
+ public function addFrames(aFrames:Array):void
+ {
+ var i:int ;
+ var j:int ;
+ var k:int ;
+ var oFrames:Object = new Object();
+ var arr:Array;
+
+ for(i=0;i<aFrames.length;i++){
+ oFrames[aFrames[i].prefix]=new Array();
+ fnarr.push(aFrames[i].prefix);
+ arr = aFrames[i].vertices;
+ for(j=0;j<arr.length;j++){
+ oFrames[aFrames[i].prefix].push(arr[j], arr[j], arr[j]);
+ }
+ }
+
+ var frame:Frame;
+ for(i = 0;i<fnarr.length; i++){
+ trace("[ "+fnarr[i]+" ]");
+ frame = new Frame();
+ framenames[fnarr[i]] = i;
+ frames[i] = frame;
+ k=0;
+ for (j = 0; j < oFrames[fnarr[i]].length; j+=3){
+ var vp:VertexPosition = new VertexPosition(varr[k]);
+ k++;
+ vp.x = oFrames[fnarr[i]][j].x;
+ vp.y = oFrames[fnarr[i]][j+1].y;
+ vp.z = oFrames[fnarr[i]][j+2].z;
+ frame.vertexpositions.push(vp);
+ }
+
+ if (i == 0)
+ frame.adjust();
+ }
+
+ }
+
+
+ }
+}
Added: maven/trunk/ogoglio-viewer/away3d/away3d-license.txt
===================================================================
--- maven/trunk/ogoglio-viewer/away3d/away3d-license.txt (rev 0)
+++ maven/trunk/ogoglio-viewer/away3d/away3d-license.txt 2008-07-15 03:38:05 UTC (rev 798)
@@ -0,0 +1,13 @@
+Copyright 2007 Alexander Zadorozhny
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
\ No newline at end of file
Added: maven/trunk/ogoglio-viewer/away3d/cameras/Camera3D.as
===================================================================
--- maven/trunk/ogoglio-viewer/away3d/cameras/Camera3D.as (rev 0)
+++ maven/trunk/ogoglio-viewer/away3d/cameras/Camera3D.as 2008-07-15 03:38:05 UTC (rev 798)
@@ -0,0 +1,148 @@
+package away3d.cameras
+{
+ import away3d.core.*;
+ import away3d.core.base.*;
+ import away3d.core.draw.*;
+ import away3d.core.math.*;
+ import away3d.core.render.*;
+ import away3d.core.utils.*;
+ import away3d.sprites.dof.DofCache;
+
+ /** Camera in 3D-space */
+ public class Camera3D extends Object3D
+ {
+ public var zoom:Number;
+
+
+ // Depth of field parameters
+ private var _aperture:Number = 22;
+ private var _focus:Number;
+
+ public function set aperture(value:Number):void
+ {
+ _aperture = value;
+ DofCache.aperture = _aperture;
+ }
+
+ public function get aperture():Number
+ {
+ return _aperture;
+ }
+
+ public function set focus(value:Number):void
+ {
+ _focus = value;
+ DofCache.focus = _focus;
+ }
+
+ public function get focus():Number
+ {
+ return _focus;
+ }
+
+
+ public var maxblur:Number = 150;
+ public var doflevels:Number = 16;
+ public var usedof:Boolean = false;
+
+ private var _view:Matrix3D = new Matrix3D();
+
+ public function Camera3D(init:Object = null)
+ {
+ super(init);
+
+ init = Init.parse(init);
+ zoom = (init as Init).getNumber("zoom", 10);
+ focus = (init as Init).getNumber("focus", 100);
+ usedof = (init as Init).getBoolean("dof", false);
+ if(usedof)
+ {
+ aperture = (init as Init).getNumber("aperture", 22);
+ maxblur = (init as Init).getNumber("maxblur", 150);
+ doflevels = (init as Init).getNumber("doflevels", 16);
+ enableDof();
+ }
+ else
+ {
+ disableDof();
+ }
+
+ var lookat:Number3D = (init as Init).getPosition("lookat");
+
+ _flipY.syy = -1;
+
+ if (lookat != null)
+ lookAt(lookat);
+ }
+
+ public function enableDof():void
+ {
+ DofCache.doflevels = doflevels;
+ DofCache.aperture = aperture;
+ DofCache.maxblur = maxblur;
+ DofCache.focus = focus;
+ ...
[truncated message content] |