|
From: <tre...@us...> - 2007-06-29 23:23:01
|
Revision: 203
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=203&view=rev
Author: trevorolio
Date: 2007-06-29 16:23:02 -0700 (Fri, 29 Jun 2007)
Log Message:
-----------
Dropped S3 specific code since using S3 directly is a Bad Idea, learned painfully during this morning's outage.
Added WebStore and MediaServlet to replace S3. Together these allow multiple instances to use a single file store fronted by a simple servlet.
Added an ogoglio/mediaDirectory environment parameter to servlet.xml to indicate when the MediaServlet should serve (not a good idea unless firewalled).
Set more threads to daemon and cleaned up more Java3D state on renderer shutdown in hopes of alleviating cross space teleport leaks.
Safari seems happier when shutting down the viewer applet, but it's unclear that this will help in production.
Despite this, the sims still keep Tomcat alive past context cleanup.
Moved test account and template creation into the ClientTests instead of inflicting it on all installations.
Modified Paths:
--------------
spaces/trunk/.classpath
spaces/trunk/build.xml
spaces/trunk/docs/server.xml
spaces/trunk/src/com/ogoglio/client/ClientTests.java
spaces/trunk/src/com/ogoglio/client/SpaceDuplicatorTests.java
spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
spaces/trunk/src/com/ogoglio/media/FileStore.java
spaces/trunk/src/com/ogoglio/media/MediaService.java
spaces/trunk/src/com/ogoglio/media/MediaStore.java
spaces/trunk/src/com/ogoglio/message/NetworkChannelServer.java
spaces/trunk/src/com/ogoglio/message/SenderQueue.java
spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java
spaces/trunk/src/com/ogoglio/persist/PersistTests.java
spaces/trunk/src/com/ogoglio/persist/ServiceInitializationPersistTasks.java
spaces/trunk/src/com/ogoglio/sim/Sim.java
spaces/trunk/src/com/ogoglio/sim/SpaceSimulator.java
spaces/trunk/src/com/ogoglio/sim/script/ScriptHTTPRequest.java
spaces/trunk/src/com/ogoglio/sim/site/SimServlet.java
spaces/trunk/src/com/ogoglio/site/AbstractResourceServlet.java
spaces/trunk/src/com/ogoglio/site/AccountServlet.java
spaces/trunk/src/com/ogoglio/site/AuthenticatedSiteResource.java
spaces/trunk/src/com/ogoglio/site/MessageProxy.java
spaces/trunk/src/com/ogoglio/site/SiteInfo.java
spaces/trunk/src/com/ogoglio/site/SiteResource.java
spaces/trunk/src/com/ogoglio/viewer/j3d/J3DRenderer.java
spaces/trunk/src/com/ogoglio/viewer/j3d/PhysicsBehavior.java
spaces/trunk/src/hibernate.cfg.xml
spaces/trunk/war/WEB-INF/web.xml
Added Paths:
-----------
spaces/trunk/src/com/ogoglio/media/WebStore.java
spaces/trunk/src/com/ogoglio/media/site/
spaces/trunk/src/com/ogoglio/media/site/MediaServlet.java
Removed Paths:
-------------
spaces/trunk/src/com/ogoglio/media/MediaTests.java
spaces/trunk/src/com/ogoglio/media/S3Store.java
spaces/trunk/src/com/ogoglio/persist/TestPersistTasks.java
spaces/trunk/src/com/ogoglio/util/S3Utils.java
spaces/trunk/war/WEB-INF/lib/jets3t-0.5.0.jar
Modified: spaces/trunk/.classpath
===================================================================
--- spaces/trunk/.classpath 2007-06-28 23:14:43 UTC (rev 202)
+++ spaces/trunk/.classpath 2007-06-29 23:23:02 UTC (rev 203)
@@ -4,7 +4,7 @@
<classpathentry kind="var" path="TOMCAT_HOME/common/lib/servlet-api.jar"/>
<classpathentry kind="var" path="TOMCAT_HOME/common/lib/jasper-runtime.jar"/>
<classpathentry kind="var" path="TOMCAT_HOME/common/lib/jsp-api.jar"/>
- <classpathentry kind="src" output="work" path="work"/>
+ <classpathentry output="work" kind="src" path="work"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/junit.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/mysql-connector-java-3.1.11-bin.jar"/>
@@ -26,7 +26,6 @@
<classpathentry kind="lib" path="war/WEB-INF/lib/js.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/commons-httpclient-3.0.1.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/commons-codec-1.3.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/jets3t-0.5.0.jar"/>
<classpathentry kind="var" path="BROWSER_PLUGIN"/>
<classpathentry kind="output" path="war/WEB-INF/classes"/>
</classpath>
Modified: spaces/trunk/build.xml
===================================================================
--- spaces/trunk/build.xml 2007-06-28 23:14:43 UTC (rev 202)
+++ spaces/trunk/build.xml 2007-06-29 23:23:02 UTC (rev 203)
@@ -2,7 +2,7 @@
<project default="war" basedir=".">
<property name="source" value="src" />
<property name="dest" value="war/WEB-INF/classes" />
- <property name="tomcatHome" value="/usr/share/tomcat5/" />
+ <property name="tomcatHome" value="../../tomcat/" />
<property name="webLibDir" value="./war/WEB-INF/lib/" />
<property name="warName" value="ogoglio.war" />
Modified: spaces/trunk/docs/server.xml
===================================================================
--- spaces/trunk/docs/server.xml 2007-06-28 23:14:43 UTC (rev 202)
+++ spaces/trunk/docs/server.xml 2007-06-29 23:23:02 UTC (rev 203)
@@ -16,22 +16,24 @@
<Context path="/og" reloadable="false" docBase="/Users/trevor/Code/EclipseWorkspace/spaces/war" workDir="/Users/trevor/Code/EclipseWorkspace/spaces/work" >
<Logger className="org.apache.catalina.logger.SystemOutLogger" verbosity="4" timestamp="true"/>
- <!-- THIS DEFINES THE DATABASE USED BY THE OGOGLIO SERVLETS -->
+ <!-- THIS DEFINES THE DATABASE USED BY THE OGOGLIO SERVLETS, SET THE HSQL PATH OR ANOTHER JDBC URL (e.g. MySQL) -->
<Resource name="jdbc/space" scope="Shareable" type="javax.sql.DataSource" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" url="jdbc:hsqldb:/Users/trevor/Code/EclipseWorkspace/spaces/db/ogoglio" driverClassName="org.hsqldb.jdbcDriver" username="sa" password="" maxIdle="5" maxActive="50" />
<!-- THE FOLLOWING VARIABLES ARE READ IN com.ogoglio.site.AbstractResourceServet.init -->
- <!-- CHANGE THIS TO POINT TO THE DIRECTORY WHERE YOU WANT THE MODELS, TEXTURES, SCRIPTS, and XML FILES TO BE STORED -->
+ <!-- CHANGE THIS TO POINT TO THE URL OF THE SERVER OR DIRECTORY WHERE YOU WANT THE MODELS, TEXTURES, SCRIPTS, and XML FILES TO BE STORED -->
+ <!-- IF YOU ARE RUNNING EVERYTHING ON ONE MACHINE, USE A FILE URL LIKE file:///home/username/mediaDir -->
+ <!-- IF YOU ARE RUNNING A REMOTE MEDIA SERVICE, USE A URL LIKE http://example.com:8080/og/media/ -->
<Environment name="ogoglio/mediaURL" value="file:///Users/trevor/Code/EclipseWorkspace/spaces/working/media" type="java.lang.String"/>
- <!-- OR, IF YOU HAVE AN AMAZON S3 ACCOUNT, YOU CAN USE THAT _INSTEAD_OF_ THE MEDIA URL ABOVE-->
- <!-- <Environment name="ogoglio/mediaURL" value="s3://YOUR_AWS_ACCESS_KEY:YOUR_AWS_SECRET_KEY@EXISTING_BUCKET_NAME" type="java.lang.String"/> -->
-
<!-- CHANGE THIS TO BE THE PUBLIC URL FOR YOUR SERVICE: http://YOUR_DOMAIN/og/ -->
- <Environment name="ogoglio/baseURL" value="http://127.0.0.1:8080/og/" type="java.lang.String"/>
+ <Environment name="ogoglio/baseURL" value="http://example.com:8080/og/" type="java.lang.String"/>
<!-- CHANGE THIS TO TRUE IF YOUR SIMS RUN ON SEPARATE MACHINES (UNSAFE UNLESS THE SIMS HAVE FIREWALLS WHICH REFUSE CONNECTIONS FROM ALL BUT KNOWN WEB APPS) -->
<Environment name="ogoglio/simsAllowRemoteAccess" value="false" type="java.lang.String" />
+
+ <!-- IF THIS CONFIG IS FOR A MEDIA SERVER, UNCOMMENT THESE, SET THE FULL PATH TO YOUR MEDIA DIR -->
+ <!-- <Environment name="ogoglio/mediaDirectory" value="/Users/trevor/Code/EclipseWorkspace/spaces/working/media" type="java.lang.String"/>
</Context>
</Host>
Modified: spaces/trunk/src/com/ogoglio/client/ClientTests.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-06-28 23:14:43 UTC (rev 202)
+++ spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-06-29 23:23:02 UTC (rev 203)
@@ -13,6 +13,7 @@
limitations under the License. */
package com.ogoglio.client;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
@@ -34,7 +35,6 @@
import com.ogoglio.client.model.User;
import com.ogoglio.persist.AccountRecord;
import com.ogoglio.persist.ServiceInitializationPersistTasks;
-import com.ogoglio.persist.TestPersistTasks;
import com.ogoglio.util.StreamUtils;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.AuthDocument;
@@ -51,12 +51,20 @@
public class ClientTests extends TestCase {
+ public static final String PASSWORD1 = "1234";
+
+ public static final String USERNAME1 = "susan";
+
+ public static final String USERNAME2 = "tina";
+
+ public static final String COOKIE1 = "tr5w95nxracntj";
+
+ public static final String COOKIE2 = "trMoonUnitZappa";
+
URI linkURI1 = null;
URI serviceURI1 = null;
- private String ownerUsername1;
-
private String spaceName1;
private long spaceID1;
@@ -65,7 +73,6 @@
public void setUp() {
try {
- ownerUsername1 = "susan";
spaceID1 = 1;
spaceName1 = "Angry Young Space";
serviceURI1 = new URI("http://127.0.0.1:8080/og/");
@@ -83,29 +90,36 @@
public void testWebAdmin() {
try {
- String basicAuthCookie = WebAPIClient.authenticate(serviceURI1, TestPersistTasks.USERNAME1, TestPersistTasks.PASSWORD1);
+ String adminAuthCookie = WebAPIClient.authenticate(serviceURI1, ServiceInitializationPersistTasks.LIBRARY_USERNAME, ServiceInitializationPersistTasks.DEFAULT_LIBRARY_PASSWORD);
+ assertNotNull("got null auth cookie", adminAuthCookie);
+
+ try {
+ WebAPIClient.createAccount(serviceURI1, adminAuthCookie, USERNAME1, AccountRecord.ACCOUNT_LEVEL_ADVANCED, "Susan", "Examplar", "http://example.com/susan/", "su...@ex...", PASSWORD1);
+ WebAPIClient.createAccount(serviceURI1, adminAuthCookie, USERNAME2, AccountRecord.ACCOUNT_LEVEL_ADVANCED, "Tina", "Examplar", "http://example.com/tina/", "ti...@ex...", PASSWORD1);
+ } catch (IOException e) {
+ //may already exist
+ }
+
+ String basicAuthCookie = WebAPIClient.authenticate(serviceURI1, USERNAME1, PASSWORD1);
assertNotNull("got null auth cookie", basicAuthCookie);
try {
String failedUsername = "Bogosity" + System.currentTimeMillis();
AccountDocument doc = WebAPIClient.createAccount(serviceURI1, basicAuthCookie, failedUsername, AccountRecord.ACCOUNT_LEVEL_BASIC, "Shouldnt", "Exist", null, failedUsername + "@example.com", "1234");
- if(doc != null) {
+ if (doc != null) {
fail();
}
} catch (Exception e) {
//this should happen, because basic accounts can't create new accounts
}
- String adminAuthCookie = WebAPIClient.authenticate(serviceURI1, ServiceInitializationPersistTasks.LIBRARY_USERNAME, ServiceInitializationPersistTasks.DEFAULT_LIBRARY_PASSWORD);
- assertNotNull("got null auth cookie", adminAuthCookie);
-
String username = "testuser" + Math.abs(new Random().nextLong());
WebAPIClient.createAccount(serviceURI1, adminAuthCookie, username, AccountRecord.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, username + "@example.com", "1234");
-
+
AccountDocument accountDoc = WebAPIClient.getAccountDocument(serviceURI1, adminAuthCookie, username);
assertNotNull(accountDoc);
assertEquals("Test", accountDoc.getFirstName());
assertEquals("Sims", accountDoc.getLastName());
-
+
Date frozenDate = new Date(System.currentTimeMillis() + 1000000);
accountDoc.setFrozenUntil(frozenDate);
accountDoc.setAccountLevel(AccountRecord.ACCOUNT_LEVEL_ADMIN);
@@ -131,7 +145,7 @@
SpaceClient guestSpaceClient1 = null;
try {
- String authCookie1 = WebAPIClient.authenticate(serviceURI1, TestPersistTasks.USERNAME1, TestPersistTasks.PASSWORD1);
+ String authCookie1 = WebAPIClient.authenticate(serviceURI1, USERNAME1, PASSWORD1);
assertNotNull("got null auth cookie", authCookie1);
SpaceDocument spaceDoc1 = WebAPIClient.createSpace(serviceURI1, authCookie1);
@@ -159,11 +173,11 @@
AuthDocument authDoc = webClient1.getAuthDocument(true);
assertNotNull(authDoc);
- assertEquals(TestPersistTasks.USERNAME1, authDoc.getUsername());
+ assertEquals(USERNAME1, authDoc.getUsername());
AccountDocument ownerDoc = webClient1.getAccountDocument(authDoc.getUsername());
assertNotNull(ownerDoc);
- assertEquals(TestPersistTasks.USERNAME1, ownerDoc.getUsername());
+ assertEquals(USERNAME1, ownerDoc.getUsername());
String key1 = "ogoglio.key.1";
String value1 = "This is a very fine value which is < 1";
@@ -208,14 +222,14 @@
assertNotNull(membershipDocs);
assertEquals(0, membershipDocs.length);
- webClient1.addSpaceMember(TestPersistTasks.USERNAME2, SpaceMemberDocument.MEMBER);
+ webClient1.addSpaceMember(USERNAME2, SpaceMemberDocument.MEMBER);
membershipDocs = webClient1.getSpaceMemberDocuments();
assertNotNull(membershipDocs);
assertEquals(1, membershipDocs.length);
- assertEquals(TestPersistTasks.USERNAME2, membershipDocs[0].getMemberUsername());
+ assertEquals(USERNAME2, membershipDocs[0].getMemberUsername());
assertEquals(SpaceMemberDocument.MEMBER, membershipDocs[0].getRole());
- String authCookie2 = WebAPIClient.authenticate(serviceURI1, TestPersistTasks.USERNAME2, TestPersistTasks.PASSWORD1);
+ String authCookie2 = WebAPIClient.authenticate(serviceURI1, USERNAME2, PASSWORD1);
assertNotNull("got null auth cookie", authCookie1);
WebAPIClient webClient2 = new WebAPIClient(spaceURI1, serviceURI1, authCookie2);
membershipDocs = webClient2.getUsersSpaceMemberships();
@@ -224,9 +238,9 @@
assertEquals(webClient2.getAuthDocument(true).getUsername(), membershipDocs[0].getMemberUsername());
SpaceMemberDocument[] spaceMemberDocs = webClient1.getSpaceMemberDocuments();
assertFalse("member doc length = " + spaceMemberDocs.length, spaceMemberDocs.length == 0);
- assertEquals(spaceMemberDocs[0].getMemberUsername(), TestPersistTasks.USERNAME2);
+ assertEquals(spaceMemberDocs[0].getMemberUsername(), USERNAME2);
- webClient1.removeSpaceMember(TestPersistTasks.USERNAME2);
+ webClient1.removeSpaceMember(USERNAME2);
membershipDocs = webClient2.getUsersSpaceMemberships();
assertEquals(0, membershipDocs.length);
@@ -237,7 +251,7 @@
TemplateDocument newTemplateDoc = webClient1.createTemplate(templateName);
assertEquals(templateName, newTemplateDoc.getDisplayName());
- templateName = "Cold Blue Shirt";
+ templateName = "Test Cube";
newTemplateDoc.setDisplayName(templateName);
newTemplateDoc = webClient1.updateTemplate(newTemplateDoc);
assertEquals(templateName, newTemplateDoc.getDisplayName());
@@ -248,25 +262,24 @@
webClient1.updateTemplateScript(newTemplateDoc.getTemplateID(), null);
assertEquals(null, webClient1.getTemplateScript(newTemplateDoc.getTemplateID()));
- PossessionDocument[] possDocs = webClient1.getPossessionDocuments(TestPersistTasks.USERNAME1);
+ URI templateURI = webClient1.getTemplateURI(newTemplateDoc.getOwnerUsername(), newTemplateDoc.getTemplateID());
+ FileInputStream objData = new FileInputStream("src/com/ogoglio/persist/resources/TestCube.obj");
+ webClient1.putGeometryStream(templateURI, objData, 0);
+ FileInputStream mtlData = new FileInputStream("src/com/ogoglio/persist/resources/TestCube.mtl");
+ webClient1.putGeometryStream(templateURI, mtlData, "TestCube.mtl");
+ FileInputStream textureData = new FileInputStream("src/com/ogoglio/persist/resources/TestCube.gif");
+ webClient1.putGeometryStream(templateURI, textureData, "TestCube.gif");
+ String cubeScript = StreamUtils.readInput(new FileInputStream("src/com/ogoglio/persist/resources/TestCube.js"));
+ webClient1.updateTemplateScript(newTemplateDoc.getTemplateID(), cubeScript);
+
+ PossessionDocument[] possDocs = webClient1.getPossessionDocuments(USERNAME1);
int numPossessions = possDocs.length;
- TemplateDocument[] templateDocs = webClient1.getTemplateDocuments(ServiceInitializationPersistTasks.LIBRARY_USERNAME);
- assertTrue(templateDocs.length > 0);
- assertEquals(templateDocs[0].getOwnerUsername(), ServiceInitializationPersistTasks.LIBRARY_USERNAME);
-
- TemplateDocument templateDoc = webClient1.getTemplateDocument(ServiceInitializationPersistTasks.LIBRARY_USERNAME, templateDocs[0].getTemplateID());
- assertNotNull(templateDoc);
- assertEquals(templateDocs[0].getTemplateID(), templateDoc.getTemplateID());
-
- webClient1.createPossession(templateDocs[0].getTemplateID());
- possDocs = webClient1.getPossessionDocuments(TestPersistTasks.USERNAME1);
+ webClient1.createPossession(newTemplateDoc.getTemplateID());
+ possDocs = webClient1.getPossessionDocuments(USERNAME1);
assertEquals(numPossessions + 1, possDocs.length);
- ThingDocument[] thingDocs = webClient1.getThingDocuments();
- if (thingDocs.length > 0) {
- System.out.println("Already have a " + thingDocs[0].getDisplayName());
- }
+ ThingDocument[] thingDocs = webClient1.getThingDocuments();
assertEquals(0, thingDocs.length);
PossessionDocument possDoc = webClient1.addPossessionToSpace(possDocs[numPossessions].getPossessionID(), spaceDocument.getSpaceID());
assertNotNull(possDoc);
@@ -283,7 +296,7 @@
ShapeDocument[] shapeDocs = thingDocs[0].getShapeDocuments();
assertEquals(1, shapeDocs.length);
- assertEquals("Grid_Grid_Green", shapeDocs[0].getShapeName());
+ assertEquals("Cube", shapeDocs[0].getShapeName());
PageDocument[] pages = webClient1.getPageDocuments(thingDocs[0].getThingID());
assertEquals(0, pages.length);
@@ -314,9 +327,10 @@
pages = webClient1.getPageDocuments(thingDocs[0].getThingID());
assertEquals(0, pages.length);
+ TemplateDocument[] templateDocs = webClient1.getTemplateDocuments(USERNAME1);
DoorDocument[] doorDocs = webClient1.getDoorDocuments();
assertEquals(0, doorDocs.length);
- DoorDocument doorDoc = webClient1.createDoor(spaceDocument.getSpaceID(), 2, ServiceInitializationPersistTasks.LIBRARY_USERNAME, "Test Door", linkURI1, new Transform3D());
+ DoorDocument doorDoc = webClient1.createDoor(spaceDocument.getSpaceID(), templateDocs[templateDocs.length - 1].getTemplateID(), USERNAME1, "Test Door", linkURI1, new Transform3D());
assertNotNull(doorDoc);
assertFalse(doorDoc.getDoorID() == -1);
assertEquals(linkURI1, doorDoc.getLink());
@@ -338,18 +352,18 @@
}
userDocs = webClient1.getUserDocuments();
assertEquals(1, userDocs.length);
- assertEquals(TestPersistTasks.USERNAME1, userDocs[0].getUsername());
+ assertEquals(USERNAME1, userDocs[0].getUsername());
spaceClient1.cleanup();
- InputStream stream = webClient1.getGeometryStream(webClient1.getTemplateURI(ServiceInitializationPersistTasks.LIBRARY_USERNAME, 1), 0);
+ InputStream stream = webClient1.getGeometryStream(webClient1.getTemplateURI(USERNAME1, templateDocs[templateDocs.length - 1].getTemplateID()), 0);
assertNotNull(stream);
consume(stream);
- stream = webClient1.getGeometryStream(webClient1.getTemplateURI(ServiceInitializationPersistTasks.LIBRARY_USERNAME, 1), "defaultLand.mtl");
+ stream = webClient1.getGeometryStream(webClient1.getTemplateURI(USERNAME1, templateDocs[templateDocs.length - 1].getTemplateID()), "TestCube.mtl");
assertNotNull(stream);
consume(stream);
- authCookie1 = WebAPIClient.authenticate(serviceURI1, TestPersistTasks.USERNAME1, TestPersistTasks.PASSWORD1);
+ authCookie1 = WebAPIClient.authenticate(serviceURI1, USERNAME1, PASSWORD1);
assertNotNull("got null auth cookie", authCookie1);
TestSpaceClientListener listener = new TestSpaceClientListener();
@@ -369,7 +383,7 @@
assertEquals(0, thingDocs.length);
webClient1.deletePossession(possDoc.getPossessionID());
- possDocs = webClient1.getPossessionDocuments(TestPersistTasks.USERNAME1);
+ possDocs = webClient1.getPossessionDocuments(USERNAME1);
assertEquals(numPossessions, possDocs.length);
String guestCookie1 = WebAPIClient.requestGuestCookie(serviceURI1);
Modified: spaces/trunk/src/com/ogoglio/client/SpaceDuplicatorTests.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/SpaceDuplicatorTests.java 2007-06-28 23:14:43 UTC (rev 202)
+++ spaces/trunk/src/com/ogoglio/client/SpaceDuplicatorTests.java 2007-06-29 23:23:02 UTC (rev 203)
@@ -8,7 +8,6 @@
import junit.framework.TestCase;
-import com.ogoglio.persist.TestPersistTasks;
import com.ogoglio.xml.DoorDocument;
import com.ogoglio.xml.PositionedDocument;
import com.ogoglio.xml.SpaceDocument;
@@ -27,18 +26,23 @@
WebAPIClient client2 = null;
String testSettingKey = "test.setting.key";
+
String testSettingValue = "A Value for the Test Setting";
-
+
+ String authCookie = null;
+
public void setUp() {
try {
spaceURI1 = new URI("http://127.0.0.1:8080/og/space/1/");
spaceURI2 = new URI("http://127.0.0.1:8080/og/space/2/");
serviceURI1 = new URI("http://127.0.0.1:8080/og/");
- client1 = new WebAPIClient(spaceURI1, serviceURI1, TestPersistTasks.COOKIE1);
+ authCookie = WebAPIClient.authenticate(serviceURI1, ClientTests.USERNAME1, ClientTests.PASSWORD1);
+ assertNotNull(authCookie);
+ client1 = new WebAPIClient(spaceURI1, serviceURI1, authCookie);
client1.putSetting(testSettingKey, testSettingValue);
-
- client2 = new WebAPIClient(spaceURI2, serviceURI1, TestPersistTasks.COOKIE1);
+
+ client2 = new WebAPIClient(spaceURI2, serviceURI1, authCookie);
} catch (Throwable e) {
e.printStackTrace();
fail(e.getMessage());
@@ -54,12 +58,12 @@
ThingDocument[] originalThingDocs = client1.getThingDocuments();
DoorDocument[] originalDoorDocs = client1.getDoorDocuments();
Map originalSettings = client1.getSettings();
-
+
//TODO settings transfer
-
- SpaceDuplicator duplicator = new SpaceDuplicator(spaceURI1, serviceURI1, TestPersistTasks.USERNAME1, TestPersistTasks.COOKIE1);
+
+ SpaceDuplicator duplicator = new SpaceDuplicator(spaceURI1, serviceURI1, ClientTests.USERNAME1, authCookie);
duplicator.duplicateSpace(spaceURI2, true);
-
+
SpaceDocument newSpaceDoc = client2.getSpaceDocument(false);
assertEquals(originalSpaceDoc.getDisplaySea(), newSpaceDoc.getDisplaySea());
assertEquals(originalSpaceDoc.getSeaLevel(), newSpaceDoc.getSeaLevel(), 0.001);
@@ -67,7 +71,7 @@
assertEquals(originalSpaceDoc.isPublished(), newSpaceDoc.isPublished());
assertEquals(originalSpaceDoc.getMaxGuests(), newSpaceDoc.getMaxGuests());
assertEquals(originalSpaceDoc.getOwnerUsername(), newSpaceDoc.getOwnerUsername());
-
+
ThingDocument[] newThingDocs = client2.getThingDocuments();
Arrays.sort(newThingDocs, new ThingDocComparator());
Arrays.sort(originalThingDocs, new ThingDocComparator());
@@ -83,7 +87,7 @@
assertEquals(originalDoorDocs[i].getLink(), newDoorDocs[i].getLink());
assertEqualPositions(originalDoorDocs[i], newDoorDocs[i]);
}
-
+
Map newSettings = client2.getSettings();
newSettings.equals(originalSettings);
} catch (IOException e) {
@@ -91,19 +95,19 @@
fail("" + e);
}
}
-
+
private static class ThingDocComparator implements Comparator {
public int compare(Object arg0, Object arg1) {
ThingDocument doc1 = (ThingDocument) arg0;
ThingDocument doc2 = (ThingDocument) arg1;
long idDiff = doc1.getTemplateID() - doc2.getTemplateID();
- if(idDiff != 0) {
+ if (idDiff != 0) {
return idDiff < 0 ? -1 : 1;
}
return doc1.getPossessionID() < doc1.getPossessionID() ? -1 : 1;
}
}
-
+
private static void assertEqualPositions(PositionedDocument doc1, PositionedDocument doc2) {
assertEquals(doc1.getX(), doc2.getX(), 0.001);
assertEquals(doc1.getY(), doc2.getY(), 0.001);
Modified: spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-06-28 23:14:43 UTC (rev 202)
+++ spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-06-29 23:23:02 UTC (rev 203)
@@ -520,13 +520,17 @@
}
public InputStream getGeometryStream(URI renderableRootURI, String name) throws IOException {
- return fetchAuthenticatedStream(appendToURI(renderableRootURI, "geometry/" + (name == null ? "data/" : name)), authCookie);
+ return fetchAuthenticatedStream(appendToURI(renderableRootURI, "geometry/" + name), authCookie);
}
public void putGeometryStream(URI rootURI, InputStream input, String name) throws IOException {
- performPOST(appendToURI(rootURI, "geometry/" + (name == null ? "data/" : name)), StreamUtils.readInput(input), "application/octet-stream", authCookie);
+ performPOST(appendToURI(rootURI, "geometry/" + name), StreamUtils.readInput(input), "application/octet-stream", authCookie);
}
+ public void putGeometryStream(URI rootURI, InputStream input, int lodIndex) throws IOException {
+ performPOST(appendToURI(rootURI, "geometry/data/" + lodIndex), StreamUtils.readInput(input), "application/octet-stream", authCookie);
+ }
+
public InputStream getGeometryStream(URI renderableRootURI, int lodIndex) throws IOException {
return fetchAuthenticatedStream(appendToURI(renderableRootURI, "geometry/data/" + lodIndex), authCookie);
}
@@ -554,6 +558,51 @@
return sendAuthenticatedXML(uri, body, "POST", authCookie);
}
+ public static long requestContentLength(URI uri, String authCookie) {
+ try {
+ HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
+ connection.setRequestMethod("HEAD");
+ connection.setAllowUserInteraction(false);
+ if (authCookie != null) {
+ connection.setRequestProperty("Cookie", AuthServlet.AUTH_COOKIE + "=" + authCookie);
+ }
+
+ connection.setDoOutput(false);
+ if (connection.getResponseCode() != 200) {
+ return -1;
+ }
+ String lengthHeader = (String)connection.getRequestProperties().get("Content-Length");
+ if(lengthHeader == null) {
+ return -1;
+ }
+ return Integer.parseInt(lengthHeader);
+ } catch (IOException e) {
+ return -1;
+ }
+ }
+
+ public static InputStream performPUT(URI uri, InputStream input, String type, int length, String authCookie) throws IOException {
+ HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
+ connection.setRequestMethod("PUT");
+ connection.setAllowUserInteraction(false);
+ if (authCookie != null) {
+ connection.setRequestProperty("Cookie", AuthServlet.AUTH_COOKIE + "=" + authCookie);
+ }
+
+ connection.setDoOutput(true);
+ connection.setRequestProperty("Content-type", type);
+ if (length >= 0) {
+ connection.setRequestProperty("Content-length", Integer.toString(length));
+ }
+ StreamUtils.write(input, connection.getOutputStream());
+
+ if (connection.getResponseCode() != 200) {
+ throw new IOException("Get status " + connection.getResponseCode() + " from " + uri);
+ }
+
+ return connection.getInputStream();
+ }
+
public static InputStream performPOST(URI uri, String body, String type, String authCookie) throws IOException {
HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
connection.setRequestMethod("POST");
@@ -762,4 +811,5 @@
public URI getSettingURI(String key) {
return appendToURI(getSettingsURI(), key + "/");
}
+
}
Modified: spaces/trunk/src/com/ogoglio/media/FileStore.java
===================================================================
--- spaces/trunk/src/com/ogoglio/media/FileStore.java 2007-06-28 23:14:43 UTC (rev 202)
+++ spaces/trunk/src/com/ogoglio/media/FileStore.java 2007-06-29 23:23:02 UTC (rev 203)
@@ -43,6 +43,7 @@
ArgumentUtils.assertNoPaths(name...
[truncated message content] |
|
From: <ian...@us...> - 2007-07-03 02:33:30
|
Revision: 209
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=209&view=rev
Author: iansmith
Date: 2007-07-02 19:33:29 -0700 (Mon, 02 Jul 2007)
Log Message:
-----------
Started down the road to building a tool that will sync a set of directories full of content with service that hosts those spaces. It's nowhere near complete yet.
Add support for RMock tests, since I like them. Examples in com.ogoglio.spacesync.SyncToolSpec.
Updated the .jars for cglib and junit to include proper version numbers. It appears that we were already at these versions but I wanted to be sure when I was including RMock that it was clear which version we were expecting. I did not delete old ones in case of catastrophic failure.
Java does not allow one to override (and thus mock) statics so I had to move WebAPIClient.authenticate to a separate class for later hackery. I created WebAPIUtil with a few things in it (including authenticate) and patched all the callers to use the new version. Other than the class name, no visible effects to callers.
So far, all my space sync tool does is parse the command line and look for directories that may be your collection of spaces that it should synchronize. This was enough to teach me how to use RMock (vince I was used to the ruby version, RSpec).
I split my "tests" into spec and unit parts. Eventually, I'd like to use the documentation generator (TDDocRender) to render documentation from my specs, but I couldn't get that to work right off the bat.
Modified Paths:
--------------
spaces/trunk/.classpath
spaces/trunk/src/com/ogoglio/client/ClientTests.java
spaces/trunk/src/com/ogoglio/client/SpaceDuplicatorTests.java
spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
spaces/trunk/src/com/ogoglio/media/WebStore.java
spaces/trunk/src/com/ogoglio/persist/ServiceInitializationPersistTasks.java
spaces/trunk/src/com/ogoglio/site/AccountServlet.java
spaces/trunk/src/com/ogoglio/site/AuthServlet.java
spaces/trunk/src/com/ogoglio/site/MessageProxy.java
Added Paths:
-----------
spaces/trunk/src/com/ogoglio/client/WebAPIAuthenticator.java
spaces/trunk/src/com/ogoglio/client/WebAPIUtil.java
spaces/trunk/src/com/ogoglio/spacesync/
spaces/trunk/src/com/ogoglio/spacesync/SpaceSyncTestSuite.java
spaces/trunk/src/com/ogoglio/spacesync/SyncTool.java
spaces/trunk/src/com/ogoglio/spacesync/SyncToolSpec.java
spaces/trunk/src/com/ogoglio/spacesync/SyncToolTest.java
spaces/trunk/war/WEB-INF/lib/cglib-nodep-2.1_2.jar
spaces/trunk/war/WEB-INF/lib/junit-3.8.1.jar
spaces/trunk/war/WEB-INF/lib/rmock-2.0.0.jar
Modified: spaces/trunk/.classpath
===================================================================
--- spaces/trunk/.classpath 2007-07-01 20:25:27 UTC (rev 208)
+++ spaces/trunk/.classpath 2007-07-03 02:33:29 UTC (rev 209)
@@ -4,9 +4,8 @@
<classpathentry kind="var" path="TOMCAT_HOME/common/lib/servlet-api.jar"/>
<classpathentry kind="var" path="TOMCAT_HOME/common/lib/jasper-runtime.jar"/>
<classpathentry kind="var" path="TOMCAT_HOME/common/lib/jsp-api.jar"/>
- <classpathentry output="work" kind="src" path="work"/>
+ <classpathentry kind="src" output="work" path="work"/>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/junit.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/mysql-connector-java-3.1.11-bin.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/log4j-1.2.9.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/jta.jar"/>
@@ -16,7 +15,6 @@
<classpathentry kind="lib" path="war/WEB-INF/lib/dom4j-1.6.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/commons-logging-1.0.4.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/commons-collections-2.1.1.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/cglib-2.1.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/asm-attrs.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/asm.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/antlr-2.7.5H3.jar"/>
@@ -27,5 +25,8 @@
<classpathentry kind="lib" path="war/WEB-INF/lib/commons-httpclient-3.0.1.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/commons-codec-1.3.jar"/>
<classpathentry kind="var" path="BROWSER_PLUGIN"/>
+ <classpathentry kind="lib" path="war/WEB-INF/lib/cglib-nodep-2.1_2.jar"/>
+ <classpathentry kind="lib" path="war/WEB-INF/lib/junit-3.8.1.jar"/>
+ <classpathentry kind="lib" path="war/WEB-INF/lib/rmock-2.0.0.jar"/>
<classpathentry kind="output" path="war/WEB-INF/classes"/>
</classpath>
Modified: spaces/trunk/src/com/ogoglio/client/ClientTests.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-07-01 20:25:27 UTC (rev 208)
+++ spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-07-03 02:33:29 UTC (rev 209)
@@ -81,7 +81,7 @@
public void testWebAdmin() {
try {
- String adminAuthCookie = WebAPIClient.authenticate(serviceURI1, ServiceInitializationPersistTasks.LIBRARY_USERNAME, ServiceInitializationPersistTasks.DEFAULT_LIBRARY_PASSWORD);
+ String adminAuthCookie = WebAPIUtil.authenticate(serviceURI1, ServiceInitializationPersistTasks.LIBRARY_USERNAME, ServiceInitializationPersistTasks.DEFAULT_LIBRARY_PASSWORD);
assertNotNull("got null auth cookie", adminAuthCookie);
try {
@@ -91,7 +91,7 @@
//may already exist
}
- String basicAuthCookie = WebAPIClient.authenticate(serviceURI1, USERNAME1, PASSWORD1);
+ String basicAuthCookie = WebAPIUtil.authenticate(serviceURI1, USERNAME1, PASSWORD1);
assertNotNull("got null auth cookie", basicAuthCookie);
try {
String failedUsername = "Bogosity" + System.currentTimeMillis();
@@ -136,11 +136,11 @@
SpaceClient guestSpaceClient1 = null;
try {
- String authCookie1 = WebAPIClient.authenticate(serviceURI1, USERNAME1, PASSWORD1);
+ String authCookie1 = WebAPIUtil.authenticate(serviceURI1, USERNAME1, PASSWORD1);
assertNotNull("got null auth cookie", authCookie1);
SpaceDocument spaceDoc1 = WebAPIClient.createSpace(serviceURI1, authCookie1);
- URI spaceURI1 = WebAPIClient.appendToURI(serviceURI1, "space/" + spaceDoc1.getSpaceID());
+ URI spaceURI1 = WebAPIUtil.appendToURI(serviceURI1, "space/" + spaceDoc1.getSpaceID());
try {
new WebAPIClient(spaceURI1, serviceURI1, "BadBadCookie").getSpaceDocument(false);
@@ -220,7 +220,7 @@
assertEquals(USERNAME2, membershipDocs[0].getMemberUsername());
assertEquals(SpaceMemberDocument.MEMBER, membershipDocs[0].getRole());
- String authCookie2 = WebAPIClient.authenticate(serviceURI1, USERNAME2, PASSWORD1);
+ String authCookie2 = WebAPIUtil.authenticate(serviceURI1, USERNAME2, PASSWORD1);
assertNotNull("got null auth cookie", authCookie1);
WebAPIClient webClient2 = new WebAPIClient(spaceURI1, serviceURI1, authCookie2);
membershipDocs = webClient2.getUsersSpaceMemberships();
@@ -354,7 +354,7 @@
assertNotNull(stream);
consume(stream);
- authCookie1 = WebAPIClient.authenticate(serviceURI1, USERNAME1, PASSWORD1);
+ authCookie1 = WebAPIUtil.authenticate(serviceURI1, USERNAME1, PASSWORD1);
assertNotNull("got null auth cookie", authCookie1);
TestSpaceClientListener listener = new TestSpaceClientListener();
Modified: spaces/trunk/src/com/ogoglio/client/SpaceDuplicatorTests.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/SpaceDuplicatorTests.java 2007-07-01 20:25:27 UTC (rev 208)
+++ spaces/trunk/src/com/ogoglio/client/SpaceDuplicatorTests.java 2007-07-03 02:33:29 UTC (rev 209)
@@ -37,7 +37,7 @@
spaceURI2 = new URI("http://127.0.0.1:8080/og/space/2/");
serviceURI1 = new URI("http://127.0.0.1:8080/og/");
- authCookie = WebAPIClient.authenticate(serviceURI1, ClientTests.USERNAME1, ClientTests.PASSWORD1);
+ authCookie = WebAPIUtil.authenticate(serviceURI1, ClientTests.USERNAME1, ClientTests.PASSWORD1);
assertNotNull(authCookie);
client1 = new WebAPIClient(spaceURI1, serviceURI1, authCookie);
client1.putSetting(testSettingKey, testSettingValue);
Added: spaces/trunk/src/com/ogoglio/client/WebAPIAuthenticator.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPIAuthenticator.java (rev 0)
+++ spaces/trunk/src/com/ogoglio/client/WebAPIAuthenticator.java 2007-07-03 02:33:29 UTC (rev 209)
@@ -0,0 +1,50 @@
+package com.ogoglio.client;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.net.HttpURLConnection;
+import java.net.URI;
+
+import nanoxml.XMLElement;
+
+import com.ogoglio.site.AuthServlet;
+
+public class WebAPIAuthenticator {
+
+ // it makes it a LOT easier to simulate if we use this style of a little object
+ // rather than the statics which don't allow mocking (and that's kinda important
+ // for authentication!)
+ public WebAPIAuthenticator() {
+
+ }
+
+ /**
+ * @return the authCookie or null if authentication failed
+ */
+ public String authenticate(URI serviceURI, String username, String password) throws IOException {
+
+ String body = AuthServlet.USERNAME_PARAM + "=" + username + "&" + AuthServlet.PASS_PARAM + "=" + password;
+
+ HttpURLConnection connection = (HttpURLConnection) WebAPIUtil.appendToURI(serviceURI, "auth/").toURL().openConnection();
+ connection.setRequestMethod("POST");
+ connection.setAllowUserInteraction(false);
+ connection.setDoOutput(true);
+ connection.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
+ connection.setRequestProperty("Content-length", Integer.toString(body.length()));
+
+ OutputStream rawOutStream = connection.getOutputStream();
+ PrintWriter pw = new PrintWriter(rawOutStream);
+ pw.print(body);
+ pw.flush();
+ pw.close();
+
+ String cookie = WebAPIUtil.parseSetCookieHeader(connection.getHeaderField("Set-Cookie"));
+
+ XMLElement data = new XMLElement();
+ data.parseFromReader(new InputStreamReader(connection.getInputStream()));
+ return cookie;
+ }
+
+}
Modified: spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-07-01 20:25:27 UTC (rev 208)
+++ spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-07-03 02:33:29 UTC (rev 209)
@@ -87,19 +87,19 @@
public static AccountDocument createAccount(URI serviceURI, String adminAuthCookie, String username, String accountLevel, String firstName, String lastName, String homepage, String email, String password) throws IOException {
AccountDocument newAccountDoc = new AccountDocument(username, accountLevel, firstName, lastName, homepage, password, email, null, null, null, null, -1);
- XMLElement result = sendAuthenticatedXML(appendToURI(serviceURI, "account/"), newAccountDoc.toString(), "POST", adminAuthCookie);
+ XMLElement result = sendAuthenticatedXML(WebAPIUtil.appendToURI(serviceURI, "account/"), newAccountDoc.toString(), "POST", adminAuthCookie);
return new AccountDocument(result);
}
public static SpaceDocument createSpace(URI serviceURI, String authCookie) throws IOException {
AuthDocument authDocument = new AuthDocument(fetchAuthenticatedXML(getAuthURI(serviceURI), authCookie));
SpaceDocument spaceDoc = new SpaceDocument(-1, "New Space", authDocument.getUsername(), false, 0, false, 0, -1);
- XMLElement result = sendAuthenticatedXML(appendToURI(serviceURI, "account/" + authDocument.getUsername() + "/space/"), spaceDoc.toString(), "POST", authCookie);
+ XMLElement result = sendAuthenticatedXML(WebAPIUtil.appendToURI(serviceURI, "account/" + authDocument.getUsername() + "/space/"), spaceDoc.toString(), "POST", authCookie);
return new SpaceDocument(result);
}
public static AccountDocument updateAccount(URI serviceURI, String authCookie, AccountDocument accountDoc) throws IOException {
- XMLElement result = sendAuthenticatedXML(appendToURI(serviceURI, "account/" + accountDoc.getUsername()), accountDoc.toElement().toString(), "POST", authCookie);
+ XMLElement result = sendAuthenticatedXML(WebAPIUtil.appendToURI(serviceURI, "account/" + accountDoc.getUsername()), accountDoc.toElement().toString(), "POST", authCookie);
if (result == null) {
return null;
}
@@ -107,7 +107,7 @@
}
public static AccountDocument getAccountDocument(URI serviceURI, String authCookie, String username) throws IOException {
- XMLElement response = fetchAuthenticatedXML(appendToURI(serviceURI, "account/" + username), authCookie);
+ XMLElement response = fetchAuthenticatedXML(WebAPIUtil.appendToURI(serviceURI, "account/" + username), authCookie);
if (response == null) {
return null;
}
@@ -296,44 +296,7 @@
return StreamUtils.readInput(input);
}
- /**
- * @return the authCookie or null if authentication failed
- */
- public static String authenticate(URI serviceURI, String username, String password) throws IOException {
- String body = AuthServlet.USERNAME_PARAM + "=" + username + "&" + AuthServlet.PASS_PARAM + "=" + password;
-
- HttpURLConnection connection = (HttpURLConnection) appendToURI(serviceURI, "auth/").toURL().openConnection();
- connection.setRequestMethod("POST");
- connection.setAllowUserInteraction(false);
- connection.setDoOutput(true);
- connection.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
- connection.setRequestProperty("Content-length", Integer.toString(body.length()));
-
- OutputStream rawOutStream = connection.getOutputStream();
- PrintWriter pw = new PrintWriter(rawOutStream);
- pw.print(body);
- pw.flush();
- pw.close();
-
- String cookie = parseSetCookieHeader(connection.getHeaderField("Set-Cookie"));
-
- XMLElement data = new XMLElement();
- data.parseFromReader(new InputStreamReader(connection.getInputStream()));
- return cookie;
- }
-
- private static String parseSetCookieHeader(String setCookieHeader) {
- if (setCookieHeader == null || setCookieHeader.indexOf('=') == -1 || setCookieHeader.indexOf(';') == -1) {
- return null;
- }
- if (!setCookieHeader.startsWith(AuthServlet.AUTH_COOKIE + "=")) {
- System.err.println("Unknown set cookie: " + setCookieHeader);
- return null;
- }
- return setCookieHeader.substring(setCookieHeader.indexOf("=") + 1, setCookieHeader.indexOf(";"));
- }
-
public SpaceDocument getSpaceDocument(boolean includeChildren) throws IOException {
return new SpaceDocument(fetchAuthenticatedXML(getSpaceURI(includeChildren)));
}
@@ -521,19 +484,19 @@
}
public InputStream getGeometryStream(URI renderableRootURI, String name) throws IOException {
- return fetchAuthenticatedStream(appendToURI(renderableRootURI, "geometry/" + name), authCookie);
+ return fetchAuthenticatedStream(WebAPIUtil.appendToURI(renderableRootURI, "geometry/" + name), authCookie);
}
public void putGeometryStream(URI rootURI, InputStream input, String name) throws IOException {
- performPOST(appendToURI(rootURI, "geometry/" + name), StreamUtils.readInput(input), "application/octet-stream", authCookie);
+ performPOST(WebAPIUtil.appendToURI(rootURI, "geometry/" + name), StreamUtils.readInput(input), "application/octet-stream", authCookie);
}
public void putGeometryStream(URI rootURI, InputStream input, int lodIndex) throws IOException {
- performPOST(appendToURI(rootURI, "geometry/data/" + lodIndex), StreamUtils.readInput(input), "application/octet-stream", authCookie);
+ performPOST(WebAPIUtil.appendToURI(rootURI, "geometry/data/" + lodIndex), StreamUtils.readInput(input), "application/octet-stream", authCookie);
}
public InputStream getGeometryStream(URI renderableRootURI, int lodIndex) throws IOException {
- return fetchAuthenticatedStream(appendToURI(renderableRootURI, "geometry/data/" + lodIndex), authCookie);
+ return fetchAuthenticatedStream(WebAPIUtil.appendToURI(renderableRootURI, "geometry/data/" + lodIndex), authCookie);
}
public static InputStream performGET(URI uri, String authCookie) throws IOException {
@@ -660,7 +623,7 @@
pw.close();
}
- String cookie = parseSetCookieHeader(connection.getHeaderField("Set-Cookie"));
+ String cookie = WebAPIUtil.parseSetCookieHeader(connection.getHeaderField("Set-Cookie"));
if (connection.getResponseCode() != 200) {
throw new IOException("Get status " + connection.getResponseCode() + " from " + uri);
@@ -696,57 +659,48 @@
return fetchAuthenticatedXML(uri, authCookie);
}
- public static URI appendToURI(URI uri, String suffix) {
- try {
- String uriString = uri.toString();
- return new URI(uriString + (uriString.endsWith("/") ? "" : "/") + suffix);
- } catch (URISyntaxException e) {
- throw new IllegalArgumentException("Bad uri: " + uri.toString() + suffix);
- }
- }
-
public URI getSpaceURI() {
return spaceURI;
}
public URI getSpaceURI(boolean includeChildren) {
if (includeChildren) {
- return appendToURI(spaceURI, "?" + SpaceServlet.INCLUDE_CHILDREN_PARAM + "=true");
+ return WebAPIUtil.appendToURI(spaceURI, "?" + SpaceServlet.INCLUDE_CHILDREN_PARAM + "=true");
} else {
return spaceURI;
}
}
public URI getSpaceMemberURI() {
- return appendToURI(spaceURI, "member/");
+ return WebAPIUtil.appendToURI(spaceURI, "member/");
}
private URI getSpaceMemberURI(String memberUsername) {
- return appendToURI(getSpaceMemberURI(), memberUsername + "/");
+ return WebAPIUtil.appendToURI(getSpaceMemberURI(), memberUsername + "/");
}
private URI getUsersSpaceMembershipsURI(String username) {
- return appendToURI(getAccountURI(username), "membership/");
+ return WebAPIUtil.appendToURI(getAccountURI(username), "membership/");
}
public URI getAccountURI() {
- return appendToURI(serviceURI, "account/");
+ return WebAPIUtil.appendToURI(serviceURI, "account/");
}
public URI getAccountURI(String username) {
- return appendToURI(getAccountURI(), username + "/");
+ return WebAPIUtil.appendToURI(getAccountURI(), username + "/");
}
private URI getPossessionsURI(String username) {
- return appendToURI(getAccountURI(username), "possession/");
+ return WebAPIUtil.appendToURI(getAccountURI(username), "possession/");
}
private URI getPossessionURI(String username, long possessionID) {
- return appendToURI(getPossessionsURI(username), possessionID + "/");
+ return WebAPIUtil.appendToURI(getPossessionsURI(username), possessionID + "/");
}
public static URI getAuthURI(URI serviceURI) {
- return appendToURI(serviceURI, "auth/");
+ return WebAPIUtil.appendToURI(serviceURI, "auth/");
}
public URI getAuthURI() {
@@ -754,75 +708,75 @@
}
private static URI getAuthGuestURI(URI serviceURI) {
- return appendToURI(getAuthURI(serviceURI), "guest/");
+ return WebAPIUtil.appendToURI(getAuthURI(serviceURI), "guest/");
}
private URI getAccountSpacesURI(String username) {
- return appendToURI(getAccountURI(username), "space/");
+ return WebAPIUtil.appendToURI(getAccountURI(username), "space/");
}
public URI getTemplatesURI(String username) {
- return appendToURI(getAccountURI(username), "template/");
+ return WebAPIUtil.appendToURI(getAccountURI(username), "template/");
}
public URI getTemplateURI(String username, long templateID) {
- return appendToURI(getTemplatesURI(username), templateID + "/");
+ return WebAPIUtil.appendToURI(getTemplatesURI(username), templateID + "/");
}
public URI getDoorsURI() {
- return appendToURI(spaceURI, "door/");
+ return WebAPIUtil.appendToURI(spaceURI, "door/");
}
public URI getDoorURI(long doorID) {
- return appendToURI(getDoorsURI(), doorID + "/");
+ return WebAPIUtil.appendToURI(getDoorsURI(), doorID + "/");
}
public URI getThingsURI() {
- return appendToURI(spaceURI, "thing/");
+ return WebAPIUtil.appendToURI(spaceURI, "thing/");
}
public URI getThingURI(long thingID) {
- return appendToURI(getThingsURI(), thingID + "/");
+ return WebAPIUtil.appendToURI(getThingsURI(), thingID + "/");
}
private URI getTemplateScriptURI(String username, long templateID) {
- return appendToURI(getTemplateURI(username, templateID), "script/");
+ return WebAPIUtil.appendToURI(getTemplateURI(username, templateID), "script/");
}
public URI getUserURI(String username) {
- return appendToURI(getUsersURI(), username + "/");
+ return WebAPIUtil.appendToURI(getUsersURI(), username + "/");
}
public URI getUsersURI() {
- return appendToURI(spaceURI, "user/");
+ return WebAPIUtil.appendToURI(spaceURI, "user/");
}
private URI getBodiesURI(String username) {
- return appendToURI(getAccountURI(username), "body/");
+ return WebAPIUtil.appendToURI(getAccountURI(username), "body/");
}
public URI getBodyURI(String username, long bodyID) {
- return appendToURI(getBodiesURI(username), bodyID + "/");
+ return WebAPIUtil.appendToURI(getBodiesURI(username), bodyID + "/");
}
public URI getPagesURI(long thingID) {
- return appendToURI(getThingURI(thingID), "page/");
+ return WebAPIUtil.appendToURI(getThingURI(thingID), "page/");
}
public URI getPageURI(long thingID, long pageID) {
- return appendToURI(getPagesURI(thingID), pageID + "/");
+ return WebAPIUtil.appendToURI(getPagesURI(thingID), pageID + "/");
}
private URI getPageContentsURI(long thingID, long pageID) {
- return appendToURI(getPageURI(thingID, pageID), "content");
+ return WebAPIUtil.appendToURI(getPageURI(thingID, pageID), "content");
}
public URI getSettingsURI() {
- return appendToURI(getSpaceURI(), "setting/");
+ return WebAPIUtil.appendToURI(getSpaceURI(), "setting/");
}
public URI getSettingURI(String key) {
- return appendToURI(getSettingsURI(), key + "/");
+ return WebAPIUtil.appendToURI(getSettingsURI(), key + "/");
}
}
Added: spaces/trunk/src/com/ogoglio/client/WebAPIUtil.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPIUtil.java (rev 0)
+++ spaces/trunk/src/com/ogoglio/client/WebAPIUtil.java 2007-07-03 02:33:29 UTC (rev 209)
@@ -0,0 +1,34 @@
+package com.ogoglio.client;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import com.ogoglio.site.AuthServlet;
+
+public class WebAPIUtil {
+ public static URI appendToURI(URI uri, String suffix) {
+ try {
+ String uriString = uri.toString();
+ return new URI(uriString + (uriString.endsWith("/") ? "" : "/") + suffix);
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException("Bad uri: " + uri.toString() + suffix);
+ }
+ }
+
+ //for clients that don't want to bother creating the authenticator object
+ public static String authenticate(URI serviceURI, String username, String password)
+ throws IOException {
+ return (new WebAPIAuthenticator()).authenticate(serviceURI, username, password);
+ }
+ public static String parseSetCookieHeader(String setCookieHeader) {
+ if (setCookieHeader == null || setCookieHeader.indexOf('=') == -1 || setCookieHeader.indexOf(';') == -1) {
+ return null;
+ }
+ if (!setCookieHeader.startsWith(AuthServlet.AUTH_COOKIE + "=")) {
+ System.err.println("Unknown set cookie: " + setCookieHeader);
+ return null;
+ }
+ return setCookieHeader.substring(setCookieHeader.indexOf("=") + 1, setCookieHeader.indexOf(";"));
+ }
+}
Modified: spaces/trunk/src/com/ogoglio/media/WebStore.java
===================================================================
--- spaces/trunk/src/com/ogoglio/media/WebStore.java 2007-07-01 20:25:27 UTC (rev 208)
+++ spaces/trunk/src/com/ogoglio/media/WebStore.java 2007-07-03 02:33:29 UTC (rev 209)
@@ -19,6 +19,7 @@
import java.net.URI;
import com.ogoglio.client.WebAPIClient;
+import com.ogoglio.client.WebAPIUtil;
import com.ogoglio.util.ArgumentUtils;
public class WebStore implements MediaStore {
@@ -35,7 +36,7 @@
}
public boolean write(String name, InputStream input, long maxSize) throws IOException {
- InputStream responseInput = WebAPIClient.performPUT(WebAPIClient.appendToURI(mediaURI, name), input, "application/data", -1, null);
+ InputStream responseInput = WebAPIClient.performPUT(WebAPIUtil.appendToURI(mediaURI, name), input, "application/data", -1, null);
if(responseInput == null) {
return false;
}
@@ -46,19 +47,19 @@
public InputStream getData(String name) {
try {
- return WebAPIClient.performGET(WebAPIClient.appendToURI(mediaURI, name), null);
+ return WebAPIClient.performGET(WebAPIUtil.appendToURI(mediaURI, name), null);
} catch (IOException e) {
return null;
}
}
public long getSize(String name) {
- return WebAPIClient.requestContentLength(WebAPIClient.appendToURI(mediaURI, name), null);
+ return WebAPIClient.requestContentLength(WebAPIUtil.appendToURI(mediaURI, name), null);
}
public boolean delete(String name) {
try {
- return WebAPIClient.sendDelete(WebAPIClient.appendToURI(mediaURI, name), null);
+ return WebAPIClient.sendDelete(WebAPIUtil.appendToURI(mediaURI, name), null);
} catch (IOException e) {
e.printStackTrace();
return false;
Modified: spaces/trunk/src/com/ogoglio/persist/ServiceInitializationPersistTasks.java
===================================================================
--- spaces/trunk/src/com/ogoglio/persist/ServiceInitializationPersistTasks.java 2007-07-01 20:25:27 UTC (rev 208)
+++ spaces/trunk/src/com/ogoglio/persist/ServiceInitializationPersistTasks.java 2007-07-03 02:33:29 UTC (rev 209)
@@ -18,7 +18,7 @@
import org.hibernate.SessionFactory;
-import com.ogoglio.client.WebAPIClient;
+import com.ogoglio.client.WebAPIUtil;
public class ServiceInitializationPersistTasks {
@@ -37,7 +37,7 @@
if (simRecords.length != 0) {
return;
}
- SimPersistTasks.createSim(LOCAL_SIM_DISPLAY_NAME, WebAPIClient.appendToURI(serviceURI, "sim/"), SimRecord.DEFAULT_EVENT_PORT, true, sessionFactory);
+ SimPersistTasks.createSim(LOCAL_SIM_DISPLAY_NAME, WebAPIUtil.appendToURI(serviceURI, "sim/"), SimRecord.DEFAULT_EVENT_PORT, true, sessionFactory);
}
public static void initializeLibraryAccount(SessionFactory sessionFactory,String host) throws PersistException, IOException {
Modified: spaces/trunk/src/com/ogoglio/site/AccountServlet.java
===================================================================
--- spaces/trunk/src/com/ogoglio/site/AccountServlet.java 2007-07-01 20:25:27 UTC (rev 208)
+++ spaces/trunk/src/com/ogoglio/site/AccountServlet.java 2007-07-03 02:33:29 UTC (rev 209)
@@ -29,6 +29,7 @@
import nanoxml.XMLElement;
import com.ogoglio.client.WebAPIClient;
+import com.ogoglio.client.WebAPIUtil;
import com.ogoglio.media.MediaService;
import com.ogoglio.persist.AccountPersistTasks;
import com.ogoglio.persist.AccountRecord;
@@ -725,7 +726,7 @@
if (spaceRecord != null) {
SimRecord simRecord = SpacePersistTasks.findOrAssignSim(spaceRecord, getSessionFactory());
if (simRecord != null) {
- URI thingURI = WebAPIClient.appendToURI(simRecord.getSimURI(), "space/" + record.getSpaceID() + "/thing/" + record.getThingID());
+ URI thingURI = WebAPIUtil.appendToURI(simRecord.getSimURI(), "space/" + record.getSpaceID() + "/thing/" + record.getThingID());
if (!WebAPIClient.sendDelete(thingURI, null)) {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
@@ -775,7 +776,7 @@
if (oldSpaceRecord != null) {
SimRecord simRecord = SpacePersistTasks.findOrAssignSim(oldSpaceRecord, getSessionFactory());
if (simRecord != null) {
- URI thingURI = WebAPIClient.appendToURI(simRecord.getSimURI(), "space/" + oldSpaceID + "/thing/" + oldThingID);
+ URI thingURI = WebAPIUtil.appendToURI(simRecord.getSimURI(), "space/" + oldSpaceID + "/thing/" + oldThingID);
if (!WebAPIClient.sendDelete(thingURI, null)) {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
@@ -810,7 +811,7 @@
return;
}
- URI thingsURI = WebAPIClient.appendToURI(simRecord.getSim...
[truncated message content] |
|
From: <ian...@us...> - 2007-07-05 20:40:06
|
Revision: 214
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=214&view=rev
Author: iansmith
Date: 2007-07-05 13:40:07 -0700 (Thu, 05 Jul 2007)
Log Message:
-----------
Renamed spacesync package to (correct) name of templatesync.
Added support for generating test code coverage with ant from the command line. Should have no effect on anyone not using it.
Info on how to generate code coverage data can be found here:
http://ogoglio.wiki.sourceforge.net/CodeCoverageWithEmma
Modified Paths:
--------------
spaces/trunk/build.xml
spaces/trunk/src/com/ogoglio/client/ClientTests.java
spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java
spaces/trunk/src/com/ogoglio/templatesync/SyncToolSpec.java
spaces/trunk/src/com/ogoglio/templatesync/SyncToolTest.java
Added Paths:
-----------
spaces/trunk/.settings/
spaces/trunk/.settings/org.eclipse.jdt.core.prefs
spaces/trunk/.settings/org.eclipse.jdt.ui.prefs
spaces/trunk/dev-lib/
spaces/trunk/dev-lib/emma/
spaces/trunk/dev-lib/emma/emma.jar
spaces/trunk/dev-lib/emma/emma_ant.jar
spaces/trunk/dev-lib/junit/
spaces/trunk/dev-lib/junit/ant-junit.jar
spaces/trunk/src/com/ogoglio/templatesync/
spaces/trunk/src/com/ogoglio/templatesync/TemplateSyncTestSuite.java
Removed Paths:
-------------
spaces/trunk/src/com/ogoglio/spacesync/
spaces/trunk/src/com/ogoglio/templatesync/SpaceSyncTestSuite.java
Added: spaces/trunk/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- spaces/trunk/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ spaces/trunk/.settings/org.eclipse.jdt.core.prefs 2007-07-05 20:40:07 UTC (rev 214)
@@ -0,0 +1,12 @@
+#Tue Jul 03 09:23:42 PDT 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.3
Added: spaces/trunk/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- spaces/trunk/.settings/org.eclipse.jdt.ui.prefs (rev 0)
+++ spaces/trunk/.settings/org.eclipse.jdt.ui.prefs 2007-07-05 20:40:07 UTC (rev 214)
@@ -0,0 +1,3 @@
+#Tue Jul 03 09:23:41 PDT 2007
+eclipse.preferences.version=1
+internal.default.compliance=default
Modified: spaces/trunk/build.xml
===================================================================
--- spaces/trunk/build.xml 2007-07-03 22:05:56 UTC (rev 213)
+++ spaces/trunk/build.xml 2007-07-05 20:40:07 UTC (rev 214)
@@ -5,7 +5,27 @@
<property name="tomcatHome" value="../../tomcat/" />
<property name="webLibDir" value="./war/WEB-INF/lib/" />
<property name="warName" value="ogoglio.war" />
-
+
+ <!--code coverage with emma -->
+ <property name="emmaData" value="working/emma"/>
+ <property name="coverage.dir" value="${emmaData}/reports/emma" /> <!-- directory which emma coverage reports will be written to -->
+ <property name="instr.dir" value="${emmaData}/target/emmainstr" /> <!-- directory which emma instrumentation classes will be written to -->
+ <property name="emma.dir" value="dev-lib/emma" /> <!-- directory that contains emma.jar and emma_ant.jar -->
+ <property name="emma.source_classes" value="${dest}"/>
+ <!-- Set emma.lib to refer to the list of EMMA jar files -->
+ <path id="emma.lib" >
+ <fileset dir="${emma.dir}">
+ <include name="*.jar"/>
+ </fileset>
+ </path>
+
+ <!-- which classes to work on -->
+ <path id="emma.coverage.classes" >
+ <pathelement location="${dest}" />
+ </path>
+ <!-- Load <emma> and <emmajava> custom tasks so that they can be used in ANT -->
+ <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
+
<path id="classpath">
<fileset dir="${webLibDir}">
<include name="**/*.jar" />
@@ -18,6 +38,94 @@
</fileset>
</path>
+ <!-- Enable Emma -->
+ <target name="emma" description="turns on EMMA's instrumentation/reporting" >
+
+ <property name="emma.enabled" value="true" />
+
+ <!-- EMMA instr class output directory (it is important to create this property only when EMMA is enabled) -->
+ <mkdir dir="${instr.dir}" />
+
+ <!-- this property, if overriden via -Demma.filter=<list of filter specs>
+ on ANT's command line, will set the coverage filter; by default,
+ all classes found in 'emma.coverage.classes' pathref will be instrumented:
+ -->
+ <property name="emma.filter" value="+com.ogoglio.*,-*Test*,-*Spec*" />
+ <property name="debug.on" value="true"/>
+ </target>
+
+ <target name="coverage" depends="cleanInstrumented,emma,test">
+ </target>
+
+ <target name="test" depends="compile">
+ <!-- ======================================================================= -->
+ <!-- EMMA INSTRUMENTATION -->
+ <!-- ======================================================================= -->
+ <!-- Instrument the classes, this takes the normal classes, and makes instrumented classes instead -->
+ <!-- Note that EMMA takes regular ANT path elements as instrumentation input, which is exceedingly convenient -->
+ <emma enabled="${emma.enabled}" >
+ <instr instrpath="${dest}"
+ destdir="${instr.dir}"
+ metadatafile="${coverage.dir}/metadata.emma"
+ merge="false" mode="copy" filter="${emma.filter}">
+ </instr>
+ </emma>
+ <junit fork="true" forkmode="once">
+ <classpath>
+ <pathelement location="${instr.dir}"/>
+ <fileset dir="${webLibDir}">
+ <include name="**/*.jar" />
+ </fileset>
+ <path refid="emma.lib" />
+ <pathelement location="${dest}"/>
+ </classpath>
+ <formatter type="brief" usefile="false" />
+ <test name="com.ogoglio.templatesync.TemplateSyncTestSuite" />
+ <test name="com.ogoglio.OgoglioTestSuite" />
+ <jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" />
+ <jvmarg value="-Demma.coverage.out.merge=false" />
+ </junit>
+ <!-- if enabled, generate coverage report(s): -->
+ <emma enabled="${emma.enabled}" >
+ <report sourcepath="src"
+ sort="+block,+name,+method,+class"
+ metrics="method:100,block:100,line:100,class:100"
+ >
+ <!-- collect all EMMA data dumps (metadata and runtime)
+ [this can be done via nested <fileset> fileset elements
+ or <file> elements pointing to a single file]:
+ -->
+ <fileset dir="${coverage.dir}" >
+ <include name="*.emma" />
+ </fileset>
+
+ <!-- for every type of report desired, configure a nested
+ element; various report parameters
+ can be inherited from the parent <report>
+ and individually overridden for each report type:
+ -->
+ <txt outfile="${coverage.dir}/coverage.txt"
+ depth="package"
+ columns="class,method,block,line,name"
+ />
+ <xml outfile="${coverage.dir}/coverage.xml"
+ depth="package"
+ />
+ <html outfile="${coverage.dir}/coverage.html"
+ depth="method"
+ columns="name,class,method,block,line"
+ />
+ </report>
+ </emma>
+ </target>
+
+ <target name="cleanInstrumented">
+ <delete>
+ <fileset dir="${instr.dir}" includes="**/**"/>
+ <fileset dir="${coverage.dir}" includes="**/**"/>
+ </delete>
+ </target>
+
<target name="clean">
<delete>
<fileset dir="${dest}" includes="**/*" />
@@ -36,7 +144,7 @@
</target>
<target name="compile">
- <javac source="1.4" target="1.4" srcdir="${source}" destdir="${dest}">
+ <javac source="1.4" target="1.4" srcdir="${source}" destdir="${dest}" debug="${debug.on}">
<classpath refid="classpath" />
</javac>
<copy todir="${dest}/">
Added: spaces/trunk/dev-lib/emma/emma.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/dev-lib/emma/emma.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/dev-lib/emma/emma_ant.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/dev-lib/emma/emma_ant.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/dev-lib/junit/ant-junit.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/dev-lib/junit/ant-junit.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: spaces/trunk/src/com/ogoglio/client/ClientTests.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-07-03 22:05:56 UTC (rev 213)
+++ spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-07-05 20:40:07 UTC (rev 214)
@@ -365,6 +365,7 @@
TestListener testListener = new TestListener();
space1.addListener(testListener, false);
+ assertNotNull(space1.getThing(1));
stream = space1.getThing(1).getGeometryStream(0);
assertNotNull(stream);
consume(stream);
Copied: spaces/trunk/src/com/ogoglio/templatesync (from rev 213, spaces/trunk/src/com/ogoglio/spacesync)
Deleted: spaces/trunk/src/com/ogoglio/templatesync/SpaceSyncTestSuite.java
===================================================================
--- spaces/trunk/src/com/ogoglio/spacesync/SpaceSyncTestSuite.java 2007-07-03 22:05:56 UTC (rev 213)
+++ spaces/trunk/src/com/ogoglio/templatesync/SpaceSyncTestSuite.java 2007-07-05 20:40:07 UTC (rev 214)
@@ -1,15 +0,0 @@
-package com.ogoglio.spacesync;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class SpaceSyncTestSuite {
- public static Test suite() {
- TestSuite suite = new TestSuite();
- //units
- suite.addTestSuite(SyncToolTest.class);
- //specs
- suite.addTestSuite(SyncToolSpec.class);
- return suite;
- }
-}
Modified: spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java
===================================================================
--- spaces/trunk/src/com/ogoglio/spacesync/SyncTool.java 2007-07-03 22:05:56 UTC (rev 213)
+++ spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java 2007-07-05 20:40:07 UTC (rev 214)
@@ -1,4 +1,4 @@
-package com.ogoglio.spacesync;
+package com.ogoglio.templatesync;
import java.io.File;
import java.io.IOException;
Modified: spaces/trunk/src/com/ogoglio/templatesync/SyncToolSpec.java
===================================================================
--- spaces/trunk/src/com/ogoglio/spacesync/SyncToolSpec.java 2007-07-03 22:05:56 UTC (rev 213)
+++ spaces/trunk/src/com/ogoglio/templatesync/SyncToolSpec.java 2007-07-05 20:40:07 UTC (rev 214)
@@ -1,4 +1,4 @@
-package com.ogoglio.spacesync;
+package com.ogoglio.templatesync;
import java.io.IOException;
import java.net.URI;
Modified: spaces/trunk/src/com/ogoglio/templatesync/SyncToolTest.java
===================================================================
--- spaces/trunk/src/com/ogoglio/spacesync/SyncToolTest.java 2007-07-03 22:05:56 UTC (rev 213)
+++ spaces/trunk/src/com/ogoglio/templatesync/SyncToolTest.java 2007-07-05 20:40:07 UTC (rev 214)
@@ -1,4 +1,4 @@
-package com.ogoglio.spacesync;
+package com.ogoglio.templatesync;
import java.io.File;
import java.io.IOException;
Added: spaces/trunk/src/com/ogoglio/templatesync/TemplateSyncTestSuite.java
===================================================================
--- spaces/trunk/src/com/ogoglio/templatesync/TemplateSyncTestSuite.java (rev 0)
+++ spaces/trunk/src/com/ogoglio/templatesync/TemplateSyncTestSuite.java 2007-07-05 20:40:07 UTC (rev 214)
@@ -0,0 +1,16 @@
+
+package com.ogoglio.templatesync;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class TemplateSyncTestSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ //units
+ suite.addTestSuite(SyncToolTest.class);
+ //specs
+ suite.addTestSuite(SyncToolSpec.class);
+ return suite;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2007-07-06 02:24:42
|
Revision: 215
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=215&view=rev
Author: iansmith
Date: 2007-07-05 19:24:44 -0700 (Thu, 05 Jul 2007)
Log Message:
-----------
First successful use of mocks with the WebAPIClient. Can
run tests of the template sync tool <B>without</B> having
the server up. Woo-hoo!
Modified Paths:
--------------
spaces/trunk/build.xml
spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java
spaces/trunk/src/com/ogoglio/templatesync/SyncToolSpec.java
spaces/trunk/src/com/ogoglio/templatesync/SyncToolTest.java
spaces/trunk/src/com/ogoglio/xml/TemplateDocument.java
Modified: spaces/trunk/build.xml
===================================================================
--- spaces/trunk/build.xml 2007-07-05 20:40:07 UTC (rev 214)
+++ spaces/trunk/build.xml 2007-07-06 02:24:44 UTC (rev 215)
@@ -82,6 +82,7 @@
<formatter type="brief" usefile="false" />
<test name="com.ogoglio.templatesync.TemplateSyncTestSuite" />
<test name="com.ogoglio.OgoglioTestSuite" />
+
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=false" />
</junit>
Modified: spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-07-05 20:40:07 UTC (rev 214)
+++ spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-07-06 02:24:44 UTC (rev 215)
@@ -59,9 +59,15 @@
private AuthDocument authDocument = null;
private AccountDocument accountDocument = null;
-
+ private static final URI NO_SPACE = null; /* constant representing that we want no space connection */
+
+ public WebAPIClient(URI serviceURI, String authCookie) throws IOException {
+ this(NO_SPACE,serviceURI,authCookie);
+ }
public WebAPIClient(URI spaceURI, URI serviceURI, String authCookie) throws IOException {
- ArgumentUtils.assertNotNull(spaceURI);
+ //seems that we have to allow the null spaceURI to indicate that
+ //the client has no interest in a space
+ //ArgumentUtils.assertNotNull(spaceURI);
this.spaceURI = spaceURI;
ArgumentUtils.assertNotNull(serviceURI);
this.serviceURI = serviceURI;
@@ -806,5 +812,7 @@
public URI getSettingURI(String key) {
return WebAPIUtil.appendToURI(getSettingsURI(), key + "/");
}
-
+ public String toString() {
+ return "<WebAPI:"+serviceURI+">";
+ }
}
Modified: spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java
===================================================================
--- spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java 2007-07-05 20:40:07 UTC (rev 214)
+++ spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java 2007-07-06 02:24:44 UTC (rev 215)
@@ -5,20 +5,30 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import com.ogoglio.client.WebAPIAuthenticator;
+import com.ogoglio.client.WebAPIClient;
+import com.ogoglio.xml.TemplateDocument;
public class SyncTool {
- public static final String ABORT_NO_SPACES =
- "Aborting: Checked CWD and $HOME for \"spaces\" and \".spaces\" but found none.";
+ public static final String ABORT_NO_TEMPLATES_DISK =
+ "Aborting: Checked local disk in CWD and $HOME for \"templates\" and \".templates\" but found none.";
+ public static final String ABORT_NO_TEMPLATES_SERVER =
+ "Aborting: Checked server and you don't have any templates.";
public static final String ABORT_USAGE =
"usage SyncTool username password serviceURI";
public static final String ABORT_BAD_PW =
"username/password pair unable to authenticate to that service";
private WebAPIAuthenticator theDecider=new WebAPIAuthenticator();
+ String cookie;
+ Map serverTemplateNamesToIds;
+ //Troubling: Can't test this the way I want to because the OS calls main and there is no
+ //Troubling: no way to introduce things in-between the two
public static void main(String[] args) {
SyncTool self = new SyncTool();
try {
@@ -29,7 +39,7 @@
}
}
- public List listSpacesToSynchronize(String dir) {
+ public List listTemplatesToSynchronize(String dir) {
File f = new File(dir);
List result = new ArrayList();
@@ -53,14 +63,14 @@
public List candidatesDirsFromCriticalDirs(String path1, String path2) {
List result = new ArrayList();
- result.add(path1 + File.separatorChar + "spaces");
- result.add(path1 + File.separatorChar + ".spaces");
- result.add(path2 + File.separatorChar + "spaces");
- result.add(path2 + File.separatorChar + ".spaces");
+ result.add(path1 + File.separatorChar + "templates");
+ result.add(path1 + File.separatorChar + ".templates");
+ result.add(path2 + File.separatorChar + "templates");
+ result.add(path2 + File.separatorChar + ".templates");
return result;
}
- public List findUsersSpaces() {
+ public List findUsersTemplates() {
List result=null;
String cwd=System.getProperty("user.dir");
@@ -68,7 +78,7 @@
List candidateList = candidatesDirsFromCriticalDirs(cwd, home);
for (int i=0; i<candidateList.size();++i) {
- result=listSpacesToSynchronize((String)candidateList.get(i));
+ result=listTemplatesToSynchronize((String)candidateList.get(i));
if (result!=null) {
return result;
}
@@ -76,29 +86,60 @@
return result;
}
+ //Troubling: One really can't test this properly because you can't mock System
public void abort(String msg) {
System.out.println(msg);
System.exit(1);
}
- public void start(String[] argv) throws IOException, URISyntaxException{
+ public void start(String[] argv) throws IOException, URISyntaxException{
+ URI serviceURI;
+
if (argv.length!=3) {
abort(ABORT_USAGE);
return; //if you don't understand why this is here, don't mess with it
- }
- String cookie = getAuthenticator().authenticate(new URI(argv[2]), argv[0], argv[1]);
+ }
+ serviceURI = new URI(argv[2]);
+ cookie = getAuthenticator().authenticate(serviceURI, argv[0], argv[1]);
if (cookie==null) {
abort(ABORT_BAD_PW);
return; //if you don't understand why this is here, don't mess with it
}
- List spaceNames = findUsersSpaces();
- if (spaceNames==null) {
- abort(ABORT_NO_SPACES);
+ List templateNames = findUsersTemplates();
+ if (templateNames==null) {
+ abort(ABORT_NO_TEMPLATES_DISK);
return; //if you don't understand why this is here, don't mess with it
}
+ WebAPIClient client = new WebAPIClient(serviceURI,cookie);
+ serverTemplateNamesToIds = getServerTemplateList(client);
+
+ for (int i=0; i<templateNames.size();++i) {
+ syncTemplate((String)templateNames.get(i),client);
+ }
}
+ public Map getServerTemplateList(WebAPIClient client) throws IOException {
+ System.out.println("Fetching server templates...");
+ String user = client.getAuthDocument(true).getUsername();
+ TemplateDocument docs[] = client.getTemplateDocuments(user);
+ Map result=new HashMap();
+
+ if (docs.length==0) {
+ abort(ABORT_NO_TEMPLATES_SERVER);
+ return null; //please don't mess with this
+ }
+ for (int i=0; i<docs.length; ++i) {
+ TemplateDocument doc=docs[i];
+ result.put(doc.getDisplayName(),new Long(doc.getTemplateID()));
+ }
+ return result;
+ }
+
+ public void syncTemplate(String name,WebAPIClient client) {
+
+ }
+
public WebAPIAuthenticator getAuthenticator() {
return theDecider;
}
Modified: spaces/trunk/src/com/ogoglio/templatesync/SyncToolSpec.java
===================================================================
--- spaces/trunk/src/com/ogoglio/templatesync/SyncToolSpec.java 2007-07-05 20:40:07 UTC (rev 214)
+++ spaces/trunk/src/com/ogoglio/templatesync/SyncToolSpec.java 2007-07-06 02:24:44 UTC (rev 215)
@@ -5,19 +5,26 @@
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import com.agical.rmock.extension.junit.RMockTestCase;
import com.ogoglio.client.WebAPIAuthenticator;
+import com.ogoglio.client.WebAPIClient;
+import com.ogoglio.xml.AuthDocument;
+import com.ogoglio.xml.TemplateDocument;
public class SyncToolSpec extends RMockTestCase {
- public SyncTool mock; //we use this in every spec
-
+ public SyncTool mock;
+ public WebAPIClient client;
+
public static final String SVC="http://transmutable.gov",USER="doofus",PW="somepw";
public static final String[] CMD_LINE_ARGS = { USER, PW, SVC};
- public void setUp() {
+ public void setUp() throws URISyntaxException{
mock=(SyncTool)mock(SyncTool.class);
+ client = (WebAPIClient)mock(WebAPIClient.class,
+ new Object[]{null,new URI("http://transmutable.com"),"cookie-tastic"},"client");
}
private List createFakeList(int numberOfFakeItems,String prefix) {
List result = new ArrayList();
@@ -30,20 +37,20 @@
beginSection(s.ordered("set of directories checked"));
{
- mock.findUsersSpaces();
+ mock.findUsersTemplates();
modify().forward();
mock.candidatesDirsFromCriticalDirs("cwd","home dir");
modify().args(is.NOT_NULL,is.NOT_NULL).returnValue(fakeDirList);
- mock.listSpacesToSynchronize("points to a dir");
+ mock.listTemplatesToSynchronize("points to a dir");
modify().args(is.NOT_NULL);
modify().multiplicity(expect.exactly(ITERS)).returnValue(null);
}
endSection();
startVerification();
- mock.findUsersSpaces();
+ mock.findUsersTemplates();
}
public void checkWrongNumberOfArgs(int argsSupplied) throws IOException, URISyntaxException {
@@ -92,32 +99,92 @@
mock.start(CMD_LINE_ARGS);
}
- //basically test that all the startup crap completes ok so we can get started testing that spaces
+ //basically test that all the startup crap completes ok so we can get started testing that templates
//actually can sync
- public void testSyncSpaceCalledOnceForEachSpaceName() throws IOException, URISyntaxException{
+ public void testSyncTemplateCalledOnceForEachTemplateName() throws IOException, URISyntaxException{
List fakeMagicDirs= createFakeList(2,"dir");
- List fakeSpaces = createFakeList(2,"space");
+ List fakeTemplates = createFakeList(2,"templ");
+ String COOKIE = "someCookieSoAuthOK";
- checkAuthorizationSequence("someCookieSoAuthOK");
-
+ checkAuthorizationSequence(COOKIE);
beginSection(s.ordered("order of looking in dirs makes sense"));
{
- mock.findUsersSpaces();
+ mock.findUsersTemplates();
modify().forward();
mock.candidatesDirsFromCriticalDirs("really CWD", "really $HOME");
modify().args(is.instanceOf(String.class).and(is.NOT_NULL),is.instanceOf(String.class).and(is.NOT_NULL));
modify().returnValue(fakeMagicDirs);
- mock.listSpacesToSynchronize((String)fakeMagicDirs.get(0));
+ mock.listTemplatesToSynchronize((String)fakeMagicDirs.get(0));
modify().returnValue(null);
- mock.listSpacesToSynchronize((String)fakeMagicDirs.get(1));
- modify().returnValue(fakeSpaces);
+ mock.listTemplatesToSynchronize((String)fakeMagicDirs.get(1));
+ modify().returnValue(fakeTemplates);
+
+ mock.getServerTemplateList(null);
+ modify().args(is.instanceOf(WebAPIClient.class));
+
+ mock.syncTemplate((String)fakeTemplates.get(0),null);
+ modify().args(is.AS_RECORDED,is.instanceOf(WebAPIClient.class));
+ mock.syncTemplate((String)fakeTemplates.get(1),null);
+ modify().args(is.AS_RECORDED,is.instanceOf(WebAPIClient.class));
}
endSection();
startVerification();
mock.start(CMD_LINE_ARGS);
+ assertThat(mock.cookie,is.eq(COOKIE));
}
+
+ private void prepareForCallToListTemplates(WebAPIClient api,TemplateDocument[] templates)
+ throws IOException, URISyntaxException{
+ String USER = "some user";
+
+ AuthDocument authDoc = (AuthDocument)mock(AuthDocument.class,"authDoc");
+
+ api.getAuthDocument(true);
+ modify().returnValue(authDoc);
+
+ authDoc.getUsername();
+ modify().returnValue(USER);
+
+ mock.getServerTemplateList(api);
+ modify().args(is.instanceOf(WebAPIClient.class));
+ modify().forward();
+
+ api.getTemplateDocuments("someuser");
+ modify().args(is.instanceOf(String.class)).returnValue(templates);
+
+ }
+ public void testFailsWithNoTemplates() throws IOException,URISyntaxException {
+
+ prepareForCallToListTemplates(client,new TemplateDocument[]{});
+ mock.abort(SyncTool.ABORT_NO_TEMPLATES_SERVER);
+
+ startVerification();
+ mock.getServerTemplateList(client);
+ }
+ public void testMapCreatedByListingTemplates() throws IOException,URISyntaxException {
+ String DISPLAY_NAME="myTemplate";
+ long ID=82872;
+
+ TemplateDocument templateMock = (TemplateDocument)mock(TemplateDocument.class,
+ new Object[] {new Long(ID),DISPLAY_NAME,"owner","description"},
+ "templateMock");
+
+ prepareForCallToListTemplates(client,new TemplateDocument[]{templateMock});
+
+ templateMock.getDisplayName();
+ modify().forward();
+ templateMock.getTemplateID();
+ modify().forward();
+
+ startVerification();
+ Map map = mock.getServerTemplateList(client);
+ assertThat(map.size(),is.eq(1));
+ assertThat(map.containsKey(DISPLAY_NAME),is.TRUE);
+ assertThat(map.containsValue(new Long(ID)),is.TRUE);
+ }
+
}
Modified: spaces/trunk/src/com/ogoglio/templatesync/SyncToolTest.java
===================================================================
--- spaces/trunk/src/com/ogoglio/templatesync/SyncToolTest.java 2007-07-05 20:40:07 UTC (rev 214)
+++ spaces/trunk/src/com/ogoglio/templatesync/SyncToolTest.java 2007-07-06 02:24:44 UTC (rev 215)
@@ -16,8 +16,8 @@
tool = new SyncTool();
}
public void testFindSpacesDirOnBogusDirectory_unit(){
- assertThat(tool.listSpacesToSynchronize("/foo"),is.NULL);
- assertThat(tool.listSpacesToSynchronize("/bar"),is.NULL);
+ assertThat(tool.listTemplatesToSynchronize("/foo"),is.NULL);
+ assertThat(tool.listTemplatesToSynchronize("/bar"),is.NULL);
}
public void testFindSpacesDirOnGoodDirectoryGivesAListOfDirs_unit() {
@@ -38,8 +38,8 @@
}
String path = f.getPath();
- assertThat(tool.listSpacesToSynchronize(path),is.instanceOf(List.class));
- List result = tool.listSpacesToSynchronize(path);
+ assertThat(tool.listTemplatesToSynchronize(path),is.instanceOf(List.class));
+ List result = tool.listTemplatesToSynchronize(path);
assertThat(result.size(),is.eq(2));
assertThat(result.contains(dir1),is.TRUE);
@@ -58,8 +58,8 @@
List choices = tool.candidatesDirsFromCriticalDirs(FART,BARF);
assertThat(choices.size(),is.eq(4));
- assertThat(choices.get(0),is.eq(FART+File.separatorChar+"spaces")); //prefer no dot
- assertThat(choices.get(3),is.eq(BARF+File.separatorChar+".spaces"));
+ assertThat(choices.get(0),is.eq(FART+File.separatorChar+"templates")); //prefer no dot
+ assertThat(choices.get(3),is.eq(BARF+File.separatorChar+".templates"));
}
public void testBadURIFormat() throws IOException, URISyntaxException{
@@ -70,7 +70,6 @@
expectThatExceptionThrown(is.instanceOf(IOException.class));
tool.getAuthenticator().authenticate(new URI("http://transmutable.com"), "", "no");
tool.getAuthenticator().authenticate(new URI("http://transmutable.com"), null, "no");
-
}
}
Modified: spaces/trunk/src/com/ogoglio/xml/TemplateDocument.java
===================================================================
--- spaces/trunk/src/com/ogoglio/xml/TemplateDocument.java 2007-07-05 20:40:07 UTC (rev 214)
+++ spaces/trunk/src/com/ogoglio/xml/TemplateDocument.java 2007-07-06 02:24:44 UTC (rev 215)
@@ -35,6 +35,10 @@
this(templateRecord.getTemplateID(), templateRecord.getDisplayName(), templateRecord.getOwnerUsername(), templateRecord.getDescription());
}
+ //for convenience of people who are creating this dynamically via the mock system
+ public TemplateDocument(Long templateID, String displayName, String ownerUsername, String description) {
+ this(templateID.longValue(),displayName,ownerUsername,description);
+ }
public TemplateDocument(long templateID, String displayName, String ownerUsername, String description) {
data = new XMLElement(NAME);
data.setAttribute(TEMPLATE_ID, templateID);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-07-11 20:20:29
|
Revision: 225
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=225&view=rev
Author: trevorolio
Date: 2007-07-11 13:20:31 -0700 (Wed, 11 Jul 2007)
Log Message:
-----------
Replaced the lame Mr. Boxy avatar with a better one from the Croquet project.
Removed silly cartoon face textures, replaced with text patterns.
This is a stopgap until the Grand Avatar Rewhack takes place.
Modified Paths:
--------------
spaces/trunk/src/com/ogoglio/client/ClientTests.java
spaces/trunk/src/com/ogoglio/viewer/applet/BodyConstants.java
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Eyes1.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Eyes2.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Mouth1.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Mouth2.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Nose1.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Nose2.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/avatar.jpg
spaces/trunk/src/com/ogoglio/viewer/applet/resources/avatar.obj
spaces/trunk/src/com/ogoglio/viewer/applet/resources/avatar1.jpg
spaces/trunk/src/com/ogoglio/viewer/j3d/J3DRenderer.java
spaces/trunk/src/com/ogoglio/viewer/j3d/body/Skin.java
Added Paths:
-----------
spaces/trunk/art/GlassHouse/lawn3.jpg
spaces/trunk/art/GlassHouse/rock10.gif
spaces/trunk/art/Mike/
spaces/trunk/art/Mike/License.txt
spaces/trunk/art/Mike/MikeOg.blend
spaces/trunk/art/Mike/MikeOg.mtl
spaces/trunk/art/Mike/MikeOg.obj
spaces/trunk/art/Mike/MikeOgArmsDown.blend
spaces/trunk/art/Mike/MikeOgArmsDown.obj
spaces/trunk/art/Mike/mike.jpg
Removed Paths:
-------------
spaces/trunk/art/MissBoxy/
spaces/trunk/art/MrBoxy/
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Eyes10.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Eyes11.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Eyes12.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Eyes3.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Eyes4.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Eyes5.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Eyes6.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Eyes7.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Eyes8.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Eyes9.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Mouth10.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Mouth11.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Mouth12.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Mouth3.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Mouth4.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Mouth5.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Mouth6.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Mouth7.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Mouth8.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Mouth9.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Nose10.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Nose3.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Nose4.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Nose5.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Nose6.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Nose7.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Nose8.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/Nose9.gif
spaces/trunk/src/com/ogoglio/viewer/applet/resources/avatar2.jpg
spaces/trunk/src/com/ogoglio/viewer/applet/resources/avatar3.jpg
Added: spaces/trunk/art/GlassHouse/lawn3.jpg
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/art/GlassHouse/lawn3.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/art/GlassHouse/rock10.gif
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/art/GlassHouse/rock10.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/art/Mike/License.txt
===================================================================
--- spaces/trunk/art/Mike/License.txt (rev 0)
+++ spaces/trunk/art/Mike/License.txt 2007-07-11 20:20:31 UTC (rev 225)
@@ -0,0 +1,9 @@
+The Croquet License
+
+Copyright © 2002-2007 by The Croquet Consortium, Inc. and other individual, corporate, and institutional contributors who have collectively contributed elements of the CroquetTM software code to the Croquet Project. CroquetTM is a trademark of The Croquet Consortium, Inc..
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Added: spaces/trunk/art/Mike/MikeOg.blend
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/art/Mike/MikeOg.blend
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/art/Mike/MikeOg.mtl
===================================================================
--- spaces/trunk/art/Mike/MikeOg.mtl (rev 0)
+++ spaces/trunk/art/Mike/MikeOg.mtl 2007-07-11 20:20:31 UTC (rev 225)
@@ -0,0 +1,13 @@
+# Blender3D MTL File: MikeOg.blend
+# Material Count: 1
+newmtl lambert3SG_mike2.3.jp_mike.jpg
+Ns 92.156863
+Ka 0.000000 0.000000 0.000000
+Kd 0.640000 0.640000 0.640000
+Ks 0.250000 0.250000 0.250000
+Ni 1.000000
+d 1.000000
+illum 2
+map_Kd mike.jpg
+
+
Added: spaces/trunk/art/Mike/MikeOg.obj
===================================================================
--- spaces/trunk/art/Mike/MikeOg.obj (rev 0)
+++ spaces/trunk/art/Mike/MikeOg.obj 2007-07-11 20:20:31 UTC (rev 225)
@@ -0,0 +1,7401 @@
+# Blender3D v243 OBJ File: MikeOg.blend
+# www.blender3d.org
+mtllib MikeOg.mtl
+o lHand_lambert3SG_mik
+v 0.304331 1.600250 -0.106217
+v 0.296387 1.540905 -0.123080
+v 0.222721 1.536892 -0.125699
+v 0.224254 1.603192 -0.104775
+v 0.288443 1.475208 -0.100581
+v 0.235947 1.450956 -0.117817
+v 0.221188 1.453990 -0.011827
+v 0.288443 1.467295 -0.035953
+v 0.296387 1.519913 0.024538
+v 0.222721 1.515002 0.023864
+v 0.304331 1.590295 0.014126
+v 0.224254 1.588909 0.000483
+v 0.307621 1.622676 -0.050612
+v 0.224889 1.616153 -0.053476
+v 0.031699 1.631706 0.018797
+v 0.000028 1.626968 0.027862
+v 0.000028 1.572805 0.023299
+v 0.047934 1.581856 0.014421
+v 0.031184 1.632111 0.040990
+v 0.000028 1.625232 0.060530
+v 0.021510 1.642458 0.070554
+v 0.000028 1.637987 0.079617
+v 0.015679 1.662722 0.075168
+v 0.000028 1.662424 0.079744
+v 0.012151 1.683332 0.081626
+v 0.000028 1.682390 0.085443
+v 0.008928 1.689377 0.077621
+v 0.000028 1.689389 0.079847
+v 0.011830 1.694796 0.085648
+v 0.000028 1.694486 0.087556
+v 0.020156 1.715386 0.079020
+v 0.000028 1.711260 0.088192
+v 0.014540 1.722568 0.094598
+v 0.000028 1.716367 0.100731
+v 0.013391 1.731593 0.091547
+v 0.000028 1.727371 0.103264
+v 0.006782 1.750099 0.087120
+v 0.000028 1.751144 0.092659
+v 0.014590 1.813361 0.085290
+v 0.000028 1.813361 0.085290
+v 0.000028 1.780439 0.088549
+v 0.010351 1.776019 0.082854
+v 0.029413 1.877446 0.032680
+v 0.000028 1.880973 0.036731
+v 0.000028 1.848225 0.073969
+v 0.021541 1.846084 0.071437
+v 0.029413 1.876206 -0.057265
+v 0.000028 1.879162 -0.059238
+v 0.037931 1.809009 -0.123248
+v 0.000028 1.810443 -0.125912
+v 0.037256 1.746803 -0.116906
+v 0.000028 1.746742 -0.119888
+v 0.030105 1.664945 -0.079885
+v 0.000028 1.664942 -0.080338
+v 0.000028 1.700917 -0.094458
+v 0.036735 1.699393 -0.090184
+v 0.031534 1.630601 -0.079179
+v 0.000028 1.627309 -0.082668
+v 0.009101 1.764093 0.080396
+v 0.000028 1.763571 0.085736
+v 0.026224 1.774747 0.069976
+v 0.039634 1.772987 0.065589
+v 0.048803 1.786524 0.069047
+v 0.027398 1.788332 0.080073
+v 0.046901 1.764903 0.058095
+v 0.055902 1.762505 0.047194
+v 0.038560 1.760040 0.065658
+v 0.047132 1.747054 0.061318
+v 0.026278 1.760335 0.071309
+v 0.025330 1.744685 0.070920
+v 0.018099 1.762180 0.074697
+v 0.013074 1.747909 0.077025
+v 0.021834 1.729899 0.077289
+v 0.031796 1.729389 0.067836
+v 0.051985 1.729992 0.044445
+v 0.067682 1.763677 0.032037
+v 0.057938 1.799245 0.056789
+v 0.031470 1.810491 0.077698
+v 0.021774 1.693801 0.078791
+v 0.037464 1.705666 0.065347
+v 0.032143 1.689974 0.069280
+v 0.045512 1.686672 0.060492
+v 0.020257 1.686101 0.075782
+v 0.035483 1.666855 0.068222
+v 0.018793 1.767937 0.074748
+v 0.010123 1.775553 0.082756
+v 0.052757 1.703952 0.043951
+v 0.055278 1.685174 0.040365
+v 0.045141 1.655043 0.047800
+v 0.047941 1.838674 0.052654
+v 0.071829 1.814402 0.025533
+v 0.077815 1.771814 0.010856
+v 0.065991 1.732158 0.013487
+v 0.063512 1.704866 0.011598
+v 0.062024 1.681645 0.012739
+v 0.051753 1.648090 0.012236
+v 0.052706 1.646567 0.001524
+v 0.076040 1.604901 -0.021773
+v 0.082029 1.625612 -0.043365
+v 0.059421 1.664253 -0.024530
+v 0.057857 1.864283 0.025120
+v 0.057263 1.862222 -0.052979
+v 0.068615 1.799755 -0.103134
+v 0.062396 1.745273 -0.098058
+v 0.057438 1.700431 -0.073833
+v 0.056821 1.666496 -0.056203
+v 0.064720 1.626966 -0.058248
+v 0.079998 1.823396 -0.004581
+v 0.080713 1.824307 -0.050449
+v 0.086055 1.790256 -0.076830
+v 0.076318 1.746401 -0.068716
+v 0.067574 1.704440 -0.042797
+v 0.069624 1.708378 -0.012426
+v 0.073828 1.737170 -0.016729
+v 0.089655 1.744526 -0.028393
+v 0.090162 1.762365 -0.024583
+v 0.075351 1.737649 -0.003943
+v 0.068021 1.712675 -0.005750
+v 0.082387 1.715925 -0.014000
+v 0.075238 1.743044 -0.030738
+v 0.090962 1.744318 -0.037111
+v 0.079665 1.708886 -0.017767
+v 0.083318 1.761969 -0.035899
+v 0.092272 1.766689 -0.038393
+v 0.085829 1.771837 -0.021522
+v 0.084842 1.769044 -0.013992
+v 0.092272 1.777364 -0.021593
+v 0.085890 1.792359 -0.014779
+v 0.000028 1.502440 0.076393
+v 0.096259 1.511947 0.056833
+v 0.000028 1.585110 -0.121379
+v 0.064656 1.587060 -0.116044
+v 0.124488 1.600167 -0.001619
+v 0.130205 1.625669 -0.047954
+v 0.103155 1.614673 -0.092544
+v 0.172321 1.517763 0.038396
+v 0.178505 1.597546 -0.006514
+v 0.179251 1.623526 -0.054926
+v 0.163499 1.605183 -0.094448
+v 0.152823 1.552933 -0.123240
+v 0.070229 1.484656 -0.139732
+v 0.000028 1.485200 -0.145575
+v 0.157850 1.477547 -0.132386
+v 0.000028 1.432783 0.099374
+v 0.086547 1.438363 0.091618
+v 0.179155 1.445502 0.072994
+v 0.214723 1.364257 0.008880
+v 0.215389 1.361520 -0.101872
+v 0.073390 1.379866 -0.151309
+v 0.000028 1.380873 -0.157741
+v 0.159049 1.374304 -0.140306
+v 0.000028 1.323022 0.126264
+v 0.079331 1.338232 0.119767
+v 0.165847 1.374576 0.079141
+v 0.383628 1.592956 -0.101051
+v 0.381070 1.537482 -0.116199
+v 0.355178 1.492323 -0.096047
+v 0.355959 1.485251 -0.037948
+v 0.363298 1.518615 -0.003143
+v 0.384434 1.588335 0.012610
+v 0.384431 1.615165 -0.051075
+v 0.469814 1.577306 -0.106558
+v 0.467358 1.535360 -0.113745
+v 0.466522 1.478255 -0.094326
+v 0.467273 1.471466 -0.038550
+v 0.469337 1.517294 0.003606
+v 0.470587 1.570560 -0.002456
+v 0.470584 1.597293 -0.051158
+v 0.522828 1.578179 -0.100886
+v 0.520203 1.535469 -0.110605
+v 0.519311 1.474441 -0.090377
+v 0.520113 1.476521 -0.037463
+v 0.520232 1.516040 -0.008306
+v 0.523654 1.571883 -0.006896
+v 0.523651 1.601616 -0.050887
+v 0.600760 1.565869 -0.092559
+v 0.598421 1.526450 -0.100785
+v 0.597626 1.470024 -0.087667
+v 0.598341 1.472230 -0.039332
+v 0.600306 1.508458 -0.013182
+v 0.601496 1.561100 -0.011875
+v 0.601493 1.587546 -0.051312
+v 0.682410 1.544939 -0.083438
+v 0.680918 1.519891 -0.092873
+v 0.680410 1.485834 -0.080355
+v 0.680867 1.481799 -0.044360
+v 0.682121 1.502849 -0.017107
+v 0.682880 1.540917 -0.021039
+v 0.682879 1.556849 -0.052464
+v 0.738177 1.529207 -0.076113
+v 0.736795 1.516347 -0.094309
+v 0.736325 1.492726 -0.079256
+v 0.736747 1.489216 -0.047591
+v 0.737909 1.507535 -0.024136
+v 0.738611 1.528345 -0.031153
+v 0.738610 1.533484 -0.054837
+v 0.789913 1.513130 -0.100630
+v 0.789222 1.505622 -0.102482
+v 0.788753 1.491242 -0.086173
+v 0.789175 1.499566 -0.044012
+v 0.773335 1.493167 -0.013695
+v 0.773650 1.512223 -0.012046
+v 0.774038 1.522389 -0.018902
+v 0.791784 1.533675 -0.053799
+v 0.791214 1.525938 -0.092451
+v 0.837912 1.520402 -0.105583
+v 0.837460 1.506294 -0.108686
+v 0.836990 1.497969 -0.088851
+v 0.820914 1.506526 -0.065095
+v 0.821898 1.503872 -0.050581
+v 0.800406 1.518695 -0.003293
+v 0.799462 1.507955 0.007034
+v 0.838925 1.503900 0.022058
+v 0.839276 1.516835 0.012564
+v 0.807672 1.523652 -0.016726
+v 0.804939 1.528006 -0.030385
+v 0.824356 1.533153 -0.068367
+v 0.839201 1.530334 -0.082460
+v 0.838841 1.528333 -0.092464
+v 0.859235 1.522249 -0.108760
+v 0.859036 1.506522 -0.110821
+v 0.858765 1.498682 -0.092510
+v 0.858885 1.503455 -0.079815
+v 0.836566 1.499463 -0.077008
+v 0.838573 1.491511 -0.009854
+v 0.837585 1.499221 -0.020484
+v 0.864041 1.502566 -0.025545
+v 0.860348 1.500532 -0.009902
+v 0.839276 1.524838 -0.014681
+v 0.840523 1.506955 -0.011404
+v 0.860634 1.513422 -0.006401
+v 0.865328 1.524838 -0.014681
+v 0.860759 1.530880 -0.079728
+v 0.866331 1.532980 -0.069234
+v 0.859633 1.512757 -0.085717
+v 0.863851 1.506192 -0.066601
+v 0.865317 1.513609 -0.062357
+v 0.864543 1.507431 -0.053476
+v 0.864420 1.512717 -0.032154
+v 0.863472 1.505532 -0.039154
+v 0.860616 1.524960 -0.099549
+v 0.866417 1.534554 -0.055531
+v 0.865327 1.536128 -0.041828
+v 0.865327 1.530809 -0.025351
+v 0.803205 1.486733 -0.011015
+v 0.838573 1.492685 0.017071
+v 0.799158 1.498167 0.001482
+v 0.891615 1.499343 -0.001214
+v 0.892218 1.509485 0.003385
+v 0.901452 1.498307 0.011405
+v 0.891120 1.487886 0.005371
+v 0.891120 1.488154 0.017677
+v 0.886690 1.514008 -0.111373
+v 0.886524 1.500083 -0.110265
+v 0.888136 1.518998 -0.099962
+v 0.887099 1.508105 -0.090487
+v 0.886253 1.496068 -0.097425
+v 0.921159 1.499482 -0.099382
+v 0.927390 1.488119 -0.102944
+v 0.918529 1.496051 -0.109616
+v 0.944218 1.502344 -0.069752
+v 0.950866 1.495268 -0.072723
+v 0.944088 1.501952 -0.077032
+v 0.823210 1.535991 -0.054175
+v 0.822735 1.531240 -0.036998
+v 0.837239 1.528039 -0.025840
+v 0.945234 1.505500 -0.054082
+v 0.953337 1.496222 -0.046890
+v 0.950246 1.493396 -0.056367
+v 0.943338 1.499045 -0.012707
+v 0.951247 1.491158 -0.017419
+v 0.943020 1.497881 -0.022910
+v 0.805763 1.491765 -0.027268
+v 0.826931 1.500960 -0.029517
+v 0.840207 1.514971 -0.005417
+v 0.874909 1.501528 0.029720
+v 0.875457 1.514709 0.020654
+v 0.866423 1.490602 0.022250
+v 0.866423 1.485831 0.007494
+v 0.866917 1.498909 -0.002503
+v 0.892709 1.503338 -0.064919
+v 0.893581 1.513609 -0.062357
+v 0.892603 1.503006 -0.079812
+v 0.893446 1.513073 -0.082163
+v 0.894478 1.525528 -0.079700
+v 0.894595 1.525330 -0.069193
+v 0.892906 1.506051 -0.038887
+v 0.893710 1.520154 -0.035779
+v 0.892808 1.505324 -0.051371
+v 0.893652 1.514591 -0.058199
+v 0.894682 1.528550 -0.055499
+v 0.894768 1.529590 -0.041793
+v 0.894090 1.503411 -0.010392
+v 0.894356 1.513431 -0.007127
+v 0.893524 1.499690 -0.022715
+v 0.894039 1.512964 -0.026321
+v 0.894742 1.523085 -0.024191
+v 0.894743 1.523767 -0.011837
+v 0.867520 1.514539 0.003358
+v 0.892218 1.507195 0.014763
+v 0.891669 1.497847 0.022643
+v 0.909566 1.499300 -0.090906
+v 0.912363 1.509373 -0.099956
+v 0.906586 1.487359 -0.097379
+v 0.907564 1.491264 -0.110218
+v 0.910183 1.504920 -0.110858
+v 0.923133 1.496300 -0.066912
+v 0.925779 1.505085 -0.062312
+v 0.922985 1.496786 -0.079779
+v 0.925570 1.504579 -0.082118
+v 0.928754 1.512097 -0.078431
+v 0.928826 1.512635 -0.069125
+v 0.927940 1.500531 -0.038858
+v 0.931186 1.511887 -0.035735
+v 0.927728 1.499028 -0.051337
+v 0.930181 1.506417 -0.058155
+v 0.933624 1.514845 -0.055426
+v 0.933878 1.515854 -0.041720
+v 0.922297 1.495451 -0.009875
+v 0.924454 1.505151 -0.006357
+v 0.921291 1.494400 -0.022687
+v 0.924050 1.504702 -0.027003
+v 0.930001 1.509544 -0.024680
+v 0.930117 1.511114 -0.011396
+v 0.926892 1.490732 -0.091857
+v 0.922131 1.480756 -0.097676
+v 0.923705 1.484016 -0.109209
+v 0.944121 1.487766 -0.067935
+v 0.947447 1.493951 -0.064409
+v 0.944022 1.488026 -0.078076
+v 0.947224 1.493595 -0.079903
+v 0.949296 1.490323 -0.040035
+v 0.951986 1.497766 -0.037379
+v 0.948877 1.489110 -0.050604
+v 0.945603 1.506296 -0.042475
+v 0.943004 1.484630 -0.011093
+v 0.946366 1.492164 -0.008315
+v 0.942189 1.484247 -0.021637
+v 0.945917 1.491709 -0.025009
+v 0.207279 1.262289 0.009423
+v 0.207944 1.259632 -0.086365
+v 0.073390 1.270047 -0.153715
+v 0.000028 1.272736 -0.157165
+v 0.159049 1.268044 -0.131835
+v 0.000028 1.221030 0.122269
+v 0.079331 1.236226 0.113130
+v 0.157171 1.249832 0.061838
+v 0.189642 1.145092 0.010047
+v 0.190257 1.142489 -0.075598
+v 0.072125 1.150118 -0.141909
+v 0.000028 1.154047 -0.145366
+v 0.151282 1.144697 -0.120011
+v 0.000028 1.119637 0.113262
+v 0.077615 1.126515 0.107446
+v 0.149547 1.140154 0.062422
+v 0.202120 1.024396 0.006254
+v 0.202769 1.021798 -0.078476
+v 0.071487 1.023475 -0.160002
+v 0.000028 1.025455 -0.172710
+v 0.155063 1.020199 -0.137691
+v 0.000028 1.023361 0.101139
+v 0.077283 1.021062 0.098712
+v 0.153231 1.018956 0.059647
+v 0.212868 0.893113 0.008272
+v 0.213527 0.890552 -0.069346
+v 0.076441 0.874148 -0.153219
+v 0.009048 0.900586 -0.161306
+v 0.160415 0.886373 -0.123576
+v -0.001617 0.944486 0.084257
+v 0.082320 0.882676 0.072629
+v 0.158556 0.885042 0.057199
+v 0.225138 0.781897 0.004952
+v 0.225859 0.779286 -0.065270
+v 0.006475 0.834195 -0.119823
+v 0.082086 0.771191 -0.132787
+v 0.030276 0.774394 -0.116744
+v 0.161427 0.774970 -0.114331
+v -0.002759 0.878070 0.033001
+v 0.017565 0.783412 0.007736
+v 0.088522 0.770976 0.063186
+v 0.159393 0.773451 0.049224
+v 0.217959 0.661961 0.008615
+v 0.227125 0.661442 -0.053430
+v 0.110671 0.660475 -0.112178
+v 0.047579 0.661961 -0.099373
+v 0.178906 0.660851 -0.099987
+v 0.030220 0.661964 0.020241
+v 0.099755 0.661246 0.052429
+v 0.161021 0.661433 0.047079
+v 0.004361 0.782228 -0.041446
+v 0.015067 0.661964 -0.043784
+v 0.002100 0.830725 -0.042353
+v 0.202083 0.547625 0.018311
+v 0.209725 0.547099 -0.044872
+v 0.112638 0.546127 -0.104697
+v 0.061107 0.547614 -0.091657
+v 0.169525 0.546504 -0.092282
+v 0.045960 0.547629 0.030150
+v 0.103538 0.546914 0.062928
+v 0.154615 0.547100 0.057481
+v 0.033328 0.547623 -0.035048
+v 0.194044 0.430189 0.017913
+v 0.201076 0.429672 -0.043620
+v 0.111733 0.428709 -0.101883
+v 0.064312 0.430193 -0.089185
+v 0.164083 0.429084 -0.089793
+v 0.051622 0.430191 0.029443
+v 0.103359 0.429472 0.061366
+v 0.150362 0.429659 0.056060
+v 0.040544 0.430194 -0.034053
+v 0.179260 0.313693 0.010371
+v 0.185456 0.313198 -0.047184
+v 0.106733 0.312254 -0.101680
+v 0.064949 0.313734 -0.089803
+v 0.152860 0.312625 -0.090371
+v 0.057723 0.313691 0.021156
+v 0.099354 0.312961 0.051015
+v 0.140770 0.313150 0.046052
+v 0.044007 0.313716 -0.038236
+v 0.179260 0.206281 0.007359
+v 0.185456 0.205793 -0.048751
+v 0.106733 0.204856 -0.101879
+v 0.064949 0.206335 -0.090300
+v 0.152860 0.205226 -0.090854
+v 0.057723 0.206277 0.017874
+v 0.099354 0.205543 0.046983
+v 0.140770 0.205732 0.042145
+v 0.044007 0.206310 -0.040027
+v 0.169448 0.104158 0.007903
+v 0.183630 0.103612 -0.059239
+v 0.106733 0.102676 -0.112368
+v 0.064949 0.104154 -0.100789
+v 0.152860 0.103045 -0.101343
+v 0.061859 0.104155 0.018417
+v 0.100354 0.103421 0.047527
+v 0.139357 0.103610 0.042689
+v 0.047859 0.104129 -0.050516
+v 0.172974 0.041935 0.027165
+v 0.183536 0.014943 -0.057919
+v 0.106733 0.016611 -0.111909
+v 0.064949 0.018090 -0.100330
+v 0.152860 0.014594 -0.100872
+v 0.099354 0.066991 0.178308
+v 0.064241 0.052160 0.149281
+v 0.064241 0.020018 0.149452
+v 0.099354 0.014545 0.178587
+v 0.140770 0.067181 0.173470
+v 0.140770 0.014735 0.173749
+v 0.168786 0.052163 0.138767
+v 0.168786 0.011892 0.138981
+v 0.047859 0.015453 -0.050044
+v 0.060053 0.041878 0.027632
+v 0.059170 0.088333 0.073877
+v 0.099354 0.098421 0.073759
+v 0.059170 0.013914 0.086632
+v 0.094056 0.025552 0.024895
+v 0.099354 0.005925 0.086611
+v 0.140770 0.098637 0.073774
+v 0.139357 0.025766 0.024679
+v 0.140770 0.006141 0.086625
+v 0.173857 0.088392 0.073881
+v 0.173857 0.013973 0.086636
+v 0.149148 0.005500 -0.059990
+v 0.104143 0.005216 -0.059601
+v 0.018645 1.689344 0.071362
+v 0.028032 1.766450 0.073041
+v 0.036296 1.766312 0.069204
+v -0.304276 1.600250 -0.106217
+v -0.224199 1.603192 -0.104775
+v -0.222666 1.536892 -0.125699
+v -0.296332 1.540905 -0.123080
+v -0.235892 1.450956 -0.117817
+v -0.288388 1.475208 -0.100581
+v -0.221133 1.453990 -0.011827
+v -0.288388 1.467295 -0.035953
+v -0.222666 1.515002 0.023864
+v -0.296332 1.519913 0.024538
+v -0.224199 1.588909 0.000483
+v -0.304276 1.590295 0.014126
+v -0.224834 1.616153 -0.053476
+v -0.307566 1.622676 -0.050612
+v -0.031644 1.631706 0.018797
+v -0.047879 1.581856 0.014421
+v -0.031129 1.632111 0.040990
+v -0.021455 1.642458 0.070554
+v -0.015624 1.662722 0.075168
+v -0.012095 1.683332 0.081626
+v -0.008873 1.689377 0.077621
+v -0.011775 1.694796 0.085648
+v -0.020101 1.715386 0.079020
+v -0.014484 1.722568 0.094598
+v -0.013336 1.731593 0.091547
+v -0.006727 1.750099 0.087120
+v -0.014535 1.813361 0.085290
+v -0.010296 1.776019 0.082854
+v -0.029358 1.877446 0.032680
+v -0.021486 1.846084 0.071437
+v -0.029358 1.876206 -0.057265
+v -0.037876 1.809009 -0.123248
+v -0.037164 1.744622 -0.116026
+v -0.030050 1.664982 -0.072929
+v -0.036679 1.699393 -0.090184
+v -0.031479 1.630601 -0.079179
+v -0.009046 1.764093 0.080396
+v -0.026169 1.774747 0.069976
+v -0.027342 1.788333 0.080073
+v -0.048747 1.786524 0.069047
+v -0.039579 1.772987 0.065589
+v -0.055847 1.762505 0.047194
+v -0.046846 1.764903 0.058095
+v -0.047077 1.747054 0.061318
+v -0.038505 1.760040 0.065658
+v -0.025275 1.744685 0.070920
+v -0.026223 1.760335 0.071309
+v -0.018044 1.762180 0.074697
+v -0.013018 1.747909 0.077025
+v -0.031741 1.729389 0.067836
+v -0.021779 1.729899 0.077289
+v -0.051930 1.729992 0.044445
+v -0.067627 1.763677 0.032037
+v -0.057883 1.799245 0.056789
+v -0.031414 1.810491 0.077698
+v -0.037409 1.705666 0.065347
+v -0.021719 1.693801 0.078791
+v -0.045456 1.686672 0.060492
+v -0.032087 1.689974 0.069280
+v -0.035427 1.666855 0.068222
+v -0.020202 1.686101 0.075782
+v -0.018738 1.767937 0.074748
+v -0.010067 1.775553 0.082756
+v -0.052702 1.703952 0.043951
+v -0.051840 1.685174 0.040365
+v -0.045086 1.655043 0.047800
+v -0.047886 1.838674 0.052654
+v -0.071774 1.814402 0.025533
+v -0.077760 1.771814 0.010856
+v -0.065935 1.732158 0.013487
+v -0.063456 1.704866 0.011598
+v -0.061969 1.681645 0.012739
+v -0.051698 1.648127 0.019192
+v -0.052651 1.646567 0.001524
+v -0.059366 1.664253 -0.024530
+v -0.081974 1.625612 -0.043365
+v -0.075985 1.604901 -0.021773
+v -0.057801 1.864283 0.025120
+v -0.057208 1.862222 -0.052979
+v -0.068560 1.799755 -0.103134
+v -0.062184 1.744302 -0.097736
+v -0.056765 1.666496 -0.056203
+v -0.057383 1.700431 -0.073833
+v -0.064665 1.626966 -0.058248
+v -0.079943 1.823396 -0.004581
+v -0.080657 1.824307 -0.050449
+v -0.086000 1.790256 -0.076830
+v -0.075170 1.742465 -0.067192
+v -0.067519 1.704440 -0.042797
+v -0.069569 1.708378 -0.012426
+v -0.073773 1.737170 -0.016729
+v -0.090107 1.762365 -0.024583
+v -0.089600 1.744526 -0.028393
+v -0.075296 1.737649 -0.003943
+v -0.082332 1.715925 -0.014000
+v -0.067966 1.712675 -0.005750
+v -0.079610 1.708886 -0.017767
+v -0.090906 1.744318 -0.037111
+v -0.075183 1.743044 -0.030738
+v -0.092217 1.766689 -0.038393
+v -0.083263 1.761969 -0.035899
+v -0.085774 1.771837 -0.021522
+v -0.092217 1.777364 -0.021593
+v -0.084787 1.769045 -0.013992
+v -0.085834 1.792359 -0.014779
+v -0.096204 1.511947 0.056833
+v -0.064601 1.587060 -0.116044
+v -0.130150 1.625669 -0.047954
+v -0.124433 1.600167 -0.001619
+v -0.103100 1.614673 -0.092544
+v -0.178449 1.597546 -0.006514
+v -0.172265 1.517763 0.038396
+v -0.163444 1.605183 -0.094448
+v -0.179196 1.623526 -0.054926
+v -0.152768 1.552933 -0.123240
+v -0.070174 1.484656 -0.139732
+v -0.157795 1.477547 -0.132386
+v -0.086491 1.438363 0.091618
+v -0.179100 1.445502 0.072994
+v -0.215334 1.361520 -0.101872
+v -0.214668 1.364257 0.008880
+v -0.073335 1.379866 -0.151309
+v -0.158994 1.374304 -0.140306
+v -0.079276 1.338232 0.119767
+v -0.165792 1.374654 0.093710
+v -0.381015 1.537482 -0.116199
+v -0.383573 1.592956 -0.101051
+v -0.355122 1.492323 -0.096047
+v -0.355904 1.485251 -0.037948
+v -0.363243 1.518615 -0.003143
+v -0.384379 1.588335 0.012610
+v -0.384376 1.615165 -0.051075
+v -0.467303 1.535360 -0.113745
+v -0.469759 1.577306 -0.106558
+v -0.466467 1.478255 -0.094326
+v -0.467218 1.471466 -0.038550
+v -0.469282 1.517294 0.003606
+v -0.470532 1.570560 -0.002456
+v -0.470529 1.597293 -0.051158
+v -0.520148 1.535469 -0.110605
+v -0.522773 1.578179 -0.100886
+v -0.519255 1.474441 -0.090377
+v -0.520057 1.476521 -0.037463
+v -0.520176 1.516040 -0.008306
+v -0.523599 1.571883 -0.006896
+v -0.523596 1.601616 -0.050887
+v -0.598366 1.526450 -0.100785
+v -0.600704 1.565869 -0.092559
+v -0.597571 1.470024 -0.087667
+v -0.598285 1.472230 -0.039332
+v -0.600251 1.508458 -0.013182
+v -0.601440 1.561100 -0.011875
+v -0.601438 1.587546 -0.051312
+v -0.680863 1.519891 -0.092873
+v -0.682355 1.544939 -0.083438
+v -0.680355 1.485834 -0.080355
+v -0.680811 1.481799 -0.044360
+v -0.682066 1.502849 -0.017107
+v -0.682825 1.540917 -0.021039
+v -0.682823 1.556849 -0.052464
+v -0.736740 1.516347 -0.094309
+v -0.738121 1.529207 -0.076113
+v -0.736270 1.492726 -0.079256
+v -0.736692 1.489216 -0.047591
+v -0.737853 1.507535 -0.024136
+v -0.738556 1.528345 -0.031153
+v -0.738555 1.533484 -0.054837
+v -0.789167 1.505622 -0.102482
+v -0.789858 1.513130 -0.100630
+v -0.788697 1.491242 -0.086173
+v -0.789119 1.499566 -0.044012
+v -0.773280 1.493167 -0.013695
+v -0.773983 1.522389 -0.018902
+v -0.773595 1.512223 -0.012046
+v -0.791729 1.533675 -0.053799
+v -0.791158 1.525938 -0.092451
+v -0.837405 1.506294 -0.108686
+v -0.837857 1.520402 -0.105583
+v -0.836935 1.497969 -0.088851
+v -0.821843 1.503872 -0.050581
+v -0.820859 1.506526 -0.065095
+v -0.800351 1.518695 -0.003293
+v -0.839221 1.516835 0.012564
+v -0.838870 1.503900 0.022058
+v -0.799407 1.507955 0.007034
+v -0.804884 1.528006 -0.030385
+v -0.807617 1.523652 -0.016726
+v -0.838786 1.528333 -0.092464
+v -0.839145 1.530334 -0.082460
+v -0.824301 1.533153 -0.068367
+v -0.859179 1.522249 -0.108760
+v -0.858980 1.506522 -0.110821
+v -0.836511 1.499463 -0.077008
+v -0.858829 1.503455 -0.079815
+v -0.858709 1.498682 -0.092510
+v -0.838518 1.491511 -0.009854
+v -0.860293 1.500532 -0.009902
+v -0.863986 1.502566 -0.025545
+v -0.837530 1.499221 -0.020484
+v -0.839221 1.524838 -0.014681
+v -0.865273 1.524837 -0.014681
+v -0.860579 1.513422 -0.006401
+v -0.840468 1.506955 -0.011404
+v -0.860704 1.530880 -0.079728
+v -0.866275 1.532980 -0.069234
+v -0.859577 1.512757 -0.085717
+v -0.863796 1.506192 -0.066601
+v -0.864488 1.507431 -0.053476
+v -0.865262 1.513609 -0.062357
+v -0.864365 1.512717 -0.032154
+v -0.863417 1.505532 -0.039154
+v -0.860561 1.524960 -0.099549
+v -0.866362 1.534554 -0.055531
+v -0.865272 1.536128 -0.041828
+v -0.865272 1.530809 -0.025351
+v -0.803150 1.486733 -0.011015
+v -0.799102 1.498167 0.001482
+v -0.838518 1.492685 0.017071
+v -0.891560 1.499343 -0.001214
+v -0.901396 1.498307 0.011405
+v -0.892163 1.509485 0.003385
+v -0.891065 1.487886 0.005371
+v -0.891065 1.488154 0.017677
+v -0.886469 1.500083 -0.110265
+v -0.886635 1.514008 -0.111373
+v -0.888081 1.518998 -0.099962
+v -0.887043 1.508105 -0.090487
+v -0.886197 1.496068 -0.097425
+v -0.921104 1.499482 -0.099382
+v -0.918473 1.496051 -0.109616
+v -0.927335 1.488119 -0.102944
+v -0.944162 1.502344 -0.069752
+v -0.944033 1.501952 -0.077032
+v -0.950811 1.495268 -0.072723
+v -0.823155 1.535991 -0.054175
+v -0.837184 1.528039 -0.025840
+v -0.822680 1.531240 -0.036998
+v -0.945179 1.505500 -0.054082
+v -0.950190 1.493396 -0.056367
+v -0.953281 1.496222 -0.046890
+v -0.943283 1.499045 -0.012707
+v -0.942965 1.497881 -0.022910
+v -0.951192 1.491158 -0.017419
+v -0.805708 1.491765 -0.027268
+v -0.826875 1.500960 -0.029517
+v -0.840152 1.514971 -0.005417
+v -0.875402 1.514708 0.020654
+v -0.874853 1.501528 0.029720
+v -0.866367 1.490602 0.022250
+v -0.866367 1.485831 0.007494
+v -0.866862 1.498909 -0.002503
+v -0.893526 1.513609 -0.062357
+v -0.892654 1.503338 -0.064919
+v -0.892548 1.503006 -0.079812
+v -0.893391 1.513073 -0.082163
+v -0.894423 1.525528 -0.079700
+v -0.894540 1.525329 -0.069193
+v -0.893655 1.520154 -0.035779
+v -0.892851 1.506051 -0.038887
+v -0.892752 1.505324 -0.051371
+v -0.893597 1.514591 -0.058199
+v -0.894627 1.528550 -0.055499
+v -0.894713 1.529590 -0.041793
+v -0.894301 1.513431 -0.007127
+v -0.894035 1.503411 -0.010392
+v -0.893469 1.499690 -0.022715
+v -0.893984 1.512964 -0.026321
+v -0.894687 1.523085 -0.024191
+v -0.894688 1.523767 -0.011837
+v -0.867465 1.514539 0.003358
+v -0.892163 1.507195 0.014763
+v -0.891614 1.497847 0.022643
+v -0.912308 1.509373 -0.099956
+v -0.909511 1.499300 -0.090906
+v -0.906531 1.487359 -0.097379
+v -0.907509 1.491264 -0.110218
+v -0.910128 1.504920 -0.110858
+v -0.925724 1.505085 -0...
[truncated message content] |
|
From: <tre...@us...> - 2007-07-11 22:50:01
|
Revision: 226
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=226&view=rev
Author: trevorolio
Date: 2007-07-11 15:50:02 -0700 (Wed, 11 Jul 2007)
Log Message:
-----------
Moved space creation over to /og/space/ and out of /og/account/<username>/space/ so that it is more appropriately near space deletion on /og/space/<id#>
Updated ogoglio.js and WebAPIClient to reflect this change.
Added AccountRecord.isFrozen() util function.
Modified Paths:
--------------
spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
spaces/trunk/src/com/ogoglio/persist/AccountRecord.java
spaces/trunk/src/com/ogoglio/site/AccountServlet.java
spaces/trunk/src/com/ogoglio/site/SpaceServlet.java
spaces/trunk/war/ogoglio.js
Modified: spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-07-11 20:20:31 UTC (rev 225)
+++ spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-07-11 22:50:02 UTC (rev 226)
@@ -114,7 +114,7 @@
public static SpaceDocument createSpace(URI serviceURI, String authCookie) throws IOException {
AuthDocument authDocument = new AuthDocument(fetchAuthenticatedXML(getAuthURI(serviceURI), authCookie));
SpaceDocument spaceDoc = new SpaceDocument(-1, "New Space", authDocument.getUsername(), false, 0, false, 0, -1);
- XMLElement result = sendAuthenticatedXML(WebAPIUtil.appendToURI(serviceURI, "account/" + authDocument.getUsername() + "/space/"), spaceDoc.toString(), "POST", authCookie);
+ XMLElement result = sendAuthenticatedXML(WebAPIUtil.appendToURI(serviceURI, "space/"), spaceDoc.toString(), "POST", authCookie);
return new SpaceDocument(result);
}
Modified: spaces/trunk/src/com/ogoglio/persist/AccountRecord.java
===================================================================
--- spaces/trunk/src/com/ogoglio/persist/AccountRecord.java 2007-07-11 20:20:31 UTC (rev 225)
+++ spaces/trunk/src/com/ogoglio/persist/AccountRecord.java 2007-07-11 22:50:02 UTC (rev 226)
@@ -217,6 +217,10 @@
this.frozenUntil = frozenUntil;
}
+ public boolean isFrozen() {
+ return frozenUntil != null && System.currentTimeMillis() < frozenUntil.getTime();
+ }
+
public String getLastName() {
return lastName;
}
Modified: spaces/trunk/src/com/ogoglio/site/AccountServlet.java
===================================================================
--- spaces/trunk/src/com/ogoglio/site/AccountServlet.java 2007-07-11 20:20:31 UTC (rev 225)
+++ spaces/trunk/src/com/ogoglio/site/AccountServlet.java 2007-07-11 22:50:02 UTC (rev 226)
@@ -656,38 +656,6 @@
super("space", true, getSessionFactory());
}
- public void doPost(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
- String usernameParam = pathElements[pathElements.length - 2];
- AccountRecord requestedAccount = AccountPersistTasks.findAccountByUsername(usernameParam, getSessionFactory());
- if (requestedAccount == null) {
- response.setStatus(HttpServletResponse.SC_NOT_FOUND);
- return;
- }
-
- if (!authedAccount.getUsername().equals(requestedAccount.getUsername())) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return;
- }
-
- XMLElement spaceElement = parseXML(request.getInputStream());
- if (!SpaceDocument.NAME.equals(spaceElement.getName())) {
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- return;
- }
-
- String displayName = spaceElement.getStringAttribute(SpaceDocument.DISPLAY_NAME);
-
- SpaceRecord newSpace = SpacePersistTasks.createSpace(displayName, requestedAccount.getUsername(), getSessionFactory());
- if (newSpace == null) {
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- return;
- }
- getMediaService().write(MediaService.SPACE_DOCUMENT_PREFIX + newSpace.getSpaceID() + MediaService.SPACE_DOCUMENT_SUFFIX, new SpaceDocument(newSpace).toString());
-
- SpaceDocument spaceDoc = new SpaceDocument(newSpace);
- sendStringResponse(spaceDoc.toString(), "text/xml", response);
- }
-
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
String usernameParam = pathElements[pathElements.length - 2];
AccountRecord requestedAccount = AccountPersistTasks.findAccountByUsername(usernameParam, getSessionFactory());
Modified: spaces/trunk/src/com/ogoglio/site/SpaceServlet.java
===================================================================
--- spaces/trunk/src/com/ogoglio/site/SpaceServlet.java 2007-07-11 20:20:31 UTC (rev 225)
+++ spaces/trunk/src/com/ogoglio/site/SpaceServlet.java 2007-07-11 22:50:02 UTC (rev 226)
@@ -29,6 +29,7 @@
import com.ogoglio.client.WebAPIClient;
import com.ogoglio.client.WebAPIUtil;
import com.ogoglio.media.MediaService;
+import com.ogoglio.persist.AccountPersistTasks;
import com.ogoglio.persist.AccountRecord;
import com.ogoglio.persist.PersistException;
import com.ogoglio.persist.SimPersistTasks;
@@ -76,17 +77,42 @@
return new BaseSpaceResource();
}
- private class BaseSpaceResource extends SiteResource {
+ private class BaseSpaceResource extends AuthenticatedSiteResource {
public BaseSpaceResource() {
- super("space");
+ super("space", false, getSessionFactory());
addSubResource(new SpaceResource());
addSubResource(new SimResource());
}
- public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws IOException {
+ public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
ServiceDocument serviceDocument = new ServiceDocument(messageProxy.getUserCount(), messageProxy.getSimCount());
sendStringResponse(serviceDocument.toString(), "text/xml", response);
}
+
+ public void doPost(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
+ if (authedAccount == null || authedAccount.isFrozen()) {
+ response.setStatus(HttpServletResponse.SC_FORBIDDEN);
+ return;
+ }
+
+ XMLElement spaceElement = parseXML(request.getInputStream());
+ if (!SpaceDocument.NAME.equals(spaceElement.getName())) {
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ return;
+ }
+
+ String displayName = spaceElement.getStringAttribute(SpaceDocument.DISPLAY_NAME);
+
+ SpaceRecord newSpace = SpacePersistTasks.createSpace(displayName, authedAccount.getUsername(), getSessionFactory());
+ if (newSpace == null) {
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ return;
+ }
+ getMediaService().write(MediaService.SPACE_DOCUMENT_PREFIX + newSpace.getSpaceID() + MediaService.SPACE_DOCUMENT_SUFFIX, new SpaceDocument(newSpace).toString());
+
+ SpaceDocument spaceDoc = new SpaceDocument(newSpace);
+ sendStringResponse(spaceDoc.toString(), "text/xml", response);
+ }
}
private class SpaceResource extends AuthenticatedSiteResource {
Modified: spaces/trunk/war/ogoglio.js
===================================================================
--- spaces/trunk/war/ogoglio.js 2007-07-11 20:20:31 UTC (rev 225)
+++ spaces/trunk/war/ogoglio.js 2007-07-11 22:50:02 UTC (rev 226)
@@ -507,7 +507,7 @@
var bodyXML = document.createElement("space");
bodyXML.setAttribute("ownerusername", username);
bodyXML.setAttribute("displayname", escape(spaceName));
- var manager = new XMLRequestManager(appPath + "/account/" + username + "/space/", new BasicHTTPListener(listener));
+ var manager = new XMLRequestManager(appPath + "/space/", new BasicHTTPListener(listener));
manager.setMethod("POST");
manager.send(serializeXML(bodyXML));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-07-20 19:11:46
|
Revision: 228
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=228&view=rev
Author: trevorolio
Date: 2007-07-20 12:11:36 -0700 (Fri, 20 Jul 2007)
Log Message:
-----------
A tweak to stop compressing textures.
Modified Paths:
--------------
spaces/trunk/.settings/org.eclipse.jdt.core.prefs
spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
spaces/trunk/src/com/ogoglio/media/WebStore.java
spaces/trunk/src/com/ogoglio/sim/Sim.java
spaces/trunk/src/com/ogoglio/site/AccountServlet.java
spaces/trunk/src/com/ogoglio/viewer/applet/AppletTestWindow.java
Modified: spaces/trunk/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- spaces/trunk/.settings/org.eclipse.jdt.core.prefs 2007-07-12 14:05:45 UTC (rev 227)
+++ spaces/trunk/.settings/org.eclipse.jdt.core.prefs 2007-07-20 19:11:36 UTC (rev 228)
@@ -1,6 +1,6 @@
-#Tue Jul 03 09:23:42 PDT 2007
+#Mon Jul 16 20:14:59 PDT 2007
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.4
Modified: spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-07-12 14:05:45 UTC (rev 227)
+++ spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-07-20 19:11:36 UTC (rev 228)
@@ -29,6 +29,8 @@
import javax.media.j3d.Transform3D;
+import org.apache.commons.httpclient.methods.RequestEntity;
+
import nanoxml.XMLElement;
import com.ogoglio.site.AuthServlet;
@@ -50,8 +52,8 @@
public class WebAPIClient {
- private WebAPIClientWire wire=new WebAPIClientWire();
-
+ private WebAPIClientWire wire = new WebAPIClientWire();
+
private URI spaceURI = null;
private URI serviceURI = null;
@@ -71,9 +73,9 @@
}
public WebAPIClient(URI spaceURI, URI serviceURI, String authCookie) throws IOException {
- this(spaceURI,serviceURI, authCookie,null);
+ this(spaceURI, serviceURI, authCookie, null);
}
-
+
public WebAPIClient(URI spaceURI, URI serviceURI, String authCookie, WebAPIClientWire otherWire) throws IOException {
//seems that we have to allow the null spaceURI to indicate that
//the client has no interest in a space
@@ -84,9 +86,9 @@
ArgumentUtils.assertNotNull(authCookie);
this.authCookie = authCookie;
-
- if (otherWire!=null) {
- this.wire = otherWire;
+
+ if (otherWire != null) {
+ this.wire = otherWire;
}
}
@@ -333,27 +335,31 @@
XMLElement templateXML = postAuthenticatedXML(getTemplateURI(authDocument.getUsername(), templateDoc.getTemplateID()), templateDoc.toString());
return new TemplateDocument(templateXML);
}
+
/*
* Beginning of new style: IES HACK
*/
public String getAuthUsername() throws IOException {
- return getAuthDocument(true).getUsername();
+ return getAuthDocument(true).getUsername();
}
+
public String getAuthCookie() throws IOException {
- return authCookie;
+ return authCookie;
}
+
public TemplateDocument createTemplate(String templateName) throws IOException {
TemplateDocument templateDoc = new TemplateDocument(-1, templateName, getAuthUsername(), null);
- XMLElement templateXML = wire.postAuthenticatedXML(getTemplatesURI(getAuthUsername()),templateDoc.toString(),
- getAuthCookie());
+ XMLElement templateXML = wire.postAuthenticatedXML(getTemplatesURI(getAuthUsername()), templateDoc.toString(), getAuthCookie());
return new TemplateDocument(templateXML);
}
- public boolean deleteTemplate(long templateID) throws IOException {
- return wire.sendDelete(getTemplateURI(getAuthUsername(), templateID),getAuthCookie());
- }
- /*
- * End of new style: IES HACK
- */
+
+ public boolean deleteTemplate(long templateID) throws IOException {
+ return wire.sendDelete(getTemplateURI(getAuthUsername(), templateID), getAuthCookie());
+ }
+
+ /*
+ * End of new style: IES HACK
+ */
public TemplateDocument getTemplateDocument(String username, long templateID) throws IOException {
return new TemplateDocument(fetchAuthenticatedXML(getTemplateURI(username, templateID)));
}
@@ -380,7 +386,7 @@
public String getTemplateScript(long templateID) {
try {
- InputStream input = fetchAuthenticatedStream(getTemplateScriptURI(getAuthDocument(true).getUsername(), templateID), authCookie);
+ InputStream input = performGET(getTemplateScriptURI(getAuthDocument(true).getUsername(), templateID), authCookie, false);
return StreamUtils.readInput(input);
} catch (IOException e) {
return null;
@@ -442,7 +448,7 @@
}
public InputStream getPageContents(long thingID, long pageID) throws IOException {
- return performGET(getPageContentsURI(thingID, pageID), authCookie);
+ return performGET(getPageContentsURI(thingID, pageID), authCookie, false);
}
public Map getSettings() throws IOException {
@@ -458,7 +464,7 @@
public String getSetting(String key) {
try {
- InputStream stream = performGET(getSettingURI(key), authCookie);
+ InputStream stream = performGET(getSettingURI(key), authCookie, false);
if (stream == null) {
return null;
}
@@ -521,7 +527,7 @@
}
public InputStream getGeometryStream(URI renderableRootURI, String name) throws IOException {
- return fetchAuthenticatedStream(WebAPIUtil.appendToURI(renderableRootURI, "geometry/" + name), authCookie);
+ return performGET(WebAPIUtil.appendToURI(renderableRootURI, "geometry/" + name), authCookie, false);
}
public void putGeometryStream(URI rootURI, InputStream input, String name) throws IOException {
@@ -533,14 +539,13 @@
}
public InputStream getGeometryStream(URI renderableRootURI, int lodIndex) throws IOException {
- return fetchAuthenticatedStream(WebAPIUtil.appendToURI(renderableRootURI, "geometry/data/" + lodIndex), authCookie);
+ return performGET(WebAPIUtil.appendToURI(renderableRootURI, "geometry/data/" + lodIndex), authCookie, true);
}
- public static DecoratedInputStream performGET(URI uri, String authCookie) throws IOException {
-
+ public static DecoratedInputStream performGET(URI uri, String authCookie, boolean requestCompression) throws IOException {
String version = System.getProperty("java.version");
if ((version == null) || version.startsWith("1.6")) {
- //THIS IS TO WORK AROUND SUN'S ABSOLUTELY BROKEN APPLET CACHE IN JRE 1.6u1
+ //THIS IS TO WORK AROUND SUN'S ABSOLUTELY BROKEN APPLET CACHE IN JRE 1.6u1 & 2
String uriString = uri.toASCIIString();
try {
if (uriString.indexOf("?") == -1) {
@@ -563,7 +568,9 @@
if (authCookie != null) {
connection.setRequestProperty("Cookie", AuthServlet.AUTH_COOKIE + "=" + authCookie);
}
- connection.setRequestProperty("Accept-encoding", "gzip");
+ if (requestCompression) {
+ connection.setRequestProperty("Accept-encoding", "gzip");
+ }
connection.setDoOutput(false);
if (connection.getResponseCode() != 200) {
throw new IOException("Get status " + connection.getResponseCode() + " from " + uri);
@@ -731,13 +738,9 @@
return connection.getResponseCode() == 200;
}
- public static InputStream fetchAuthenticatedStream(URI uri, String authCookie) throws IOException {
- return performGET(uri, authCookie);
- }
-
public static XMLElement fetchAuthenticatedXML(URI uri, String authCookie) throws IOException {
XMLElement data = new XMLElement();
- data.parseFromReader(new InputStreamReader(fetchAuthenticatedStream(uri, authCookie)));
+ data.parseFromReader(new InputStreamReader(performGET(uri, authCookie, false)));
return data;
}
Modified: spaces/trunk/src/com/ogoglio/media/WebStore.java
===================================================================
--- spaces/trunk/src/com/ogoglio/media/WebStore.java 2007-07-12 14:05:45 UTC (rev 227)
+++ spaces/trunk/src/com/ogoglio/media/WebStore.java 2007-07-20 19:11:36 UTC (rev 228)
@@ -48,7 +48,7 @@
public DecoratedInputStream getData(String name) {
try {
- return WebAPIClient.performGET(WebAPIUtil.appendToURI(mediaURI, name), null);
+ return WebAPIClient.performGET(WebAPIUtil.appendToURI(mediaURI, name), null, false);
} catch (IOException e) {
return null;
}
Modified: spaces/trunk/src/com/ogoglio/sim/Sim.java
===================================================================
--- spaces/trunk/src/com/ogoglio/sim/Sim.java 2007-07-12 14:05:45 UTC (rev 227)
+++ spaces/trunk/src/com/ogoglio/sim/Sim.java 2007-07-20 19:11:36 UTC (rev 228)
@@ -42,7 +42,7 @@
import com.ogoglio.xml.TemplateDocument;
public class Sim {
- public static final long MAX_GEOMETRY_SIZE = 1048576;
+ public static final long MAX_GEOMETRY_SIZE = 5 * 1048576;
public static final long MAX_GEOMETRY_RESOURCE_SIZE = 1048576;
Modified: spaces/trunk/src/com/ogoglio/site/AccountServlet.java
===================================================================
--- spaces/trunk/src/com/ogoglio/site/AccountServlet.java 2007-07-12 14:05:45 UTC (rev 227)
+++ spaces/trunk/src/com/ogoglio/site/AccountServlet.java 2007-07-20 19:11:36 UTC (rev 228)
@@ -415,9 +415,6 @@
}
response.setStatus(HttpServletResponse.SC_OK);
setCachable(response);
- if (data.getLength() > -1) {
- response.setContentLength((int) data.getLength());
- }
if (data.getMimeType() != null) {
response.setContentType(data.getMimeType());
}
@@ -425,6 +422,9 @@
response.setHeader("Content-encoding", "gzip");
StreamUtils.write(data, new GZIPOutputStream(response.getOutputStream()));
} else {
+ if (data.getLength() > -1) {
+ response.setContentLength((int) data.getLength());
+ }
StreamUtils.write(data, response.getOutputStream());
}
} catch (PersistException e) {
Modified: spaces/trunk/src/com/ogoglio/viewer/applet/AppletTestWindow.java
===================================================================
--- spaces/trunk/src/com/ogoglio/viewer/applet/AppletTestWindow.java 2007-07-12 14:05:45 UTC (rev 227)
+++ spaces/trunk/src/com/ogoglio/viewer/applet/AppletTestWindow.java 2007-07-20 19:11:36 UTC (rev 228)
@@ -22,10 +22,8 @@
import java.awt.Frame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
-import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
-import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
@@ -42,7 +40,7 @@
EnvironmentStub clientStub1 = null;
- String host = "localhost:8080";
+ String host = "127.0.0.1:8080";
String serviceURI = "http://" + host + "/og/";
@@ -68,7 +66,7 @@
} catch (Exception e) {
e.printStackTrace();
}
- parameters1.put("loginCookie", "guestApplet_Test_Window2");
+ //parameters1.put("loginCookie", "guestApplet_Test_Window2");
parameters1.put("spaceURI", spaceURI);
parameters1.put("serviceURI", serviceURI);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2007-07-23 00:41:27
|
Revision: 229
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=229&view=rev
Author: iansmith
Date: 2007-07-22 17:41:29 -0700 (Sun, 22 Jul 2007)
Log Message:
-----------
WARNING: This checkin changes the database format! If you have data in an ogoglio server
WARNING: that you want to preserve, be sure to make a backup before attempting to switch
WARNING: to this version of the server! Better yet, perhaps wait until this change has
WARNING: been verified to work in your configuration on the ogoglio-developers mailing list.
WARNING: There is a new tool in this version: com.ogogilo.persist.MigrateDB_TemplateTables
WARNING: which will attempt to migrate data between versions. This program is a horrendous
WARNING: hack, but appears to work correctly for the "development configuration" of
WARNING: hsqldb + FileStore for media. Instructions for using that migrate a set of data
WARNING: between versions is in that file, but be sure to make a backup because that
WARNING: hasn't been tested in all configurations.
WARNING: This is *known* to not work with the WebStore. That change shoud be forthcoming
WARNING: shortly. If you are using Web-based storage of your media files, do not upgrade
WARNING: to this version.
This is significant, but "behind the scenes" change; it should not be visible to users.
The objective of this change was to support a more complex type of TemplateDocument
that looks like this (note the new child elements):
<template ownerusername="susan" templateid="3" displayname="Test Cube">
<supportfile filename="TestCube.gif" lastmodifiedUTC="Sunday, July 22, 2007 5:09:55 PM PDT"/>
<scriptfile lastmodifiedUTC="Sunday, July 22, 2007 5:09:55 PM PDT"/>
<geometry levelofdetail="0" lastmodifiedUTC="Sunday, July 22, 2007 5:09:55 PM PDT"/>
<supportfile filename="TestCube.mtl" lastmodifiedUTC="Sunday, July 22, 2007 5:09:55 PM PDT"/>
</template>
These new elements allow any user of template documents to know about the other files related to the
template and when they were last modified. Eventually, this will be used to support a client-side
program that can keep a set of templates "synchronized" with the server so that one can do editing
on a local machine of a set of templates for some application, and the synchronization tool does all
necessary updating of the server. This is much more convenient than the current situation, which
requires the use of many web pages. The beginnings of that tool--not yet completed--are in
com.ogoglio.templatesync but this should not be used yet as it is under active development.
A side-effect of this change was to do enough bookkeeping in the database to be able to generate these
templates without needing to ask the media server each time a template is downloaded. As part of
this effort, we now use Hibernate much more extensively to maintain these associations between templates
and their support files. If this continues work well, all associations may eventually be converted to
using Hibernate to maintain them; this is being put in place as a test of this functionality.
------- OTHER CHANGES ---------
A change has been started in WebAPIClient to move all of the actual code that touches the HTTP protocol
itself (the wire) into WebAPIClientWire in an effort to eventually allow WebAPIClient to be free
of network code and (one day) be able to run without a network using a mock. For now, the code
that is involved with templates has been converted and the new style can be checked out if one is
interested. WebAPIClientWire, for now, contains *copies* of the networking code in WebAPIClient
so that existing code can be left undisturbed in WebAPIClient.
ClientTests has been revamped to make understanding what tests are being performed easier to understand.
The process of removing the inter-test dependencies has been started. New tests have been added to
insure that the new template support files and last modified times are working properly.
Fixed a bug in Thing.reload() where the shapes table was not being cleared. This had not been frequently
observed to the use of a hash table which was masking the problem for most users.
MediaStore has been changed to support the listing of all files. This API call is not yet rolled all
the way through to WebStore, thus we know the migration tool cannot work because the migration tool needs
this call to function properly to work at all.
Many changes were needed in the com.ogoglio.persist package to support the new types of data that we
are now storing. These changes were mostly in the TemplateRecord and in the TemplateSupportFileRecord
classes. Some (all?) of the Hibernate test setup code has now been factored out in an effort
to make writing Hibernate tests easier. A problem with dependencies in ClientTests led to much work
on the PossessionRecord in an effort to be sure that Space deletion functioned properly. Nothing
was broken, but in the debugging process new constants were added PossessionRecord to indicate
the lack of a Space, lack of a Thing, etc. This change should probably be rolled into all the places
we currently use -1 as a signal value, as these different constants make the code more clear and
easier to debug.
Modified Paths:
--------------
spaces/trunk/build.xml
spaces/trunk/src/com/ogoglio/client/ClientTests.java
spaces/trunk/src/com/ogoglio/client/SpaceClient.java
spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
spaces/trunk/src/com/ogoglio/client/WebAPIClientWire.java
spaces/trunk/src/com/ogoglio/client/model/Thing.java
spaces/trunk/src/com/ogoglio/media/FileStore.java
spaces/trunk/src/com/ogoglio/media/MediaService.java
spaces/trunk/src/com/ogoglio/media/MediaStore.java
spaces/trunk/src/com/ogoglio/media/WebStore.java
spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java
spaces/trunk/src/com/ogoglio/persist/AccountRecord.java
spaces/trunk/src/com/ogoglio/persist/BodyPersistTasks.java
spaces/trunk/src/com/ogoglio/persist/BodyRecord.java
spaces/trunk/src/com/ogoglio/persist/HibernateTask.java
spaces/trunk/src/com/ogoglio/persist/PersistTests.java
spaces/trunk/src/com/ogoglio/persist/PossessionPersistTasks.java
spaces/trunk/src/com/ogoglio/persist/PossessionRecord.java
spaces/trunk/src/com/ogoglio/persist/SpaceMemberPersistTasks.java
spaces/trunk/src/com/ogoglio/persist/SpacePersistTasks.java
spaces/trunk/src/com/ogoglio/persist/TemplatePersistTasks.java
spaces/trunk/src/com/ogoglio/persist/TemplateRecord.java
spaces/trunk/src/com/ogoglio/sim/Sim.java
spaces/trunk/src/com/ogoglio/sim/script/ScriptTests.java
spaces/trunk/src/com/ogoglio/site/AccountServlet.java
spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java
spaces/trunk/src/com/ogoglio/templatesync/SyncToolSpec.java
spaces/trunk/src/com/ogoglio/templatesync/SyncToolTest.java
spaces/trunk/src/com/ogoglio/templatesync/TemplateSyncTestSuite.java
spaces/trunk/src/com/ogoglio/xml/PossessionDocument.java
spaces/trunk/src/com/ogoglio/xml/TemplateDocument.java
spaces/trunk/src/com/ogoglio/xml/XMLTests.java
Added Paths:
-----------
spaces/trunk/src/com/ogoglio/persist/HibernateBase.java
spaces/trunk/src/com/ogoglio/persist/HibernateTests.java
spaces/trunk/src/com/ogoglio/persist/MigrateDB_TemplateTables.java
spaces/trunk/src/com/ogoglio/persist/Persist.hbm.xml
spaces/trunk/src/com/ogoglio/persist/Persist_NoTemplateTables.hbm.xml
spaces/trunk/src/com/ogoglio/persist/TemplateSupportFilePersistTasks.java
spaces/trunk/src/com/ogoglio/persist/TemplateSupportFileRecord.java
spaces/trunk/src/com/ogoglio/templatesync/TemplateServerSideTests.java
Removed Paths:
-------------
spaces/trunk/src/com/ogoglio/persist/Persist.hbm.xml
Modified: spaces/trunk/build.xml
===================================================================
--- spaces/trunk/build.xml 2007-07-20 19:11:36 UTC (rev 228)
+++ spaces/trunk/build.xml 2007-07-23 00:41:29 UTC (rev 229)
@@ -81,7 +81,7 @@
</classpath>
<formatter type="brief" usefile="false" />
<test name="com.ogoglio.templatesync.TemplateSyncTestSuite" />
- <test name="com.ogoglio.OgoglioTestSuite" />
+ <!--<test name="com.ogoglio.OgoglioTestSuite" />-->
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=false" />
@@ -90,7 +90,7 @@
<emma enabled="${emma.enabled}" >
<report sourcepath="src"
sort="+block,+name,+method,+class"
- metrics="method:100,block:100,line:100,class:100"
+ metrics="method:90,block:90,line:90,class:100"
>
<!-- collect all EMMA data dumps (metadata and runtime)
[this can be done via nested <fileset> fileset elements
Modified: spaces/trunk/src/com/ogoglio/client/ClientTests.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-07-20 19:11:36 UTC (rev 228)
+++ spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-07-23 00:41:29 UTC (rev 229)
@@ -14,9 +14,11 @@
package com.ogoglio.client;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
+import java.text.ParseException;
import java.util.Date;
import java.util.Random;
import java.util.Vector;
@@ -34,7 +36,9 @@
import com.ogoglio.client.model.Thing;
import com.ogoglio.client.model.User;
import com.ogoglio.persist.AccountRecord;
+import com.ogoglio.persist.PossessionRecord;
import com.ogoglio.persist.ServiceInitializationPersistTasks;
+import com.ogoglio.persist.TemplateSupportFileRecord;
import com.ogoglio.util.StreamUtils;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.AuthDocument;
@@ -131,302 +135,525 @@
}
}
+ private UserDocument[] verifyUserDocsBySize(WebAPIClient webClient1, int expectedLen, String expectedUsername) throws IOException {
+ UserDocument[] userDocs = webClient1.getUserDocuments();
+ assertTrue(userDocs.length == expectedLen);
+ if (expectedUsername!=null) {
+ assertEquals(expectedUsername,userDocs[0].getUsername());
+ }
+ return userDocs;
+ }
+
public void testWebAPIClient() {
SpaceClient spaceClient1 = null;
SpaceClient guestSpaceClient1 = null;
try {
+ //this section sets up the key variables
String authCookie1 = WebAPIUtil.authenticate(serviceURI1, USERNAME1, PASSWORD1);
assertNotNull("got null auth cookie", authCookie1);
+ URI spaceURI1 = WebAPIUtil.appendToURI(serviceURI1, "space/" + WebAPIClient.createSpace(serviceURI1, authCookie1).getSpaceID());
+ WebAPIClient webClient1 = new WebAPIClient(spaceURI1, serviceURI1, authCookie1);
+ SpaceDocument spaceDocument = webClient1.getSpaceDocument(false);
+ assertNotNull(spaceDocument);
- SpaceDocument spaceDoc1 = WebAPIClient.createSpace(serviceURI1, authCookie1);
- URI spaceURI1 = WebAPIUtil.appendToURI(serviceURI1, "space/" + spaceDoc1.getSpaceID());
+ // IES REFACTOR
+ checkNoConnectionToSpaceWithoutAuth(spaceURI1);
+
+ spaceDocument = checkSpaceSeaLevel(webClient1, spaceDocument);
- try {
- new WebAPIClient(spaceURI1, serviceURI1, "BadBadCookie").getSpaceDocument(false);
- fail("Should get an IOException when not authed");
- } catch (IOException e) {
- //this should happen
- }
+ checkSettings(webClient1);
- WebAPIClient webClient1 = new WebAPIClient(spaceURI1, serviceURI1, authCookie1);
+ checkBody(webClient1);
- SpaceDocument spaceDocument = webClient1.getSpaceDocument(false);
- assertNotNull(spaceDocument);
- assertFalse(spaceDocument.getDisplaySea());
- assertEquals(0, spaceDocument.getSeaLevel(), 0.001);
- webClient1.setSeaLevel(-2);
- spaceDocument = webClient1.getSpaceDocument(false);
- assertEquals(-2, spaceDocument.getSeaLevel(), 0.000001);
- webClient1.setDisplaySea(true);
- spaceDocument = webClient1.getSpaceDocument(false);
- assertTrue(spaceDocument.getDisplaySea());
+ checkSpaceMembership(webClient1);
- AuthDocument authDoc = webClient1.getAuthDocument(true);
- assertNotNull(authDoc);
- assertEquals(USERNAME1, authDoc.getUsername());
+ checkSpaceAuthWithMembership(authCookie1, spaceURI1, webClient1, spaceDocument);
- AccountDocument ownerDoc = webClient1.getAccountDocument(authDoc.getUsername());
- assertNotNull(ownerDoc);
- assertEquals(USERNAME1, ownerDoc.getUsername());
+ TemplateDocument newTemplateDoc = checkTemplateScriptAPI(webClient1);
+ ThingDocument[] thingDocs=checkTemplateGeomMaterialsAndPossessions(webClient1, newTemplateDoc, spaceDocument);
- String key1 = "ogoglio.key.1";
- String value1 = "This is a very fine value which is < 1";
- assertNull(webClient1.getSetting(key1));
- webClient1.putSetting(key1, value1);
- assertEquals(value1, webClient1.getSetting(key1));
+ //IES CHECK: after messing around above, verify we are are ok
+ thingDocs=webClient1.getThingDocuments();
+ assertEquals(1,thingDocs.length);
+
+ checkPageManipulation(webClient1, thingDocs[0]);
- String key2 = "ogoglio.key.2";
- String value2 = "This is a very fine value & it's value is > 2";
- assertNull(webClient1.getSetting(key2));
- webClient1.putSetting(key2, value2);
- assertEquals(value2, webClient1.getSetting(key2));
- assertEquals(value1, webClient1.getSetting(key1));
+ //figure out the last template added
+ TemplateDocument[] templateDocs = webClient1.getTemplateDocuments(USERNAME1);
+ long lastTemplateID = templateDocs[templateDocs.length - 1].getTemplateID();
- webClient1.removeSetting(key1);
- assertNull(webClient1.getSetting(key1));
- webClient1.removeSetting(key2);
- assertNull(webClient1.getSetting(key2));
+ checkDoors(webClient1, spaceDocument, lastTemplateID);
- long defaultBody = ownerDoc.getDefaultBodyID();
- BodyDocument bodyDoc = webClient1.createBody();
- assertFalse(bodyDoc.getBodyID() == -1);
- assertEquals(ownerDoc.getUsername(), bodyDoc.getOwnerUsername());
- assertEquals(0, bodyDoc.getHairIndex());
- assertEquals(0, bodyDoc.getEyesIndex());
- assertEquals(0, bodyDoc.getNoseIndex());
- assertEquals(0, bodyDoc.getMouthIndex());
- assertEquals(0, bodyDoc.getFaceIndex());
- ownerDoc = webClient1.setDefaultBody(bodyDoc.getBodyID());
- assertEquals(bodyDoc.getBodyID(), ownerDoc.getDefaultBodyID());
- assertEquals(ownerDoc.getUsername(), bodyDoc.getOwnerUsername());
- bodyDoc.setEyesIndex(3);
- bodyDoc = webClient1.updateBody(bodyDoc);
- assertEquals(3, bodyDoc.getEyesIndex());
- assertFalse(webClient1.deleteBody(bodyDoc.getBodyID()));
- webClient1.setDefaultBody(defaultBody);
- assertTrue(webClient1.deleteBody(bodyDoc.getBodyID()));
- ownerDoc = webClient1.setDefaultBody(bodyDoc.getBodyID());
- assertEquals(defaultBody, ownerDoc.getDefaultBodyID());
+ spaceClient1 = checkConnectedUsersToSpace(authCookie1, spaceURI1, webClient1);
- SpaceMemberDocument[] membershipDocs = webClient1.getUsersSpaceMemberships();
- assertNotNull(membershipDocs);
- assertEquals(0, membershipDocs.length);
+ checkGeomAndResourceStreamsOfTemplate(webClient1, lastTemplateID);
- webClient1.addSpaceMember(USERNAME2, SpaceMemberDocument.MEMBER);
- membershipDocs = webClient1.getSpaceMemberDocuments();
- assertNotNull(membershipDocs);
- assertEquals(1, membershipDocs.length);
- assertEquals(USERNAME2, membershipDocs[0].getMemberUsername());
- assertEquals(SpaceMemberDocument.MEMBER, membershipDocs[0].getRole());
+ authThenBuildSpaceClient(spaceURI1);
- String authCookie2 = WebAPIUtil.authenticate(serviceURI1, USERNAME2, PASSWORD1);
- assertNotNull("got null auth cookie", authCookie1);
- WebAPIClient webClient2 = new WebAPIClient(spaceURI1, serviceURI1, authCookie2);
- membershipDocs = webClient2.getUsersSpaceMemberships();
- assertEquals(1, membershipDocs.length);
- assertEquals(spaceDocument.getSpaceID(), membershipDocs[0].getSpaceID());
- assertEquals(webClient2.getAuthDocument(true).getUsername(), membershipDocs[0].getMemberUsername());
- SpaceMemberDocument[] spaceMemberDocs = webClient1.getSpaceMemberDocuments();
- assertFalse("member doc length = " + spaceMemberDocs.length, spaceMemberDocs.length == 0);
- assertEquals(spaceMemberDocs[0].getMemberUsername(), USERNAME2);
+ checkGeometryAvailableForSpace(webClient1, thingDocs, spaceClient1.getSpace());
+
+ guestSpaceClient1 = checkGuestCookieOperation(spaceURI1, webClient1,
+ WebAPIClient.requestGuestCookie(serviceURI1));
+ checkDeletingSpaceDestroysThings(webClient1,USERNAME1);
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail();
+ } finally {
+ if (spaceClient1 != null) {
+ spaceClient1.cleanup();
+ }
+ if (guestSpaceClient1 != null) {
+ guestSpaceClient1.cleanup();
+ }
+ }
- webClient1.removeSpaceMember(USERNAME2);
- membershipDocs = webClient2.getUsersSpaceMemberships();
- assertEquals(0, membershipDocs.length);
+ }
- SpaceDocument[] spaceDocs = webClient1.getAccountSpaceDocuments(authDoc.getUsername());
- assertTrue("space docs length is " + spaceDocs.length, spaceDocs.length >= 1);
+ private void checkSpaceAuthWithMembership(String authCookie1, URI spaceURI1, WebAPIClient webClient1, SpaceDocument spaceDocument) throws IOException {
+ SpaceMemberDocument[] membershipDocs;
+ String authCookie2 = WebAPIUtil.authenticate(serviceURI1, USERNAME2, PASSWORD1);
+ assertNotNull("got null auth cookie", authCookie1);
+ WebAPIClient webClient2 = new WebAPIClient(spaceURI1, serviceURI1, authCookie2);
+ membershipDocs = webClient2.getUsersSpaceMemberships();
+ assertEquals(1, membershipDocs.length);
+ assertEquals(spaceDocument.getSpaceID(), membershipDocs[0].getSpaceID());
+ assertEquals(webClient2.getAuthDocument(true).getUsername(), membershipDocs[0].getMemberUsername());
+ SpaceMemberDocument[] spaceMemberDocs = webClient1.getSpaceMemberDocuments();
+ assertFalse("member doc length = " + spaceMemberDocs.length, spaceMemberDocs.length == 0);
+ assertEquals(spaceMemberDocs[0].getMemberUsername(), USERNAME2);
- String templateName = "Red Hot Pants";
- TemplateDocument newTemplateDoc = webClient1.createTemplate(templateName);
- assertEquals(templateName, newTemplateDoc.getDisplayName());
+ webClient1.removeSpaceMember(USERNAME2);
+ membershipDocs = webClient2.getUsersSpaceMemberships();
+ assertEquals(0, membershipDocs.length);
- templateName = "Test Cube";
- newTemplateDoc.setDisplayName(templateName);
- newTemplateDoc = webClient1.updateTemplate(newTemplateDoc);
- assertEquals(templateName, newTemplateDoc.getDisplayName());
+ SpaceDocument[] spaceDocs = webClient1.getAccountSpaceDocuments(USERNAME1);
+ assertTrue("space docs length is " + spaceDocs.length, spaceDocs.length >= 1);
+ }
- String script = "var i = 1; return ++i;";
- webClient1.updateTemplateScript(newTemplateDoc.getTemplateID(), script);
- assertEquals(script, webClient1.getTemplateScript(newTemplateDoc.getTemplateID()));
- webClient1.updateTemplateScript(newTemplateDoc.getTemplateID(), null);
- assertEquals(null, webClient1.getTemplateScript(newTemplateDoc.getTemplateID()));
+ private void checkSpaceMembership(WebAPIClient webClient1) throws IOException {
+ SpaceMemberDocument[] membershipDocs = webClient1.getUsersSpaceMemberships();
+ assertNotNull(membershipDocs);
+ assertEquals(0, membershipDocs.length);
- URI templateURI = webClient1.getTemplateURI(newTemplateDoc.getOwnerUsername(), newTemplateDoc.getTemplateID());
- FileInputStream objData = new FileInputStream("src/com/ogoglio/persist/resources/TestCube.obj");
- webClient1.putGeometryStream(templateURI, objData, 0);
- FileInputStream mtlData = new FileInputStream("src/com/ogoglio/persist/resources/TestCube.mtl");
- webClient1.putGeometryStream(templateURI, mtlData, "TestCube.mtl");
- FileInputStream textureData = new FileInputStream("src/com/ogoglio/persist/resources/TestCube.gif");
- webClient1.putGeometryStream(templateURI, textureData, "TestCube.gif");
- String cubeScript = StreamUtils.readInput(new FileInputStream("src/com/ogoglio/persist/resources/TestCube.js"));
- webClient1.updateTemplateScript(newTemplateDoc.getTemplateID(), cubeScript);
-
- PossessionDocument[] possDocs = webClient1.getPossessionDocuments(USERNAME1);
- int numPossessions = possDocs.length;
+ webClient1.addSpaceMember(USERNAME2, SpaceMemberDocument.MEMBER);
+ membershipDocs = webClient1.getSpaceMemberDocuments();
+ assertNotNull(membershipDocs);
+ assertEquals(1, membershipDocs.length);
+ assertEquals(USERNAME2, membershipDocs[0].getMemberUsername());
+ assertEquals(SpaceMemberDocument.MEMBER, membershipDocs[0].getRole());
+ }
- webClient1.createPossession(newTemplateDoc.getTemplateID());
- possDocs = webClient1.getPossessionDocuments(USERNAME1);
- assertEquals(numPossessions + 1, possDocs.length);
+ private void checkSettings(WebAPIClient webClient1) throws IOException {
+ String key1 = "ogoglio.key.1";
+ String value1 = "This is a very fine value which is < 1";
+ assertNull(webClient1.getSetting(key1));
+ webClient1.putSetting(key1, value1);
+ assertEquals(value1, webClient1.getSetting(key1));
- ThingDocument[] thingDocs = webClient1.getThingDocuments();
- assertEquals(0, thingDocs.length);
- PossessionDocument possDoc = webClient1.addPossessionToSpace(possDocs[numPossessions].getPossessionID(), spaceDocument.getSpaceID());
- assertNotNull(possDoc);
- try {
- Thread.sleep(100);
- } catch (Exception e) {
- }
- thingDocs = webClient1.getThingDocuments();
- assertEquals(1, thingDocs.length);
- assertEquals(thingDocs[0].getTemplateID(), possDocs[numPossessions].getTemplateID());
- assertEquals(thingDocs[0].getTemplateID(), possDoc.getTemplateID());
- assertEquals(spaceDocument.getSpaceID(), possDoc.getSpaceID());
- assertEquals(thingDocs[0].getThingID(), possDoc.getThingID());
+ String key2 = "ogoglio.key.2";
+ String value2 = "This is a very fine value & it's value is > 2";
+ assertNull(webClient1.getSetting(key2));
+ webClient1.putSetting(key2, value2);
+ assertEquals(value2, webClient1.getSetting(key2));
+ assertEquals(value1, webClient1.getSetting(key1));
- ShapeDocument[] shapeDocs = thingDocs[0].getShapeDocuments();
- assertEquals(1, shapeDocs.length);
- assertEquals("Cube", shapeDocs[0].getShapeName());
+ webClient1.removeSetting(key1);
+ assertNull(webClient1.getSetting(key1));
+ webClient1.removeSetting(key2);
+ assertNull(webClient1.getSetting(key2));
+ }
- PageDocument[] pages = webClient1.getPageDocuments(thingDocs[0].getThingID());
- assertEquals(0, pages.length);
- PageDocument pageDoc = webClient1.createPage(thingDocs[0].getThingID(), 1, 1, "text/plain");
- assertNotNull(pageDoc);
- String pageText = "This is a test of the emergency broadcast system. This is only a test.";
- webClient1.setPageContents(thingDocs[0].getThingID(), pageDoc.getPageID(), pageText);
- InputStream pageStream = webClient1.getPageContents(thingDocs[0].getThingID(), pageDoc.getPageID());
- assertNotNull(pageStream);
- String fetchedPageText = StreamUtils.readInput(pageStream);
- assertEquals(pageText + " didn't match " + fetchedPageText, pageText, fetchedPageText);
- pageText = "Hi ho";
- webClient1.setPageContents(thingDocs[0].getThingID(), pageDoc.getPageID(), pageText);
- pageStream = webClient1.getPageContents(thingDocs[0].getThingID(), pageDoc.getPageID());
- assertNotNull(pageStream);
- fetchedPageText = StreamUtils.readInput(pageStream);
- assertEquals(pageText, fetchedPageText);
- pageDoc.setX(10);
- pageDoc.setY(20);
- pageDoc.setZ(30);
- PageDocument updatedPageDoc = webClient1.updatePage(thingDocs[0].getThingID(), pageDoc);
- assertTrue(10 == updatedPageDoc.getX());
- assertTrue(20 == updatedPageDoc.getY());
- assertTrue(30 == updatedPageDoc.getZ());
- pages = webClient1.getPageDocuments(thingDocs[0].getThingID());
- assertEquals(1, pages.length);
- assertTrue(webClient1.deletePage(thingDocs[0].getThingID(), pageDoc.getPageID()));
- pages = webClient1.getPageDocuments(thingDocs[0].getThingID());
- assertEquals(0, pages.length);
+ private void checkBody(WebAPIClient webClient1) throws IOException {
+ AuthDocument authDoc = webClient1.getAuthDocument(true);
+ assertNotNull(authDoc);
+ assertEquals(USERNAME1, authDoc.getUsername());
- TemplateDocument[] templateDocs = webClient1.getTemplateDocuments(USERNAME1);
- DoorDocument[] doorDocs = webClient1.getDoorDocuments();
- assertEquals(0, doorDocs.length);
- DoorDocument doorDoc = webClient1.createDoor(spaceDocument.getSpaceID(), templateDocs[templateDocs.length - 1].getTemplateID(), USERNAME1, "Test Door", linkURI1, new Transform3D());
- assertNotNull(doorDoc);
- assertFalse(doorDoc.getDoorID() == -1);
- assertEquals(linkURI1, doorDoc.getLink());
- assertEquals("Test Door", doorDoc.getDisplayName());
- doorDocs = webClient1.getDoorDocuments();
- assertEquals(1, doorDocs.length);
- assertEquals(doorDoc.getDoorID(), doorDocs[0].getDoorID());
- assertTrue(webClient1.deleteDoor(doorDoc.getDoorID()));
- doorDocs = webClient1.getDoorDocuments();
- assertEquals(0, doorDocs.length);
+ AccountDocument ownerDoc = webClient1.getAccountDocument(authDoc.getUsername());
+ assertNotNull(ownerDoc);
+ assertEquals(USERNAME1, ownerDoc.getUsername());
+ long defaultBody = ownerDoc.getDefaultBodyID();
+ BodyDocument bodyDoc = webClient1.createBody();
+ assertFalse(bodyDoc.getBodyID() == -1);
+ assertEquals(ownerDoc.getUsername(), bodyDoc.getOwnerUsername());
+ assertEquals(0, bodyDoc.getHairIndex());
+ assertEquals(0, bodyDoc.getEyesIndex());
+ assertEquals(0, bodyDoc.getNoseIndex());
+ assertEquals(0, bodyDoc.getMouthIndex());
+ assertEquals(0, bodyDoc.getFaceIndex());
+ ownerDoc = webClient1.setDefaultBody(bodyDoc.getBodyID());
+ assertEquals(bodyDoc.getBodyID(), ownerDoc.getDefaultBodyID());
+ assertEquals(ownerDoc.getUsername(), bodyDoc.getOwnerUsername());
+ bodyDoc.setEyesIndex(3);
+ bodyDoc = webClient1.updateBody(bodyDoc);
+ assertEquals(3, bodyDoc.getEyesIndex());
+ assertFalse(webClient1.deleteBody(bodyDoc.getBodyID()));
+ webClient1.setDefaultBody(defaultBody);
+ assertTrue(webClient1.deleteBody(bodyDoc.getBodyID()));
+ ownerDoc = webClient1.setDefaultBody(bodyDoc.getBodyID());
+ assertEquals(defaultBody, ownerDoc.getDefaultBodyID());
+ }
- UserDocument[] userDocs = webClient1.getUserDocuments();
- assertTrue(userDocs.length == 0);
+ private SpaceDocument checkSpaceSeaLevel(WebAPIClient webClient1, SpaceDocument spaceDocument) throws IOException {
+ assertFalse(spaceDocument.getDisplaySea());
+ assertEquals(0, spaceDocument.getSeaLevel(), 0.001);
+ webClient1.setSeaLevel(-2);
+ spaceDocument = webClient1.getSpaceDocument(false);
+ assertEquals(-2, spaceDocument.getSeaLevel(), 0.000001);
+ webClient1.setDisplaySea(true);
+ spaceDocument = webClient1.getSpaceDocument(false);
+ assertTrue(spaceDocument.getDisplaySea());
+ return spaceDocument;
+ }
- spaceClient1 = new SpaceClient(spaceURI1, serviceURI1, authCookie1, new TestSpaceClientListener());
- try {
- Thread.sleep(1000);
- } catch (Exception e) {
- }
- userDocs = webClient1.getUserDocuments();
- assertEquals(1, userDocs.length);
- assertEquals(USERNAME1, userDocs[0].getUsername());
- spaceClient1.cleanup();
+ private void checkNoConnectionToSpaceWithoutAuth(URI spaceURI1) {
+ try {
+ new WebAPIClient(spaceURI1, serviceURI1, "BadBadCookie").getSpaceDocument(false);
+ fail("Should get an IOException when not authed");
+ } catch (IOException e) {
+ //this should happen
+ }
+ }
- InputStream stream = webClient1.getGeometryStream(webClient1.getTemplateURI(USERNAME1, templateDocs[templateDocs.length - 1].getTemplateID()), 0);
- assertNotNull(stream);
- consume(stream);
+ private SpaceClient authThenBuildSpaceClient(URI spaceURI1) throws IOException {
+ SpaceClient spaceClient1;
+ String authCookie1;
+ //auth to login to the sv...
[truncated message content] |
|
From: <ian...@us...> - 2007-08-01 01:19:20
|
Revision: 231
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=231&view=rev
Author: iansmith
Date: 2007-07-31 18:19:22 -0700 (Tue, 31 Jul 2007)
Log Message:
-----------
Added more support for template support files. The client
for synchronizing templates to the server now has all the
infrastructure necessary, but needs significant work to
make that functionality usable.
-------------------------------------------------------
Broke out TemplateResource into it's own file from the
AccountServlet. In this process tried to refactor to
avoid duplication.
Modified Paths:
--------------
spaces/trunk/build.xml
spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java
spaces/trunk/src/com/ogoglio/client/ClientTests.java
spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java
spaces/trunk/src/com/ogoglio/persist/TemplatePersistTasks.java
spaces/trunk/src/com/ogoglio/site/AccountServlet.java
spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java
spaces/trunk/src/com/ogoglio/templatesync/SyncToolSpec.java
spaces/trunk/src/com/ogoglio/xml/TemplateDocument.java
Added Paths:
-----------
spaces/trunk/src/com/ogoglio/site/TemplateResource.java
spaces/trunk/src/com/ogoglio/templatesync/GeomComparator.java
spaces/trunk/src/com/ogoglio/templatesync/MaterialsComparator.java
spaces/trunk/src/com/ogoglio/templatesync/ScriptComparator.java
spaces/trunk/src/com/ogoglio/templatesync/TypedFileComparator.java
Modified: spaces/trunk/build.xml
===================================================================
--- spaces/trunk/build.xml 2007-07-23 02:22:26 UTC (rev 230)
+++ spaces/trunk/build.xml 2007-08-01 01:19:22 UTC (rev 231)
@@ -80,8 +80,8 @@
<pathelement location="${dest}"/>
</classpath>
<formatter type="brief" usefile="false" />
- <test name="com.ogoglio.templatesync.TemplateSyncTestSuite" />
- <!--<test name="com.ogoglio.OgoglioTestSuite" />-->
+ <!--<test name="com.ogoglio.templatesync.TemplateSyncTestSuite" /> -->
+ <test name="com.ogoglio.OgoglioTestSuite" />
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=false" />
Modified: spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java
===================================================================
--- spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java 2007-07-23 02:22:26 UTC (rev 230)
+++ spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java 2007-08-01 01:19:22 UTC (rev 231)
@@ -19,6 +19,7 @@
import com.ogoglio.client.ClientTests;
import com.ogoglio.persist.PersistTests;
import com.ogoglio.sim.script.ScriptTests;
+import com.ogoglio.templatesync.TemplateSyncTestSuite;
import com.ogoglio.viewer.j3d.obj.ObjTest;
import com.ogoglio.xml.XMLTests;
@@ -30,6 +31,7 @@
suite.addTestSuite(PersistTests.class);
suite.addTestSuite(ClientTests.class);
suite.addTestSuite(ScriptTests.class);
+ suite.addTest(TemplateSyncTestSuite.suite());
return suite;
}
}
Modified: spaces/trunk/src/com/ogoglio/client/ClientTests.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-07-23 02:22:26 UTC (rev 230)
+++ spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-08-01 01:19:22 UTC (rev 231)
@@ -420,15 +420,28 @@
}
private void checkGeomAndResourceStreamsOfTemplate(WebAPIClient webClient1, long templateID) throws IOException {
+ URI templateURI = webClient1.getTemplateURI(USERNAME1, templateID);
//get the geom for a template owned by this user
- InputStream stream = webClient1.getGeometryStream(webClient1.getTemplateURI(USERNAME1, templateID), 0);
+ InputStream stream = webClient1.getGeometryStream(templateURI, 0);
assertNotNull(stream);
consume(stream);
//get a material file for the same template
- stream = webClient1.getGeometryStream(webClient1.getTemplateURI(USERNAME1, templateID), "TestCube.mtl");
+ stream = webClient1.getGeometryStream(templateURI, "TestCube.mtl");
assertNotNull(stream);
consume(stream);
+
+ assertTrue(webClient1.deleteGeometryStream(templateID, 0));
+ try {
+ webClient1.getGeometryStream(templateURI, 0);
+ fail("Shouldn't be able to get a deleted stream!");
+ } catch (IOException e) {
+ //can't get the stream because we just deleted it
+ assertTrue(e.getMessage().indexOf("404")!=-1); //very weak test
+ }
+
+ webClient1.putGeometryStream(templateURI,
+ new FileInputStream("src/com/ogoglio/persist/resources/TestCylinder.obj"), 0);
}
private void checkPageManipulation(WebAPIClient webClient1, ThingDocument someThing) throws IOException {
Modified: spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-07-23 02:22:26 UTC (rev 230)
+++ spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-08-01 01:19:22 UTC (rev 231)
@@ -375,13 +375,33 @@
}
// XXX: IES: should this be "post" not put?
public void putGeometryStream(URI rootURI, InputStream input, int lodIndex) throws IOException {
- wire.performPOST(WebAPIUtil.appendToURI(rootURI, "geometry/data/" + lodIndex), StreamUtils.readInput(input), "application/octet-stream", authCookie);
+ wire.performPOST(WebAPIUtil.appendToURI(rootURI, formGeometrySuffix(lodIndex)), StreamUtils.readInput(input), "application/octet-stream", authCookie);
}
// XXX IES: should this be called "post" not put? used to be putGeometryStream but that was wholly deceptive
public void putTemplateSupportFile(URI rootURI, InputStream input, String name) throws IOException {
- wire.performPOST(WebAPIUtil.appendToURI(rootURI, "geometry/" + name), StreamUtils.readInput(input), "application/octet-stream", authCookie);
+ wire.performPOST(WebAPIUtil.appendToURI(rootURI, formMaterialSuffix(name)), StreamUtils.readInput(input), "application/octet-stream", authCookie);
}
-
+ public void updateTemplateScript(long templateID, String script) throws IOException {
+ if (script == null || script.trim().length() == 0) {
+ wire.sendDelete(getTemplateScriptURI(templateID), authCookie);
+ return;
+ }
+ wire.performPOST(getTemplateScriptURI(templateID), script, "text/plain", authCookie);
+ }
+ private String formGeometrySuffix(int lod) {
+ return "geometry/data/" + lod;
+ }
+ private String formMaterialSuffix(String name) {
+ return "geometry/" + name;
+ }
+ public boolean deleteGeometryStream(long templateID, int lodIndex) throws IOException {
+ return wire.sendDelete(WebAPIUtil.appendToURI(getTemplateURI(getAuthUsername(),templateID),
+ formGeometrySuffix(lodIndex)), authCookie);
+ }
+ public boolean deleteTemplateSupportFile(long templateID, String name) throws IOException {
+ return wire.sendDelete(WebAPIUtil.appendToURI(getTemplateURI(getAuthUsername(),templateID),
+ formMaterialSuffix(name)), authCookie);
+ }
/*
* End of new style: IES HACK
*/
@@ -415,14 +435,6 @@
}
}
- public void updateTemplateScript(long templateID, String script) throws IOException {
- if (script == null || script.trim().length() == 0) {
- sendDelete(getTemplateScriptURI(templateID), authCookie);
- return;
- }
- performPOST(getTemplateScriptURI(templateID), script, "text/plain", authCookie);
- }
-
public ThingDocument[] getThingDocuments() throws IOException {
Vector results = new Vector();
Modified: spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java
===================================================================
--- spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java 2007-07-23 02:22:26 UTC (rev 230)
+++ spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java 2007-08-01 01:19:22 UTC (rev 231)
@@ -102,7 +102,8 @@
public Object run(Session hibernateSession) {
Query query = hibernateSession.getNamedQuery(ACCOUNT_BY_COOKIE);
query.setParameter("cookie", cookie);
- return query.uniqueResult();
+ AccountRecord rec=(AccountRecord)query.uniqueResult();
+ return rec;
}
};
task.setSessionFactory(sessionFactory);
Modified: spaces/trunk/src/com/ogoglio/persist/TemplatePersistTasks.java
===================================================================
--- spaces/trunk/src/com/ogoglio/persist/TemplatePersistTasks.java 2007-07-23 02:22:26 UTC (rev 230)
+++ spaces/trunk/src/com/ogoglio/persist/TemplatePersistTasks.java 2007-08-01 01:19:22 UTC (rev 231)
@@ -13,6 +13,8 @@
limitations under the License. */
package com.ogoglio.persist;
+import java.util.Date;
+
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.Session;
@@ -141,4 +143,87 @@
task.setSessionFactory(sessionFactory);
return task.execute() == Boolean.TRUE;
}
+ // XXX this should be unified with its brothers that updates the same for scripts and geom
+ public static void updateSupportFileTemplateLastModified(TemplateRecord record, String name, boolean newValue, SessionFactory sessionFactory) throws PersistException {
+ TemplateSupportFileRecord scriptRec = record.findSupportFile(name);
+ boolean currentValue;
+
+ if (scriptRec==null) {
+ currentValue = false;
+ } else {
+ currentValue=true;
+ }
+
+ if (currentValue==newValue) {
+ if (newValue==false) {
+ return; //nothing to do
+ }
+ //only thing to do is refresh timestamp
+ scriptRec.setLastChanged(new Date());
+ } else {
+ if (newValue==true) {
+ scriptRec= TemplateSupportFilePersistTasks.createSupportFileForMaterial(name, sessionFactory);
+ record.addTemplateSupportFileRecord(scriptRec);
+ } else {
+ record.getSupportFiles().remove(scriptRec);
+ }
+ }
+ TemplatePersistTasks.update(record, sessionFactory);
+ }
+ // XXX this should be unified with its brother that updates the same for scripts or support files
+ public static void updateGeometryFileTemplateLastModified(TemplateRecord record, int LOD, boolean newValue, SessionFactory sessionFactory) throws PersistException {
+ TemplateSupportFileRecord scriptRec = record.findGeometryFileRec(LOD);
+ boolean currentValue;
+
+ if (scriptRec==null) {
+ currentValue = false;
+ } else {
+ currentValue=true;
+ }
+
+ if (currentValue==newValue) {
+ if (newValue==false) {
+ return; //nothing to do
+ }
+ //only thing to do is refresh timestamp
+ scriptRec.setLastChanged(new Date());
+ } else {
+ if (newValue==true) {
+ scriptRec= TemplateSupportFilePersistTasks.createSupportFileForGeometry(LOD, sessionFactory);
+ record.addTemplateSupportFileRecord(scriptRec);
+ } else {
+ record.getSupportFiles().remove(scriptRec);
+ }
+ }
+ TemplatePersistTasks.update(record, sessionFactory);
+ }
+ public static void updateScriptFilePropOfTemplate(TemplateRecord record, boolean newValue, SessionFactory sessionFactory) throws PersistException {
+ TemplateSupportFileRecord scriptRec = record.findScriptFileRec();
+ boolean currentValue;
+
+ if (scriptRec==null) {
+ currentValue = false;
+ } else {
+ currentValue=true;
+ }
+
+ if (currentValue==newValue) {
+ if (newValue==false) {
+ return; //nothing to do
+ }
+ //only thing to do is refresh timestamp
+ scriptRec.setLastChanged(new Date());
+ } else {
+ if (newValue==true) {
+ scriptRec= TemplateSupportFilePersistTasks.createSupportFileForScript(sessionFactory);
+ record.addTemplateSupportFileRecord(scriptRec);
+ } else {
+ record.getSupportFiles().remove(scriptRec);
+ }
+ }
+ TemplatePersistTasks.update(record, sessionFactory);
+ }
}
+
+
+
Modified: spaces/trunk/src/com/ogoglio/site/AccountServlet.java
===================================================================
--- spaces/trunk/src/com/ogoglio/site/AccountServlet.java 2007-07-23 02:22:26 UTC (rev 230)
+++ spaces/trunk/src/com/ogoglio/site/AccountServlet.java 2007-08-01 01:19:22 UTC (rev 231)
@@ -18,7 +18,6 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Date;
-import java.util.zip.GZIPOutputStream;
import javax.media.j3d.Transform3D;
import javax.servlet.ServletConfig;
@@ -28,7 +27,6 @@
import nanoxml.XMLElement;
-import com.ogoglio.client.DecoratedInputStream;
import com.ogoglio.client.WebAPIClient;
import com.ogoglio.client.WebAPIUtil;
import com.ogoglio.media.MediaService;
@@ -47,8 +45,6 @@
import com.ogoglio.persist.SpaceRecord;
import com.ogoglio.persist.TemplatePersistTasks;
import com.ogoglio.persist.TemplateRecord;
-import com.ogoglio.persist.TemplateSupportFilePersistTasks;
-import com.ogoglio.persist.TemplateSupportFileRecord;
import com.ogoglio.sim.Sim;
import com.ogoglio.util.StreamUtils;
import com.ogoglio.xml.AccountDocument;
@@ -268,7 +264,7 @@
public class TemplatesResource extends AuthenticatedSiteResource {
public TemplatesResource() {
super("template", true, getSessionFactory());
- addSubResource(new TemplateResource());
+ addSubResource(new TemplateResource(getSessionFactory(),getMediaService()));
}
public void doPost(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
@@ -291,7 +287,8 @@
}
- public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
+ public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements,
+ AccountRecord authedAccount) throws PersistException, ServletException, IOException {
String usernameParam = pathElements[pathElements.length - 2];
AccountRecord requestedAccount = AccountPersistTasks.findAccountByUsername(usernameParam, getSessionFactory());
if (requestedAccount == null) {
@@ -309,566 +306,6 @@
}
}
- private class TemplateGeometryResource extends DescendingSiteResource {
- public TemplateGeometryResource() {
- super("geometry");
- }
-
-
- public void doPost(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
- String usernameParam = pathElements[1];
- try {
- AccountRecord authedAccount = getAuthedAccount(request, response);
- if (authedAccount==null) {
- return;
- }
- AccountRecord requestedAccount = getRequestedAccount(response, usernameParam);
- if (requestedAccount==null) {
- return;
- }
-
- if (verifyAccountHolderIsOk(response, authedAccount, requestedAccount)==false) {
- return;
- }
-
- Long tid = checkTemplateIDIsOk(response, authedAccount, requestedAccount, pathElements);
- if (tid==null) {
- return;
- }
- long templateID = tid.longValue();
-
- //trying to post to just /template/<TID>/geometry
- if (pathElements.length == 5) {
- response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
- return;
- }
- //trying to post to /geometry/data but requires an LOD number
- if (pathElements.length == 6 && "data".equals(pathElements[pathElements.length - 1])) {
- response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
- return;
- };
- //posting to /geometry/data/<number>
- if (pathElements.length == 7 && "data".equals(pathElements[pathElements.length - 2])) {
- InputStream fileInput;
- //is this coming from a browser?
- if (request.getContentType() != null && request.getContentType().startsWith("multipart/form-data")) {
- fileInput = getFirstFile(request, Sim.MAX_GEOMETRY_SIZE);
- if (fileInput == null) {
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- return;
- }
- } else {
- //coming from a sensible browser, just get the file input
- fileInput=request.getInputStream();
- }
- int LOD=-2995;
- try {
- LOD=Integer.parseInt(pathElements[pathElements.length -1]);
- } catch (NumberFormatException e) {
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- return;
- }
- String templateGeometryName = MediaService.getTemplateGeometryName(templateID, LOD);
- getMediaService().write(templateGeometryName, fileInput, Sim.MAX_GEOMETRY_SIZE);
- TemplateRecord record = TemplatePersistTasks.findTemplateByTemplateID(templateID, getSessionFactory());
- updateGeometryFileTemplateLastModified(record, LOD, true);
- } else {
- //posting to /geometry/<filename> for a support file like a texture or material
- InputStream fileInput;
- //from a browser?
- if (request.getContentType() != null && request.getContentType().startsWith("multipart/form-data")) {
- fileInput = getFirstFile(request, Sim.MAX_GEOMETRY_RESOURCE_SIZE);
- if (fileInput == null) {
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- return;
- }
- } else {
- fileInput=request.getInputStream();
- }
- String rawName=pathElements[pathElements.length -1 ];
- String templateResourceName = MediaService.getTemplateResourceName(templateID, rawName);
- getMediaService().write(templateResourceName, fileInput, Sim.MAX_GEOMETRY_RESOURCE_SIZE);
- TemplateRecord record = TemplatePersistTasks.findTemplateByTemplateID(templateID, getSessionFactory());
- updateSupportFileTemplateLastModified(record, rawName, true);
- }
- response.setStatus(HttpServletResponse.SC_OK);
- return;
- } catch (PersistException e) {
- handlePersistException(response, e);
- return;
- }
- }
- // XXX this should be unified with its brothers that updates the same for scripts and geom
- private void updateSupportFileTemplateLastModified(TemplateRecord record, String name, boolean newValue) throws PersistException {
- TemplateSupportFileRecord scriptRec = record.findSupportFile(name);
- boolean currentValue;
-
- if (scriptRec==null) {
- currentValue = false;
- } else {
- currentValue=true;
- }
-
- if (currentValue==newValue) {
- if (newValue==false) {
- return; //nothing to do
- }
- //only thing to do is refresh timestamp
- scriptRec.setLastChanged(new Date());
- } else {
- if (newValue==true) {
- scriptRec= TemplateSupportFilePersistTasks.createSupportFileForMaterial(name, getSessionFactory());
- record.addTemplateSupportFileRecord(scriptRec);
- } else {
- record.getSupportFiles().remove(scriptRec);
- }
- }
- TemplatePersistTasks.update(record, getSessionFactory());
- }
-
- // XXX this should be unified with its brother that updates the same for scripts
- private void updateGeometryFileTemplateLastModified(TemplateRecord record, int LOD, boolean newValue) throws PersistException {
- TemplateSupportFileRecord scriptRec = record.findGeometryFileRec(LOD);
- boolean currentValue;
-
- if (scriptRec==null) {
- currentValue = false;
- } else {
- currentValue=true;
- }
-
- if (currentValue==newValue) {
- if (newValue==false) {
- return; //nothing to do
- }
- //only thing to do is refresh timestamp
- scriptRec.setLastChanged(new Date());
- } else {
- if (newValue==true) {
- scriptRec= TemplateSupportFilePersistTasks.createSupportFileForGeometry(LOD, getSessionFactory());
- record.addTemplateSupportFileRecord(scriptRec);
- } else {
- record.getSupportFiles().remove(scriptRec);
- }
- }
- TemplatePersistTasks.update(record, getSessionFactory());
- }
-
-
- private void handlePersistException(HttpServletResponse response, PersistException e) {
- e.printStackTrace();
- response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- }
-
- private Long checkTemplateIDIsOk(HttpServletResponse response, AccountRecord authedAccount, AccountRecord requestedAccount,String[] pathElements) throws PersistException {
- long templateID = Long.parseLong(pathElements[3]);
- TemplateRecord record = TemplatePersistTasks.findTemplateByTemplateID(templateID, getSessionFactory());
- if (record == null || !record.getOwnerUsername().equals(requestedAccount.getUsername())) {
- response.setStatus(HttpServletResponse.SC_NOT_FOUND);
- return null;
- }
- return new Long(templateID);
- }
-
- private boolean verifyAccountHolderIsOk(HttpServletResponse response, AccountRecord authedAccount, AccountRecord requestedAccount) {
- if (!requestedAccount.getUsername().equals(authedAccount.getUsername())) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return false;
- }
- return true;
- }
-
-
- private AccountRecord getRequestedAccount(HttpServletResponse response, String usernameParam) throws PersistException {
- AccountRecord requestedAccount = AccountPersistTasks.findAccountByUsername(usernameParam, getSessionFactory());
- if (requestedAccount == null) {
- response.setStatus(HttpServletResponse.SC_NOT_FOUND);
- return null;
- }
- return requestedAccount;
- }
-
-
- private AccountRecord getAuthedAccount(HttpServletRequest request, HttpServletResponse response) throws PersistException {
- AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (authedAccount == null) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return null;
- }
- return authedAccount;
- }
- public void doPut(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
- String usernameParam = pathElements[1];
- System.out.println("XXX WHO IS CALLING PUT ON A TEMPLATE GEOM RESOURCE???");
- for (int i=0; i<pathElements.length;++i) System.out.println("XXX PUT: "+i+" ->"+pathElements[i]);
- try {
- AccountRecord authedAccount = getAuthedAccount(request, response);
- if (authedAccount==null) {
- return;
- }
- AccountRecord requestedAccount = getRequestedAccount(response, usernameParam);
- if (requestedAccount==null) {
- return;
- }
-
- if (verifyAccountHolderIsOk(response, authedAccount, requestedAccount)==false) {
- return;
- }
-
- String geomFileName = verifyParamsAreOk(response,pathElements);
- if (geomFileName==null) {
- return;
- }
- Long tid = checkTemplateIDIsOk(response, authedAccount, requestedAccount, pathElements);
- if (tid==null) {
- return;
- }
- } catch (PersistException e) {
- handlePersistException(response, e);
- }
- }
- private String verifyParamsAreOk(HttpServletResponse response, String[] pathElements) {
- if (pathElements.length!=7) {
- response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
- return null;
- }
- if ((pathElements[4].equals("geometry")==false) || (pathElements[5].equals("data")==false)) {
- response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
- return null;
- }
-
- if ((pathElements[6]==null) || (pathElements[6].equals("")==true) || (pathElements[6].indexOf('-')!=-1)) {
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- return null;
- }
- return pathElements[6];
- }
-
-
- public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
- String usernameParam = pathElements[1];
- try {
- AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (authedAccount == null && !AuthServlet.isGuest(request)) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return;
- }
-
- AccountRecord requestedAccount = AccountPersistTasks.findAccountByUsername(usernameParam, getSessionFactory());
- if (requestedAccount == null) {
- response.setStatus(HttpServletResponse.SC_NOT_FOUND);
- return;
- }
-
- long templateID = Long.parseLong(pathElements[3]);
- TemplateRecord record = TemplatePersistTasks.findTemplateByTemplateID(templateID, getSessionFactory());
- if (record == null || !record.getOwnerUsername().equals(requestedAccount.getUsername())) {
- response.setStatus(HttpServletResponse.SC_NOT_FOUND);
- return;
- }
-
- if (pathElements.length == 5) {
- sendStringResponse("This is where a geometry document would be.", "text/plain", response);
- return;
- }
-
- DecoratedInputStream data = null;
- if (pathElements.length == 7 && "data".equals(pathElements[pathElements.length - 2])) {
- data = getMediaService().getData(MediaService.getTemplateGeometryName(templateID, Integer.parseInt(pathElements[pathElements.length - 1])));
- } else {
- data = getMediaService().getData(MediaService.getTemplateResourceName(templateID, pathElements[pathElements.length - 1]));
- }
- if (data == null) {
- response.setStatus(HttpServletResponse.SC_NOT_FOUND);
- return;
- }
- response.setStatus(HttpServletResponse.SC_OK);
- setCachable(response);
- if (data.getMimeType() != null) {
- response.setContentType(data.getMimeType());
- }
- if ("gzip".equals(request.getHeader("Accept-encoding"))) {
- response.setHeader("Content-encoding", "gzip");
- StreamUtils.write(data, new GZIPOutputStream(response.getOutputStream()));
- } else {
- if (data.getLength() > -1) {
- response.setContentLength((int) data.getLength());
- }
- StreamUtils.write(data, response.getOutputStream());
- }
- } catch (PersistException e) {
- handlePersistException(response, e);
- return;
- }
- }
-
- public void doHead(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
- String usernameParam = pathElements[1];
- try {
- AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (authedAccount == null && !AuthServlet.isGuest(request)) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return;
- }
-
- AccountRecord requestedAccount = AccountPersistTasks.findAccountByUsername(usernameParam, getSessionFactory());
- if (requestedAccount == null) {
- response.setStatus(HttpServletResponse.SC_NOT_FOUND);
- return;
- }
-
- long templateID = Long.parseLong(pathElements[3]);
- TemplateRecord record = TemplatePersistTasks.findTemplateByTemplateID(templateID, getSessionFactory());
- if (record == null || !record.getOwnerUsername().equals(requestedAccount.getUsername())) {
- response.setStatus(HttpServletResponse.SC_NOT_FOUND);
- return;
- }
-
- if (pathElements.length == 5) {
- sendStringResponse("This is where a geometry document would be.", "text/plain", response);
- return;
- }
-
- String mediaName = null;
- if (pathElements.length == 7 && "data".equals(pathElements[pathElements.length - 2])) {
- mediaName = MediaService.getTemplateGeometryName(templateID, Integer.parseInt(pathElements[pathElements.length - 1]));
- } else {
- mediaName = MediaService.getTemplateResourceName(templateID, pathElements[pathElements.length - 1]);
- }
-
- long length = getMediaService().getSize(mediaName);
- if (length == -1) {
- response.setStatus(HttpServletResponse.SC_NOT_FOUND);
- return;
- }
-
- long lastModified = getMediaServ...
[truncated message content] |
|
From: <tre...@us...> - 2007-08-04 00:19:54
|
Revision: 234
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=234&view=rev
Author: trevorolio
Date: 2007-08-03 17:19:57 -0700 (Fri, 03 Aug 2007)
Log Message:
-----------
Refactored the WebAPI classes like so:
WebAPIDescriptor: handles all of the URL creation mojo for a given Ogoglio service
WebAPIAuthenticator: contains login information and fetches account and auth documents
WebAPIClientWire: handles all HTTP communication
WebAPIClient: wraps the descriptor, wire, and authenticator to provide easy functions for manipulating the remote ogoglio service
NOTE: WebAPIClient instances are no longer bound to a single space
These changes make it easier for us to test because the individual objects can be mocked more easily, and in general removes a lot of the intertwined nastiness that had grown up in WebAPIClient.
NOTE: spaceui.js has changed to reflect that the viewer applet now takes a spaceID parameter instead of a spaceURI. If you have custom HTML wrapping the viewer jar you'll need to change it after this update.
NOTE 2: There are two tests in templatesync which don't pass, mostly because I'm still getting my feet under me with RMock and I'm going to bother Ian until he helps me. Also, the Persist tests are hard coded for a specific db setup, which Ian is going to fix Real Soon Now.
Modified Paths:
--------------
spaces/trunk/src/com/ogoglio/client/ClientTests.java
spaces/trunk/src/com/ogoglio/client/MultiuserTests.java
spaces/trunk/src/com/ogoglio/client/SpaceClient.java
spaces/trunk/src/com/ogoglio/client/SpaceDuplicator.java
spaces/trunk/src/com/ogoglio/client/SpaceDuplicatorTests.java
spaces/trunk/src/com/ogoglio/client/WebAPIAuthenticator.java
spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
spaces/trunk/src/com/ogoglio/client/WebAPIClientWire.java
spaces/trunk/src/com/ogoglio/client/WebAPIUtil.java
spaces/trunk/src/com/ogoglio/media/WebStore.java
spaces/trunk/src/com/ogoglio/site/AccountServlet.java
spaces/trunk/src/com/ogoglio/site/MessageProxy.java
spaces/trunk/src/com/ogoglio/site/SpaceServlet.java
spaces/trunk/src/com/ogoglio/site/TemplateResource.java
spaces/trunk/src/com/ogoglio/templatesync/GeomComparator.java
spaces/trunk/src/com/ogoglio/templatesync/MaterialsComparator.java
spaces/trunk/src/com/ogoglio/templatesync/ScriptComparator.java
spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java
spaces/trunk/src/com/ogoglio/templatesync/SyncToolSpec.java
spaces/trunk/src/com/ogoglio/templatesync/SyncToolTest.java
spaces/trunk/src/com/ogoglio/templatesync/TypedFileComparator.java
spaces/trunk/src/com/ogoglio/viewer/applet/AppletTestWindow.java
spaces/trunk/src/com/ogoglio/viewer/applet/BodyEditorApplet.java
spaces/trunk/src/com/ogoglio/viewer/applet/ViewerApplet.java
spaces/trunk/war/spaceui.js
Added Paths:
-----------
spaces/trunk/src/com/ogoglio/client/AuthenticationFailedException.java
spaces/trunk/src/com/ogoglio/client/WebAPIAuthenticatorFactory.java
spaces/trunk/src/com/ogoglio/client/WebAPIDescriptor.java
spaces/trunk/src/com/ogoglio/client/WebAPIGuestAuthenticator.java
Added: spaces/trunk/src/com/ogoglio/client/AuthenticationFailedException.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/AuthenticationFailedException.java (rev 0)
+++ spaces/trunk/src/com/ogoglio/client/AuthenticationFailedException.java 2007-08-04 00:19:57 UTC (rev 234)
@@ -0,0 +1,7 @@
+package com.ogoglio.client;
+
+public class AuthenticationFailedException extends Exception {
+ public AuthenticationFailedException(String message) {
+ super(message);
+ }
+}
Modified: spaces/trunk/src/com/ogoglio/client/ClientTests.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-08-02 17:49:59 UTC (rev 233)
+++ spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-08-04 00:19:57 UTC (rev 234)
@@ -40,6 +40,7 @@
import com.ogoglio.persist.PossessionRecord;
import com.ogoglio.persist.ServiceInitializationPersistTasks;
import com.ogoglio.persist.TemplateSupportFileRecord;
+import com.ogoglio.site.AuthServlet;
import com.ogoglio.util.StreamUtils;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.AuthDocument;
@@ -70,10 +71,16 @@
URI serviceURI1 = null;
+ WebAPIClientWire wire1 = null;
+
+ WebAPIDescriptor descriptor1 = null;
+
public void setUp() {
try {
- serviceURI1 = new URI("http://127.0.0.1:8080/og/"); //best choice: 127.0.0.1 for tests
- linkURI1 = new URI("http://ogoglio.com/");
+ serviceURI1 = new URI("http://127.0.0.1:8080/og/"); //best choice: 127.0.0.1 for tests
+ linkURI1 = new URI("http://example.com/");
+ wire1 = new WebAPIClientWire();
+ descriptor1 = new WebAPIDescriptor(serviceURI1);
} catch (Throwable e) {
e.printStackTrace();
fail(e.getMessage());
@@ -86,21 +93,23 @@
public void testWebAdmin() {
try {
- String adminAuthCookie = WebAPIUtil.authenticate(serviceURI1, ServiceInitializationPersistTasks.LIBRARY_USERNAME, ServiceInitializationPersistTasks.DEFAULT_LIBRARY_PASSWORD);
- assertNotNull("got null auth cookie", adminAuthCookie);
+ WebAPIAuthenticator adminAuthenticator = new WebAPIAuthenticatorFactory().authenticate(wire1, descriptor1, ServiceInitializationPersistTasks.LIBRARY_USERNAME, ServiceInitializationPersistTasks.DEFAULT_LIBRARY_PASSWORD);
+ assertNotNull("got null auth cookie", adminAuthenticator.getAuthCookie());
+ WebAPIClient adminWebClient = new WebAPIClient(descriptor1, adminAuthenticator, wire1);
try {
- WebAPIClient.createAccount(serviceURI1, adminAuthCookie, USERNAME1, AccountRecord.ACCOUNT_LEVEL_ADVANCED, "Susan", "Examplar", "http://example.com/susan/", "su...@ex...", PASSWORD1);
- WebAPIClient.createAccount(serviceURI1, adminAuthCookie, USERNAME2, AccountRecord.ACCOUNT_LEVEL_ADVANCED, "Tina", "Examplar", "http://example.com/tina/", "ti...@ex...", PASSWORD1);
+ adminWebClient.createAccount(USERNAME1, AccountRecord.ACCOUNT_LEVEL_ADVANCED, "Susan", "Examplar", "http://example.com/susan/", "su...@ex...", PASSWORD1);
+ adminWebClient.createAccount(USERNAME2, AccountRecord.ACCOUNT_LEVEL_ADVANCED, "Tina", "Examplar", "http://example.com/tina/", "ti...@ex...", PASSWORD1);
} catch (IOException e) {
//may already exist
}
- String basicAuthCookie = WebAPIUtil.authenticate(serviceURI1, USERNAME1, PASSWORD1);
- assertNotNull("got null auth cookie", basicAuthCookie);
+ WebAPIAuthenticator basicAuthenticator = new WebAPIAuthenticator(wire1, descriptor1, USERNAME1, PASSWORD1);
+ assertNotNull("got null auth cookie", basicAuthenticator.getAuthCookie());
+ WebAPIClient basicWebClient = new WebAPIClient(descriptor1, basicAuthenticator, wire1);
try {
String failedUsername = "Bogosity" + System.currentTimeMillis();
- AccountDocument doc = WebAPIClient.createAccount(serviceURI1, basicAuthCookie, failedUsername, AccountRecord.ACCOUNT_LEVEL_BASIC, "Shouldnt", "Exist", null, failedUsername + "@example.com", "1234");
+ AccountDocument doc = basicWebClient.createAccount(failedUsername, AccountRecord.ACCOUNT_LEVEL_BASIC, "Shouldnt", "Exist", null, failedUsername + "@example.com", "1234");
if (doc != null) {
fail();
}
@@ -109,9 +118,9 @@
}
String username = "testuser" + Math.abs(new Random().nextLong());
- WebAPIClient.createAccount(serviceURI1, adminAuthCookie, username, AccountRecord.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, username + "@example.com", "1234");
+ adminWebClient.createAccount(username, AccountRecord.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, username + "@example.com", "1234");
- AccountDocument accountDoc = WebAPIClient.getAccountDocument(serviceURI1, adminAuthCookie, username);
+ AccountDocument accountDoc = adminWebClient.getAccountDocument(username);
assertNotNull(accountDoc);
assertEquals("Test", accountDoc.getFirstName());
assertEquals("Sims", accountDoc.getLastName());
@@ -119,14 +128,14 @@
Date frozenDate = new Date(System.currentTimeMillis() + 1000000);
accountDoc.setFrozenUntil(frozenDate);
accountDoc.setAccountLevel(AccountRecord.ACCOUNT_LEVEL_ADMIN);
- WebAPIClient.updateAccount(serviceURI1, adminAuthCookie, accountDoc);
- accountDoc = WebAPIClient.getAccountDocument(serviceURI1, adminAuthCookie, username);
+ adminWebClient.updateAccount(accountDoc);
+ accountDoc = adminWebClient.getAccountDocument(username);
assertTrue(frozenDate.getTime() - accountDoc.getFrozenUntil().getTime() < 1000);
assertEquals(AccountRecord.ACCOUNT_LEVEL_ADMIN, accountDoc.getAccountLevel());
accountDoc.setFrozenUntil(new Date(1000));
accountDoc.setAccountLevel(AccountRecord.ACCOUNT_LEVEL_BASIC);
- WebAPIClient.updateAccount(serviceURI1, adminAuthCookie, accountDoc);
- accountDoc = WebAPIClient.getAccountDocument(serviceURI1, adminAuthCookie, username);
+ adminWebClient.updateAccount(accountDoc);
+ accountDoc = adminWebClient.getAccountDocument(username);
assertTrue(accountDoc.getFrozenUntil() == null);
assertEquals(AccountRecord.ACCOUNT_LEVEL_BASIC, accountDoc.getAccountLevel());
@@ -136,70 +145,60 @@
}
}
- private UserDocument[] verifyUserDocsBySize(WebAPIClient webClient1, int expectedLen, String expectedUsername) throws IOException {
- UserDocument[] userDocs = webClient1.getUserDocuments();
- assertTrue(userDocs.length == expectedLen);
- if (expectedUsername!=null) {
- assertEquals(expectedUsername,userDocs[0].getUsername());
- }
- return userDocs;
- }
-
public void testWebAPIClient() {
SpaceClient spaceClient1 = null;
SpaceClient guestSpaceClient1 = null;
try {
- //this section sets up the key variables
- String authCookie1 = WebAPIUtil.authenticate(serviceURI1, USERNAME1, PASSWORD1);
- assertNotNull("got null auth cookie", authCookie1);
- URI spaceURI1 = WebAPIUtil.appendToURI(serviceURI1, "space/" + WebAPIClient.createSpace(serviceURI1, authCookie1).getSpaceID());
- WebAPIClient webClient1 = new WebAPIClient(spaceURI1, serviceURI1, authCookie1);
- SpaceDocument spaceDocument = webClient1.getSpaceDocument(false);
+ //this section sets up the key variables
+ WebAPIAuthenticator auth1 = new WebAPIAuthenticator(wire1, descriptor1, USERNAME1, PASSWORD1);
+ WebAPIClient webClient1 = new WebAPIClient(descriptor1, auth1, wire1);
+ SpaceDocument spaceDocument = webClient1.createSpace("Susan's Space");
assertNotNull(spaceDocument);
- // IES REFACTOR
- checkNoConnectionToSpaceWithoutAuth(spaceURI1);
+ WebAPIAuthenticator auth2 = new WebAPIAuthenticator(wire1, descriptor1, USERNAME2, PASSWORD1);
+ WebAPIClient webClient2 = new WebAPIClient(descriptor1, auth2, wire1);
- checkAuthDoc(authCookie1);
-
+ checkNoConnectionToSpaceWithoutAuth(spaceDocument.getSpaceID());
+
+ checkAuthDoc(auth1, auth2);
+
spaceDocument = checkSpaceSeaLevel(webClient1, spaceDocument);
- checkSettings(webClient1);
+ checkSettings(spaceDocument.getSpaceID(), webClient1);
- checkBody(webClient1);
+ checkBody(webClient1, auth1);
- checkSpaceMembership(webClient1);
+ checkSpaceMembership(spaceDocument.getSpaceID(), webClient1);
- checkSpaceAuthWithMembership(authCookie1, spaceURI1, webClient1, spaceDocument);
+ checkSpaceAuthWithMembership(auth2, webClient2, webClient1, spaceDocument);
TemplateDocument newTemplateDoc = checkTemplateScriptAPI(webClient1);
- ThingDocument[] thingDocs=checkTemplateGeomMaterialsAndPossessions(webClient1, newTemplateDoc, spaceDocument);
+ ThingDocument[] thingDocs = checkTemplateGeomMaterialsAndPossessions(webClient1, newTemplateDoc, spaceDocument);
//IES CHECK: after messing around above, verify we are are ok
- thingDocs=webClient1.getThingDocuments();
- assertEquals(1,thingDocs.length);
-
- checkPageManipulation(webClient1, thingDocs[0]);
+ thingDocs = webClient1.getThingDocuments(spaceDocument.getSpaceID());
+ assertEquals(1, thingDocs.length);
+ checkPageManipulation(webClient1, thingDocs[0], spaceDocument);
+
//figure out the last template added
TemplateDocument[] templateDocs = webClient1.getTemplateDocuments(USERNAME1);
long lastTemplateID = templateDocs[templateDocs.length - 1].getTemplateID();
checkDoors(webClient1, spaceDocument, lastTemplateID);
- spaceClient1 = checkConnectedUsersToSpace(authCookie1, spaceURI1, webClient1);
+ spaceClient1 = checkConnectedUsersToSpace(auth1, webClient1, spaceDocument);
- checkGeomAndResourceStreamsOfTemplate(webClient1, lastTemplateID);
+ checkGeomAndResourceStreamsOfTemplate(webClient1, auth1.getUsername(), lastTemplateID);
- authThenBuildSpaceClient(spaceURI1);
+ authThenBuildSpaceClient(spaceDocument.getSpaceID(), auth1);
checkGeometryAvailableForSpace(webClient1, thingDocs, spaceClient1.getSpace());
-
- guestSpaceClient1 = checkGuestCookieOperation(spaceURI1, webClient1,
- WebAPIClient.requestGuestCookie(serviceURI1));
- checkDeletingSpaceDestroysThings(webClient1,USERNAME1);
-
+
+ guestSpaceClient1 = checkGuestCookieOperation(spaceDocument.getSpaceID(), webClient1, AuthServlet.GUEST_COOKIE_PREFIX + "Test_Suite_Guest");
+ checkDeletingSpaceDestroysThings(spaceDocument.getSpaceID(), webClient1, USERNAME1);
+
} catch (IOException e) {
e.printStackTrace();
fail();
@@ -214,18 +213,16 @@
}
- private AuthDocument getAuthDoc(String authCookie) {
- try {
- XMLElement element = WebAPIClient.fetchAuthenticatedXML(WebAPIClient.getMeAuthURI(serviceURI1), authCookie);
- return new AuthDocument(element);
- } catch (IOException e) {
- fail("Error fetching auth document with no auth cookie: " + e);
- return null;
+ private UserDocument[] verifyUserDocsBySize(WebAPIClient webClient1, long spaceID, int expectedLen, String expectedUsername) throws IOException {
+ UserDocument[] userDocs = webClient1.getUserDocuments(spaceID);
+ assertTrue(userDocs.length == expectedLen);
+ if (expectedUsername != null) {
+ assertEquals(expectedUsername, userDocs[0].getUsername());
}
+ return userDocs;
}
- private void checkAuthDoc(String authCookie1) {
-
+ private void checkAuthDoc(WebAPIAuthenticator auth1, WebAPIAuthenticator auth2) {
AuthDocument authDoc = getAuthDoc(null);
assertFalse(authDoc.isAuthenticated());
assertNull(authDoc.getUsername());
@@ -234,314 +231,300 @@
assertFalse(authDoc.isAuthenticated());
assertNull(authDoc.getUsername());
- authDoc = getAuthDoc(authCookie1);
+ authDoc = getAuthDoc(auth1.getAuthCookie());
assertTrue(authDoc.isAuthenticated());
assertEquals(USERNAME1, authDoc.getUsername());
+
+ authDoc = getAuthDoc(auth2.getAuthCookie());
+ assertTrue(authDoc.isAuthenticated());
+ assertEquals(USERNAME2, authDoc.getUsername());
}
+ private AuthDocument getAuthDoc(String authCookie) {
+ try {
+ XMLElement element = wire1.fetchAuthenticatedXML(descriptor1.getMeAuthURI(), authCookie);
+ return new AuthDocument(element);
+ } catch (IOException e) {
+ fail("Error fetching auth document with no auth cookie: " + e);
+ return null;
+ }
+ }
- private void checkSpaceAuthWithMembership(String authCookie1, URI spaceURI1, WebAPIClient webClient1, SpaceDocument spaceDocument) throws IOException {
- SpaceMemberDocument[] membershipDocs;
- String authCookie2 = WebAPIUtil.authenticate(serviceURI1, USERNAME2, PASSWORD1);
- assertNotNull("got null auth cookie", authCookie1);
- WebAPIClient webClient2 = new WebAPIClient(spaceURI1, serviceURI1, authCookie2);
- membershipDocs = webClient2.getUsersSpaceMemberships();
- assertEquals(1, membershipDocs.length);
- assertEquals(spaceDocument.getSpaceID(), membershipDocs[0].getSpaceID());
- assertEquals(webClient2.getAuthDocument(true).getUsername(), membershipDocs[0].getMemberUsername());
- SpaceMemberDocument[] spaceMemberDocs = webClient1.getSpaceMemberDocuments();
- assertFalse("member doc length = " + spaceMemberDocs.length, spaceMemberDocs.length == 0);
- assertEquals(spaceMemberDocs[0].getMemberUsername(), USERNAME2);
+ private void checkSpaceAuthWithMembership(WebAPIAuthenticator memberAuth, WebAPIClient memberClient, WebAPIClient ownerClient, SpaceDocument spaceDocument) throws IOException {
+ SpaceMemberDocument[] membershipDocs;
+ membershipDocs = memberClient.getUsersSpaceMemberships();
+ assertEquals(1, membershipDocs.length);
+ assertEquals(spaceDocument.getSpaceID(), membershipDocs[0].getSpaceID());
+ assertEquals(memberAuth.getUsername(), membershipDocs[0].getMemberUsername());
+ SpaceMemberDocument[] spaceMemberDocs = ownerClient.getSpaceMemberDocuments(spaceDocument.getSpaceID());
+ assertFalse("member doc length = " + spaceMemberDocs.length, spaceMemberDocs.length == 0);
+ assertEquals(spaceMemberDocs[0].getMemberUsername(), memberAuth.getUsername());
- webClient1.removeSpaceMember(USERNAME2);
- membershipDocs = webClient2.getUsersSpaceMemberships();
- assertEquals(0, membershipDocs.length);
+ ownerClient.removeSpaceMember(spaceDocument.getSpaceID(), memberAuth.getUsername());
+ membershipDocs = memberClient.getUsersSpaceMemberships();
+ assertEquals(0, membershipDocs.length);
+ }
- SpaceDocument[] spaceDocs = webClient1.getAccountSpaceDocuments(USERNAME1);
- assertTrue("space docs length is " + spaceDocs.length, spaceDocs.length >= 1);
- }
+ private void checkSpaceMembership(long spaceID, WebAPIClient webClient1) throws IOException {
+ SpaceMemberDocument[] membershipDocs = webClient1.getUsersSpaceMemberships();
+ assertNotNull(membershipDocs);
+ assertEquals(0, membershipDocs.length);
- private void checkSpaceMembership(WebAPIClient webClient1) throws IOException {
- SpaceMemberDocument[] membershipDocs = webClient1.getUsersSpaceMemberships();
- assertNotNull(membershipDocs);
- assertEquals(0, membershipDocs.length);
+ webClient1.addSpaceMember(spaceID, USERNAME2, SpaceMemberDocument.MEMBER);
+ membershipDocs = webClient1.getSpaceMemberDocuments(spaceID);
+ assertNotNull(membershipDocs);
+ assertEquals(1, membershipDocs.length);
+ assertEquals(USERNAME2, membershipDocs[0].getMemberUsername());
+ assertEquals(SpaceMemberDocument.MEMBER, membershipDocs[0].getRole());
+ }
- webClient1.addSpaceMember(USERNAME2, SpaceMemberDocument.MEMBER);
- membershipDocs = webClient1.getSpaceMemberDocuments();
- assertNotNull(membershipDocs);
- assertEquals(1, membershipDocs.length);
- assertEquals(USERNAME2, membershipDocs[0].getMemberUsername());
- assertEquals(SpaceMemberDocument.MEMBER, membershipDocs[0].getRole());
- }
+ private void checkSettings(long spaceID, WebAPIClient webClient1) throws IOException {
+ String key1 = "ogoglio.key.1";
+ String value1 = "This is a very fine value which is < 1";
+ assertNull(webClient1.getSpaceSetting(spaceID, key1));
+ webClient1.putSpaceSetting(spaceID, key1, value1);
+ assertEquals(value1, webClient1.getSpaceSetting(spaceID, key1));
- private void checkSettings(WebAPIClient webClient1) throws IOException {
- String key1 = "ogoglio.key.1";
- String value1 = "This is a very fine value which is < 1";
- assertNull(webClient1.getSetting(key1));
- webClient1.putSetting(key1, value1);
- assertEquals(value1, webClient1.getSetting(key1));
+ String key2 = "ogoglio.key.2";
+ String value2 = "This is a very fine value & it's value is > 2";
+ assertNull(webClient1.getSpaceSetting(spaceID, key2));
+ webClient1.putSpaceSetting(spaceID, key2, value2);
+ assertEquals(value2, webClient1.getSpaceSetting(spaceID, key2));
+ assertEquals(value1, webClient1.getSpaceSetting(spaceID, key1));
- String key2 = "ogoglio.key.2";
- String value2 = "This is a very fine value & it's value is > 2";
- assertNull(webClient1.getSetting(key2));
- webClient1.putSetting(key2, value2);
- assertEquals(value2, webClient1.getSetting(key2));
- assertEquals(value1, webClient1.getSetting(key1));
+ webClient1.removeSpaceSetting(spaceID, key1);
+ assertNull(webClient1.getSpaceSetting(spaceID, key1));
+ webClient1.removeSpaceSetting(spaceID, key2);
+ assertNull(webClient1.getSpaceSetting(spaceID, key2));
+ }
- webClient1.removeSetting(key1);
- assertNull(webClient1.getSetting(key1));
- webClient1.removeSetting(key2);
- assertNull(webClient1.getSetting(key2));
- }
+ private void checkBody(WebAPIClient webClient1, WebAPIAuthenticator authenticator) throws IOException {
+ AccountDocument ownerDoc = authenticator.getAccountDocument(true);
+ assertNotNull(ownerDoc);
+ assertEquals(USERNAME1, ownerDoc.getUsername());
+ long defaultBody = ownerDoc.getDefaultBodyID();
+ BodyDocument bodyDoc = webClient1.createBody("Testing Body");
+ assertFalse(bodyDoc.getBodyID() == -1);
+ assertEquals(ownerDoc.getUsername(), bodyDoc.getOwnerUsername());
+ assertEquals(0, bodyDoc.getHairIndex());
+ assertEquals(0, bodyDoc.getEyesIndex());
+ assertEquals(0, bodyDoc.getNoseIndex());
+ assertEquals(0, bodyDoc.getMouthIndex());
+ assertEquals(0, bodyDoc.getFaceIndex());
+ ownerDoc = webClient1.setDefaultBody(bodyDoc.getBodyID());
+ assertEquals(bodyDoc.getBodyID(), ownerDoc.getDefaultBodyID());
+ assertEquals(ownerDoc.getUsername(), bodyDoc.getOwnerUsername());
+ bodyDoc.setEyesIndex(3);
+ bodyDoc = webClient1.updateBody(bodyDoc);
+ assertEquals(3, bodyDoc.getEyesIndex());
+ assertFalse(webClient1.deleteBody(bodyDoc.getBodyID()));
+ webClient1.setDefaultBody(defaultBody);
+ assertTrue(webClient1.deleteBody(bodyDoc.getBodyID()));
+ ownerDoc = webClient1.setDefaultBody(bodyDoc.getBodyID());
+ assertEquals(defaultBody, ownerDoc.getDefaultBodyID());
+ }
- private void checkBody(WebAPIClient webClient1) throws IOException {
- AuthDocument authDoc = webClient1.getAuthDocument(true);
- assertNotNull(authDoc);
- assertEquals(USERNAME1, authDoc.getUsername());
+ private SpaceDocument checkSpaceSeaLevel(WebAPIClient webClient1, SpaceDocument spaceDocument) throws IOException {
+ assertFalse(spaceDocument.getDisplaySea());
+ assertEquals(0, spaceDocument.getSeaLevel(), 0.001);
+ webClient1.setSpaceSeaLevel(spaceDocument.getSpaceID(), -2);
+ spaceDocument = webClient1.getSpaceDocument(spaceDocument.getSpaceID(), false);
+ assertEquals(-2, spaceDocument.getSeaLevel(), 0.000001);
+ webClient1.setSpaceDisplaySea(spaceDocument.getSpaceID(), true);
+ spaceDocument = webClient1.getSpaceDocument(spaceDocument.getSpaceID(), false);
+ assertTrue(spaceDocument.getDisplaySea());
+ return spaceDocument;
+ }
- AccountDocument ownerDoc = webClient1.getAccountDocument(authDoc.getUsername());
- assertNotNull(ownerDoc);
- assertEquals(USERNAME1, ownerDoc.getUsername());
- long defaultBody = ownerDoc.getDefaultBodyID();
- BodyDocument bodyDoc = webClient1.createBody();
- assertFalse(bodyDoc.getBodyID() == -1);
- assertEquals(ownerDoc.getUsername(), bodyDoc.getOwnerUsername());
- assertEquals(0, bodyDoc.getHairIndex());
- assertEquals(0, bodyDoc.getEyesIndex());
- assertEquals(0, bodyDoc.getNoseIndex());
- assertEquals(0, bodyDoc.getMouthIndex());
- assertEquals(0, bodyDoc.getFaceIndex());
- ownerDoc = webClient1.setDefaultBody(bodyDoc.getBodyID());
- assertEquals(bodyDoc.getBodyID(), ownerDoc.getDefaultBodyID());
- assertEquals(ownerDoc.getUsername(), bodyDoc.getOwnerUsername());
- bodyDoc.setEyesIndex(3);
- bodyDoc = webClient1.updateBody(bodyDoc);
- assertEquals(3, bodyDoc.getEyesIndex());
- assertFalse(webClient1.deleteBody(bodyDoc.getBodyID()));
- webClient1.setDefaultBody(defaultBody);
- assertTrue(webClient1.deleteBody(bodyDoc.getBodyID()));
- ownerDoc = webClient1.setDefaultBody(bodyDoc.getBodyID());
- assertEquals(defaultBody, ownerDoc.getDefaultBodyID());
- }
+ private void checkNoConnectionToSpaceWithoutAuth(long spaceID) {
+ try {
+ WebAPIGuestAuthenticator guestAuth = new WebAPIGuestAuthenticator(descriptor1, AuthServlet.GUEST_COOKIE_PREFIX + "Test_Suite_Guest");
+ new WebAPIClient(descriptor1, guestAuth, wire1).getSpaceDocument(spaceID, false);
+ fail("Should get an IOException when not authed");
+ } catch (IOException e) {
+ //this should happen
+ }
+ }
- private SpaceDocument checkSpaceSeaLevel(WebAPIClient webClient1, SpaceDocument spaceDocument) throws IOException {
- assertFalse(spaceDocument.getDisplaySea());
- assertEquals(0, spaceDocument.getSeaLevel(), 0.001);
- webClient1.setSeaLevel(-2);
- spaceDocument = webClient1.getSpaceDocument(false);
- assertEquals(-2, spaceDocument.getSeaLevel(), 0.000001);
- webClient1.setDisplaySea(true);
- spaceDocument = webClient1.getSpaceDocument(false);
- assertTrue(spaceDocument.getDisplaySea());
- return spaceDocument;
- }
+ private SpaceClient authThenBuildSpaceClient(long spaceID, WebAPIAuthenticator auth1) throws IOException {
+ TestSpaceClientListener listener = new TestSpaceClientListener();
+ SpaceClient spaceClient1 = new SpaceClient(spaceID, serviceURI1, auth1.getAuthCookie(), listener);
+ return spaceClient1;
+ }
- private void checkNoConnectionToSpaceWithoutAuth(URI spaceURI1) {
- try {
- new WebAPIClient(spaceURI1, serviceURI1, "BadBadCookie").getSpaceDocument(false);
- fail("Should get an IOException when not authed");
- } catch (IOException e) {
- //this should happen
- }
- }
+ private void checkGeometryAvailableForSpace(WebAPIClient webClient1, ThingDocument[] thingDocs, Space space1) throws IOException {
+ TestListener testListener = new TestListener();
+ space1.addListener(testListener, false);
- private SpaceClient authThenBuildSpaceClient(URI spaceURI1) throws IOException {
- SpaceClient spaceClient1;
- String authCookie1;
- //auth to login to the svc
- authCookie1 = WebAPIUtil.authenticate(serviceURI1, USERNAME1, PASSWORD1);
- assertNotNull("got null auth cookie", authCookie1);
+ //make sure we can get one thing from the space (maybe floor?) and check geom stream
+ assertNotNull(space1.getThing(1));
+ InputStream stream = space1.getThing(1).getGeometryStream(0);
+ assertNotNull(stream);
+ consume(stream);
- //reconnect to space, authenticated this time?
- TestSpaceClientListener listener = new TestSpaceClientListener();
- spaceClient1 = new SpaceClient(spaceURI1, serviceURI1, authCookie1, listener);
- return spaceClient1;
- }
+ // get our possession out of the space
+ long possID = thingDocs[0].getPossessionID();
+ webClient1.removePossessionFromSpace(possID);
+ thingDocs = webClient1.getThingDocuments(space1.getSpaceID());
+ assertEquals(0, thingDocs.length);
- private void checkGeometryAvailableForSpace(WebAPIClient webClient1, ThingDocument[] thingDocs, Space space1) throws IOException {
- TestListener testListener = new TestListener();
- space1.addListener(testListener, false);
-
- //make sure we can get one thing from the space (maybe floor?) and check geom stream
- assertNotNull(space1.getThing(1));
- InputStream stream = space1.getThing(1).getGeometryStream(0);
- assertNotNull(stream);
- consume(stream);
+ //put it back so the world is in the same state
+ //XXX EVIL! DEPENDENCY BETWEEN TESTS! BOO HISS!
+ webClient1.addPossessionToSpace(possID, space1.getSpaceID());
+ }
- // get our possession out of the space
- long possID=thingDocs[0].getPossessionID();
- webClient1.removePossessionFromSpace(thingDocs[0].getOwnerUsername(), possID);
- thingDocs = webClient1.getThingDocuments();
- assertEquals(0, thingDocs.length);
-
- //put it back so the world is in the same state
- //XXX EVIL! DEPENDENCY BETWEEN TESTS! BOO HISS!
- webClient1.addPossessionToSpace(possID, space1.getSpaceID());
- }
+ private SpaceClient checkGuestCookieOperation(long spaceID, WebAPIClient webClient1, String guestCookie1) throws IOException {
+ assertNotNull(guestCookie1);
- private SpaceClient checkGuestCookieOperation(URI spaceURI1, WebAPIClient webClient1, String guestCookie1) throws IOException {
- SpaceClient guestSpaceClient1;
- assertNotNull(guestCookie1);
- try {
- //try to get into the space without proper credentials
- guestSpaceClient1 = new SpaceClient(spaceURI1, serviceURI1, guestCookie1, new TestSpaceClientListener());
- fail("Should not be able to guest into the space yet");
- } catch (IOException e) {
- //this ...
[truncated message content] |
|
From: <ian...@us...> - 2007-08-06 17:34:15
|
Revision: 235
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=235&view=rev
Author: iansmith
Date: 2007-08-06 10:34:13 -0700 (Mon, 06 Aug 2007)
Log Message:
-----------
Fixed the problems identified in Trevor's previous message
with respect to tests and DB configuration.
--------------------- Significant Change ------------------
There is a new file in the docs directory, "properties.example.txt' which should be copied and moved to your home directory as .ogoglio-properties. You'll need to update the values in this file to point to the correct database you are using for development.
-------------------- Data Issue ---------------------------
I removed the (bogus) file MigrateDB_TemplateTables. This file was wrong in both theory and practice. If you have data that was created in a server prior to the change in the Template data format, you should wait until we have new and better thought out data migration tool.
Modified Paths:
--------------
spaces/trunk/docs/server.xml
spaces/trunk/src/com/ogoglio/client/ClientTests.java
spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java
spaces/trunk/src/com/ogoglio/persist/HibernateBase.java
spaces/trunk/src/com/ogoglio/persist/HibernateTests.java
spaces/trunk/src/com/ogoglio/persist/Persist.hbm.xml
spaces/trunk/src/com/ogoglio/persist/PersistTests.java
spaces/trunk/src/com/ogoglio/persist/ServiceInitializationPersistTasks.java
spaces/trunk/src/com/ogoglio/persist/SimPersistTasks.java
spaces/trunk/src/com/ogoglio/persist/SpacePersistTasks.java
spaces/trunk/src/com/ogoglio/site/AccountServlet.java
spaces/trunk/src/com/ogoglio/site/AuthServlet.java
spaces/trunk/src/com/ogoglio/templatesync/SyncToolSpec.java
spaces/trunk/src/com/ogoglio/templatesync/SyncToolTest.java
spaces/trunk/src/com/ogoglio/templatesync/TemplateServerSideTests.java
Added Paths:
-----------
spaces/trunk/docs/properties-example.txt
spaces/trunk/src/com/ogoglio/util/OgoglioProperties.java
spaces/trunk/src/com/ogoglio/util/PrepareDatabase.java
Removed Paths:
-------------
spaces/trunk/src/com/ogoglio/PrepareDatabase.java
spaces/trunk/src/com/ogoglio/persist/MigrateDB_TemplateTables.java
Added: spaces/trunk/docs/properties-example.txt
===================================================================
--- spaces/trunk/docs/properties-example.txt (rev 0)
+++ spaces/trunk/docs/properties-example.txt 2007-08-06 17:34:13 UTC (rev 235)
@@ -0,0 +1,78 @@
+#
+# This is an example of an ogoglio developer's properties file.
+# If a file in this format isn't in $HOME/.ogoglio-properties your tests
+# will fail. There are no defaults, you must edit these values to be
+# correct for your setup or the system may fail.
+
+#
+# TOMCAT
+#
+# pointer to your tomcat 5.5 install
+tomcat_dir = /usr/share/tomcat5.5
+
+#
+# LOCALHOST
+#
+# addr (where your development sever should live) ... might need to change this to test that
+# the server can be accessed by clients outside
+localhost_addr = 127.0.0.1:8080
+
+#
+# DATABASE
+#
+# Select which database to use. Valid values are "mysql" and "hsqldb".
+# If you chose hsqldb you will be running with an "in-memory" single user database.
+# no matter which you chose, the options that don't apply can be left in this file without harm
+# use "hqsl" for the other DB
+database_choice = mysql
+
+#
+# Hibernate dialect
+#
+#hibernate dialect for mysql (you can probably leave this alone)
+database_mysql_hibernate_dialect = org.hibernate.dialect.MySQLDialect
+#hibernate dialect for hsqldb (you can probably leave this alone)
+database_mysql_hibernate_dialect = org.hibernate.dialect.HSQLDialect
+#
+# JDBC Drivers
+#
+database_hsql_driver = org.hsqldb.jdbcDriver
+database_mysql_driver = com.mysql.jdbc.Driver
+
+#
+# SERVER CONFIGURATION FOR DB
+#
+#if you are using mysql this is a pointer to the database the server uses
+#you will need to create this database via mysqladmin create <name> ("og" in this example)
+database_mysql_server_uri = jdbc:mysql://127.0.0.1/og?autoreconnect=true
+#username to access the server's database
+database_mysql_server_user = oguser
+#password to access the server's database
+database_mysql_server_pass = sssh
+
+#hsql settings (URI points to a file in the filesystem where stuff gets stored)
+database_hsql_server_uri = jdbc:hsqldb:/tmp/ogoglio-db
+#username to access the server's database
+database_hsql_server_user = sa
+#password to access the server's database
+database_hsql_server_pass =
+
+#
+# TEST CONFIGURATION FOR DB
+#
+#if you are using mysql this is a pointer to the database the server uses
+#you will need to create this database via mysqladmin create <name> ("ogtest" in this example)
+database_mysql_test_uri = jdbc:mysql://127.0.0.1/ogtest?autoreconnect=true
+#username to access the server's database
+database_mysql_test_user = oguser
+#password to access the server's database
+database_mysql_test_pass = sssh
+
+#hsql settings (note that the uri points to a file in the filesystem)
+database_hsql_test_uri = jdbc:hsqldb:/tmp/ogoglio-test-db
+#username to access the server's database
+database_hsql_test_user = sa
+#password to access the server's database
+database_hsql_test_pass =
+
+
Modified: spaces/trunk/docs/server.xml
===================================================================
--- spaces/trunk/docs/server.xml 2007-08-04 00:19:57 UTC (rev 234)
+++ spaces/trunk/docs/server.xml 2007-08-06 17:34:13 UTC (rev 235)
@@ -17,7 +17,8 @@
<Logger className="org.apache.catalina.logger.SystemOutLogger" verbosity="4" timestamp="true"/>
<!-- THIS DEFINES THE DATABASE USED BY THE OGOGLIO SERVLETS, SET THE HSQL PATH OR ANOTHER JDBC URL (e.g. MySQL) -->
- <Resource name="jdbc/space" scope="Shareable" type="javax.sql.DataSource" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" url="jdbc:hsqldb:/Users/trevor/Code/EclipseWorkspace/spaces/db/ogoglio" driverClassName="org.hsqldb.jdbcDriver" username="sa" password="" maxIdle="5" maxActive="50" />
+ <!-- <Resource name="jdbc/space" scope="Shareable" type="javax.sql.DataSource" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" url="jdbc:hsqldb:/tmp/ogogliodb" driverClassName="org.hsqldb.jdbcDriver" username="sa" password="" maxIdle="5" maxActive="50" /> -->
+ <Resource name="jdbc/space" scope="Shareable" type="javax.sql.DataSource" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" url="jdbc:mysql:/og" driverClassName="com.mysql.jdbc.Driver" username="oguser" password="sssh" maxIdle="5" maxActive="50" />
<!-- THE FOLLOWING VARIABLES ARE READ IN com.ogoglio.site.AbstractResourceServet.init -->
Deleted: spaces/trunk/src/com/ogoglio/PrepareDatabase.java
===================================================================
--- spaces/trunk/src/com/ogoglio/PrepareDatabase.java 2007-08-04 00:19:57 UTC (rev 234)
+++ spaces/trunk/src/com/ogoglio/PrepareDatabase.java 2007-08-06 17:34:13 UTC (rev 235)
@@ -1,58 +0,0 @@
-package com.ogoglio;
-
-import java.net.URI;
-
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.Configuration;
-
-import com.ogoglio.media.MediaStore;
-import com.ogoglio.persist.HibernateBase;
-import com.ogoglio.persist.ServiceInitializationPersistTasks;
-
-public class PrepareDatabase extends HibernateBase {
-
- /*
- * This is the beginning of a utility program to allow you be sure that your database is ready to
- * be used by the space (web) service. This opens the database in the correct mode to get it to
- * drop all the existing tables, create them according to the Persist.hbm.xml document while dumping
- * to the terminal the SQL it is using, and then exiting cleanly.
- *
- * This is program is only used on development machines to initialize their local HSQL instance
- * into a fresh state. After this program has run successfully, you can fire up the web service,
- * and the test suite can AND SHOULD be run.
- */
- /**
- * @param args IGNORED
- */
- public static void main(String[] args) {
- if (args.length!=2) {
- System.out.println("Need to pass the username and password on the command line!");
- System.exit(1);
- }
- new PrepareDatabase().start(args[0], args[1]);
- }
- public void start(String user, String pass) {
- setupSessionFactory("com/ogoglio/persist/Persist.hbm.xml",
- "create",
- "org.hibernate.dialect.MySQLDialect",
- "com.mysql.jdbc.Driver",
- "jdbc:mysql://127.0.0.1/og?autoReconnect=true",
- user, pass,
- "5");
- config.setProperty("hibernate.connection.shutdown","true");
- String host = "10.0.1.198"; //best choice: 127.0.0.1
- String siteInfo = "http://"+host+":8080/og"; //configured in server.xml
- SessionFactory sessionFactory = getSessionFactory();
- try {
- //new SchemaUpdate(configuration).execute(true,true);
- ServiceInitializationPersistTasks.initializeLocalSim(new URI(siteInfo), sessionFactory);
- ServiceInitializationPersistTasks.initializeLibraryAccount(sessionFactory,host);
- sessionFactory.close();
- System.out.println("Completed successfully. DB is now ready.");
- } catch (Exception e) {
- e.printStackTrace();
- System.err.println("Exception during attempt to init DB:\n"+e.getMessage());
- }
- }
-
-}
Modified: spaces/trunk/src/com/ogoglio/client/ClientTests.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-08-04 00:19:57 UTC (rev 234)
+++ spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-08-06 17:34:13 UTC (rev 235)
@@ -75,6 +75,7 @@
WebAPIDescriptor descriptor1 = null;
+
public void setUp() {
try {
serviceURI1 = new URI("http://127.0.0.1:8080/og/"); //best choice: 127.0.0.1 for tests
Modified: spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java
===================================================================
--- spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java 2007-08-04 00:19:57 UTC (rev 234)
+++ spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java 2007-08-06 17:34:13 UTC (rev 235)
@@ -22,6 +22,7 @@
public class AccountPersistTasks {
public static final String ACCOUNT_BY_USERNAME = "com.ogoglio.persist.accountByUsername";
+ public static final String ACCOUNT_BY_EMAIL = "com.ogoglio.persist.accountByEmail";
public static final String ACCOUNT_BY_COOKIE = "com.ogoglio.persist.accountByCookie";
@@ -130,13 +131,24 @@
AccountRecord record = (AccountRecord)query.uniqueResult();
if(record != null) {
- return null;
+ return null; // XXX really weird semantic: try to create something and get null because it's there?
}
+ //IES:debug because unique constraint on this field!
+ final String cleanedEmail = AccountRecord.cleanEmail(email);
+ query = hibernateSession.getNamedQuery(ACCOUNT_BY_EMAIL);
+ query.setParameter("email", email);
+ record = (AccountRecord)query.uniqueResult();
+ if (record!=null) {
+ System.err.println("Whoa! Bad email value!"+email);
+ }
+
+
record = new AccountRecord(username, accountlevel, email);
hibernateSession.save(record);
BodyRecord bodyRec = new BodyRecord("Body", record.getUsername());
hibernateSession.save(bodyRec);
+
record.setDefaultBodyID(bodyRec.getBodyID());
hibernateSession.update(record);
return record;
@@ -161,4 +173,16 @@
task.setSessionFactory(sessionFactory);
return (AccountRecord) task.execute();
}
+
+ public static void delete(final AccountRecord accRec,SessionFactory sessionFactory) throws PersistException {
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ hibernateSession.delete(accRec);
+ return null;
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ task.execute();
+
+ }
}
Modified: spaces/trunk/src/com/ogoglio/persist/HibernateBase.java
===================================================================
--- spaces/trunk/src/com/ogoglio/persist/HibernateBase.java 2007-08-04 00:19:57 UTC (rev 234)
+++ spaces/trunk/src/com/ogoglio/persist/HibernateBase.java 2007-08-06 17:34:13 UTC (rev 235)
@@ -3,6 +3,8 @@
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
+import com.ogoglio.util.OgoglioProperties;
+
/**
* Allows the hibernate initialization code to be in one place. Serves a few different purposes, but
* in general allows connection the hibernate DB directly from a program or test.
@@ -10,46 +12,77 @@
*
*/
public class HibernateBase {
+ private static final String DB_USER = "OGOGLIO_DB_USER";
+
+ private static final String DB_NAME = "OGOGLIO_DB_NAME";
+
+ private static final String DB_PASS = "OGOGLIO_DB_PASSWORD";
+
+ private static final String DB_USE_MYSQL= "OGOGLIO_USE_MYSQL";
+
protected Configuration config = null;
+
protected SessionFactory sessionFactory = null;
- public void setupSessionFactory(String persistXMLConfig, String autoDDL, String dialect, String driver, String URL, String user, String pw, String poolSize) {
- config = new Configuration();
- config.addResource(persistXMLConfig);
- if (autoDDL!=null) {
- config.setProperty("hibernate.hbm2ddl.auto", autoDDL);
- }
- config.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
- config.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
- config.setProperty("hibernate.connection.url", "jdbc:mysql://127.0.0.1/og?autoReconnect=true");
- config.setProperty("hibernate.connection.username", "oguser");
- config.setProperty("hibernate.connection.password", "sssh");
- config.setProperty("hibernate.connection.pool_size", "5");
+ private void configErrorMessage() {
+ System.err.println("We have changed the way DB server configuration works now.");
+ System.err.println("You need to se these environment variables ");
+ System.err.println(DB_USER);
+ System.err.println(DB_NAME);
+ System.err.println(DB_PASS);
+ System.err.println(DB_USE_MYSQL);
+ System.err.println("to the right values for your local MySQL setup.");
+ System.exit(1);
+ }
+
+ public void setupSessionFactory(String persistXMLConfig, String autoDDL, String dialect, String driver, String URI,
+ String user, String pw, String poolSize) {
+
+ config = new Configuration();
+ config.addResource(persistXMLConfig);
- /*
- config.setProperty("hibernate.dialect", dialect);
- config.setProperty("hibernate.connection.driver_class", driver);
- config.setProperty("hibernate.connection.url", URL);
- config.setProperty("hibernate.connection.username", user);
- config.setProperty("hibernate.connection.password", pw);
- config.setProperty("hibernate.connection.pool_size", poolSize);
- config.setProperty("hibernate.connection.shutdown","true");
- */
- sessionFactory = config.buildSessionFactory();
- }
-
- public SessionFactory getSessionFactory() {
- return sessionFactory;
- }
-
-
- public void setupSessionFactoryForTest() {
- setupSessionFactory("com/ogoglio/persist/Persist.hbm.xml",
- "create",
- "org.hibernate.dialect.HSQLDialect",
- "org.hsqldb.jdbcDriver",
- "jdbc:hsqldb:test/db",
- "sa", "",
- "1");
- }
+
+ if (autoDDL!=null) {
+ config.setProperty("hibernate.hbm2ddl.auto", "create");
+ }
+ config.setProperty("hibernate.dialect", dialect);
+ config.setProperty("hibernate.connection.driver_class", driver);
+ config.setProperty("hibernate.connection.url", URI);
+ config.setProperty("hibernate.connection.username", user);
+ config.setProperty("hibernate.connection.password", pw);
+ //always want these
+ config.setProperty("hibernate.connection.shutdown","true");
+ config.setProperty("hibernate.connection.pool_size", poolSize);
+ sessionFactory = config.buildSessionFactory();
+
+ if (sessionFactory==null) {
+ System.err.println("You have no hope of running properly because sessionFactory was not setup correctly");
+ System.err.println("in com.ogoglio.persist.HibernateBase.java");
+ System.exit(1);
+ }
+
+ }
+
+ public SessionFactory getSessionFactory() {
+ return sessionFactory;
+ }
+
+ public void setupSessionFactoryForTest() {
+ String dialect, uri, user, pass, driver;
+
+ if (OgoglioProperties.getOgoglioProperty(OgoglioProperties.WHICH_DB).equals(OgoglioProperties.WHICH_MYSQL)) {
+ dialect = OgoglioProperties.getOgoglioProperty(OgoglioProperties.MYSQL_DB_DIALECT);
+ driver = OgoglioProperties.getOgoglioProperty(OgoglioProperties.MYSQL_DB_DRIVER);
+ uri = OgoglioProperties.getOgoglioProperty(OgoglioProperties.MYSQL_DB_TEST_URI);
+ user = OgoglioProperties.getOgoglioProperty(OgoglioProperties.MYSQL_DB_TEST_USER);
+ pass = OgoglioProperties.getOgoglioProperty(OgoglioProperties.MYSQL_DB_TEST_PASS);
+ } else {
+ dialect = OgoglioProperties.getOgoglioProperty(OgoglioProperties.HSQL_DB_DIALECT);
+ driver = OgoglioProperties.getOgoglioProperty(OgoglioProperties.HSQL_DB_DRIVER);
+ uri = OgoglioProperties.getOgoglioProperty(OgoglioProperties.HSQL_DB_TEST_URI);
+ user = OgoglioProperties.getOgoglioProperty(OgoglioProperties.HSQL_DB_TEST_USER);
+ pass = OgoglioProperties.getOgoglioProperty(OgoglioProperties.HSQL_DB_TEST_PASS);
+ }
+ setupSessionFactory("com/ogoglio/persist/Persist.hbm.xml",null,dialect,driver,uri,user,pass,"5");
+ }
}
Modified: spaces/trunk/src/com/ogoglio/persist/HibernateTests.java
===================================================================
--- spaces/trunk/src/com/ogoglio/persist/HibernateTests.java 2007-08-04 00:19:57 UTC (rev 234)
+++ spaces/trunk/src/com/ogoglio/persist/HibernateTests.java 2007-08-06 17:34:13 UTC (rev 235)
@@ -1,7 +1,6 @@
package com.ogoglio.persist;
import org.hibernate.SessionFactory;
-import org.hibernate.cfg.Configuration;
import com.agical.rmock.extension.junit.RMockTestCase;
@@ -11,12 +10,13 @@
protected SessionFactory sessionFactory=null;
public void setUp() {
if (sessionFactory==null) {
- base.setupSessionFactoryForTest();
- sessionFactory=base.getSessionFactory();
- }
+ base.setupSessionFactoryForTest();
+ sessionFactory=base.getSessionFactory();
+ }
}
public void tearDown() {
sessionFactory.close();
+ sessionFactory=null;
}
}
Deleted: spaces/trunk/src/com/ogoglio/persist/MigrateDB_TemplateTables.java
===================================================================
--- spaces/trunk/src/com/ogoglio/persist/MigrateDB_TemplateTables.java 2007-08-04 00:19:57 UTC (rev 234)
+++ spaces/trunk/src/com/ogoglio/persist/MigrateDB_TemplateTables.java 2007-08-06 17:34:13 UTC (rev 235)
@@ -1,287 +0,0 @@
-package com.ogoglio.persist;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.print.attribute.SupportedValuesAttribute;
-
-import org.hibernate.SessionFactory;
-
-import com.ogoglio.media.MediaService;
-
-//This is a truly dodgy piece of code. It is intended to be used with care. At some points it
-//copies pointers (e.g. a template ID) in a record without any care to whether or not the thing
-//pointed to makes sense. Thus, it depends on the numbering of the auto-created IDs in the
-//new database being the same as in the old one. This is certainly true for hsqldb but with
-//other databases, YMMV.
-//
-public class MigrateDB_TemplateTables extends HibernateBase {
-
- public static void main(String[] argv) {
- new MigrateDB_TemplateTables().start(argv);
- }
-
- public static final long BODY_INIT_VAL = -3828;
-
- long defaultBodyID = BODY_INIT_VAL;
-
- SessionFactory oldFactory;
- SessionFactory newFactory;
-
- /* You need to be sure that this points the right file or web storage URL */
- String URL_OF_MEDIA_STORE = "file:///home/iansmith/transmutable/workspace/spaces/working/media";
-
- public void createConnectionToOldAndNewDB()
- {
- /*
- * This CREATES the CURRENT database of ogoglio.
- * Modify the driver, URL, and username/pw if you are using MySQL. The current database
- * should not exist at the time this program is run; it will be created by this program.
- * If you are using HSQLDB then this means deleting the db files. Modify the driver, URL,
- * and username/pw if you are using MySQL.
- */
- setupSessionFactory("com/ogoglio/persist/Persist.hbm.xml", "create",
- "org.hibernate.dialect.HSQLDialect",
- "org.hsqldb.jdbcDriver",
- "jdbc:hsqldb:db/ogoglio", // <--- filename in your db directory, will end up in new format
- "sa", "",
- "1");
- newFactory = getSessionFactory();
-
- /*
- * This USES (doesn't destroy) the OLD database of ogoglio. Modify the driver, URL, and
- * username/pw if you are using MySQL.
- */
- setupSessionFactory("com/ogoglio/persist/Persist_NoTemplateTables.hbm.xml", null,
- "org.hibernate.dialect.HSQLDialect",
- "org.hsqldb.jdbcDriver",
- "jdbc:hsqldb:db/ogoglio-old",// <---- filename in your db directory of old format db
- "sa", "",
- "1");
- oldFactory = getSessionFactory();
-
- }
-
- public void start(String[] argv) {
- try {
-
- createConnectionToOldAndNewDB();
-
- copyAccounts();
- copyBodies();
- copySims();
- copySpaces();
- copySpaceMembers();
- patchTemplates();
- copyPossessions();
-
- newFactory.close();
- oldFactory.close();
- } catch (PersistException e) {
- e.printStackTrace();
- System.out.println("PersistException:"+e.getMessage());
- } catch (IOException e) {
- e.printStackTrace();
- System.out.println("IOException:"+e.getMessage());
- } catch (URISyntaxException e) {
- e.printStackTrace();
- System.out.println("URISyntaxException:"+e.getMessage());
- }
- }
-
- public void abort(String msg) {
- System.out.println(msg);
- System.exit(1);
- }
-
- public void copyPossessions() throws PersistException{
- PossessionRecord[] poss=PossessionPersistTasks.findAllPossessions(oldFactory);
- for (int i=0; i<poss.length;++i) {
- PossessionRecord curr=poss[i];
- PossessionRecord newPoss = PossessionPersistTasks.createPossession(curr.getOwnerUsername(), curr.getTemplateID(), newFactory);
- if (newPoss.getPossessionID()!=curr.getPossessionID()) {
- abort("Possession IDs have gotten out of order!");
- }
- newPoss.setSpaceID(curr.getSpaceID());
- newPoss.setThingID(curr.getThingID());
- PossessionPersistTasks.update(newPoss, newFactory);
- }
- }
- public void copySims() throws PersistException{
- SimRecord[] allOldSims=SimPersistTasks.findSims(oldFactory);
- for (int i=0; i<allOldSims.length;++i) {
- SimRecord curr=allOldSims[i];
- SimRecord newSim=SimPersistTasks.createSim(curr.getDisplayName(),
- curr.getSimURI(), curr.getEventPort(), curr.isActive(), newFactory);
- if (newSim.getSimID()!=curr.getSimID()) {
- abort("Sim IDs have gotten out of order!");
- }
- }
- }
- public void copySpaceMembers() throws PersistException{
- SpaceMemberRecord[] allOldSpaceMembers=SpaceMemberPersistTasks.findAllSpaceMembers(oldFactory);
- for (int i=0; i<allOldSpaceMembers.length;++i) {
- SpaceMemberRecord curr=allOldSpaceMembers[i];
- SpaceMemberRecord newSpaceMember = SpaceMemberPersistTasks.createSpaceMember(curr.getSpaceID(),
- curr.getMemberUsername(), curr.isBanned(), newFactory);
- if (newSpaceMember.getSpaceMemberID()!=curr.getSpaceMemberID()) {
- abort("SpaceMemberIDs have gotten out of order!");
- }
- newSpaceMember.setRole(curr.getRole());
- SpaceMemberPersistTasks.update(newSpaceMember, newFactory);
- }
- }
-
- public void copySpaces() throws PersistException{
- SpaceRecord[] allOldSpaces=SpacePersistTasks.findAllSpaces(oldFactory);
- for (int i=0; i<allOldSpaces.length;++i) {
- SpaceRecord curr=allOldSpaces[i];
- SpaceRecord newSpace = SpacePersistTasks.createSpace(curr.getDisplayName(),
- curr.getOwnerUsername(), newFactory);
- if (newSpace.getSpaceID()!=curr.getSpaceID()) {
- abort("SpaceIDs have gotten out of order!");
- }
- newSpace.setDisplaySea(curr.getDisplaySea());
- newSpace.setMaxGuests(curr.getMaxGuests());
- newSpace.setPublished(curr.isPublished());
- newSpace.setSeaLevel(curr.getSeaLevel());
- newSpace.setSimID(curr.getSimID());
- SpacePersistTasks.update(newSpace, newFactory);
- }
- }
-
- public void copyAccounts() throws PersistException
- {
- AccountRecord[] oldAccount = AccountPersistTasks.findAllAccounts(oldFactory);
- for (int i=0; i<oldAccount.length;++i) {
- AccountRecord curr=oldAccount[i];
- AccountRecord newAcct =
- AccountPersistTasks.createAccount(curr.getUsername(),curr.getAccountlevel(),curr.getEmail(), newFactory);
- newAcct.setPassword(curr.getPassword());
- AccountPersistTasks.update(newAcct, newFactory);
- //blow away the body because it is initialized to a default value and we are going
- //to copy it rather than use the default
- BodyRecord[] body = BodyPersistTasks.findBodyByUsername(newAcct.getUsername(), newFactory);
- if (body.length!=1) {
- System.err.println("Whoa! More than one body created by default! Or No body!");
- System.exit(1);
- }
- boolean delResult = BodyPersistTasks.delete(body[0], newFactory);
- if (delResult==false) {
- //System.err.println("Can't delete body for user "+newAcct.getUsername() + "(probably default)");
- }
- }
- }
-
- public long getDefaultBodyID() throws PersistException {
-
- if (defaultBodyID==BODY_INIT_VAL) {
- AccountRecord[] allAccts = AccountPersistTasks.findAllAccounts(newFactory);
- defaultBodyID=allAccts[0].getDefaultBodyID();
- }
- return defaultBodyID;
- }
-
- public void copyBodies() throws PersistException {
- BodyRecord[] oldBody = BodyPersistTasks.findAllBodies(oldFactory);
- for (int i=0; i<oldBody.length;++i) {
- BodyRecord curr=oldBody[i];
- //careful, may have been created by the creation of the account
- BodyRecord newBody = BodyPersistTasks.findBodyByID(curr.getBodyID(), newFactory);
- if (newBody==null) {
- newBody = BodyPersistTasks.createBody(curr.getDisplayName(),curr.getOwnerUsername(),newFactory);
- }
- if (newBody.getBodyID()!=curr.getBodyID()) {
- abort("BodyIDs have gotten out of order!");
- }
- newBody.setEyesIndex(curr.getEyesIndex());
- newBody.setFaceIndex(curr.getFaceIndex());
- newBody.setGirth(curr.getGirth());
- newBody.setHairIndex(curr.getHairIndex());
- newBody.setHeight(curr.getHeight());
- newBody.setMale(curr.getMale());
- newBody.setMouthIndex(curr.getMouthIndex());
- newBody.setNoseIndex(curr.getNoseIndex());
- BodyPersistTasks.update(newBody, newFactory);
- }
- }
-
- public void patchTemplates() throws PersistException, IOException, URISyntaxException{
- MediaService svc = new MediaService(new URI(URL_OF_MEDIA_STORE));
- String[] names=svc.getAllNames();
- int SIGNAL_NO_LOD_FOUND=-622;
- for (int i=0; i<names.length;++i) {
- String name=names[i];
- long templateID=-288;
- int lod = SIGNAL_NO_LOD_FOUND;
- TemplateRecord patched=null;
-
- if (name.startsWith(MediaService.TEMPLATE_GEOMETRY_PREFIX)){
- String shorter =name.substring(MediaService.TEMPLATE_GEOMETRY_PREFIX.length());
- String templateParsed = shorter.substring(0,shorter.indexOf('-'));
- String lodParsed = shorter.substring(shorter.indexOf('-')+1);
- try {
- templateID = Long.parseLong(templateParsed);
- } catch (NumberFormatException ex) {
- abort("Unable to understand the template ID in "+name);
- }
- try {
- lod = Integer.parseInt(lodParsed);
- if (lod!=0) {
- abort("We currently don't know how to handle any LOD except 0.");
- }
- } catch (NumberFormatException e) {
- //we have lod already in place
- }
- TemplateRecord curr = TemplatePersistTasks.findTemplateByTemplateID(templateID, oldFactory);
- if (curr==null) {
- continue;
- }
- patched = getTemplateByIDOrCreateIt(templateID, curr);
- TemplateSupportFileRecord rec;
- if (lod!=SIGNAL_NO_LOD_FOUND) {
- rec=TemplateSupportFilePersistTasks.createSupportFileForGeometry(lod,newFactory);
- } else {
- rec=TemplateSupportFilePersistTasks.createSupportFileForMaterial(lodParsed,newFactory);
- }
- patched.addTemplateSupportFileRecord(rec);
- TemplatePersistTasks.update(patched, newFactory);
- } else if (name.startsWith(MediaService.TEMPLATE_SCRIPT_PREFIX)) {
- if (!name.endsWith(MediaService.TEMPLATE_SCRIPT_SUFFIX)) {
- abort("Unable to handle that type of a script document:"+name);
- }
- String shorter = name.substring(MediaService.TEMPLATE_SCRIPT_PREFIX.length(),
- name.indexOf('.'));
- try {
- templateID = Long.parseLong(shorter);
- } catch (NumberFormatException e) {
- abort("Can't handle the template number on this script file:"+name);
- }
- TemplateRecord curr = TemplatePersistTasks.findTemplateByTemplateID(templateID, oldFactory);
- if (curr==null) {
- continue;
- }
- patched = getTemplateByIDOrCreateIt(templateID, curr);
- TemplateSupportFileRecord rec=TemplateSupportFilePersistTasks.createSupportFileForScript(newFactory);
- patched.addTemplateSupportFileRecord(rec);
- TemplatePersistTasks.update(patched, newFactory);
- } else if (name.startsWith(MediaService.SPACE_DOCUMENT_PREFIX)) {
- continue; //prevents trying to update!
- } else {
- System.out.println("WARNING: Ignoring media file:"+name);
- continue; //prevents trying to update!
- }
- }
- }
-
- private TemplateRecord getTemp...
[truncated message content] |
|
From: <tre...@us...> - 2007-08-07 00:22:08
|
Revision: 238
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=238&view=rev
Author: trevorolio
Date: 2007-08-06 17:22:09 -0700 (Mon, 06 Aug 2007)
Log Message:
-----------
Moved all of the jars our of war/WEB-INF/lib/ and into shared-lib/ so they should be put in ${CATALINA_HOME}/shared/lib/ instead of built into the ogoglio.war (as Gal suggested I do ages ago :-).
Added a sharedJar target to build.xml which will build some of the ogoglio classes which could be used by other webapps in the same tomcat instance, say for custom apps built on top of Ogoglio spaces.
That new target will build ogoglio-shared.jar which should also be placed in ${CATALINA_HOME}/shared/lib/
Modified Paths:
--------------
spaces/trunk/.classpath
spaces/trunk/build.xml
spaces/trunk/src/com/ogoglio/sim/Sim.java
spaces/trunk/src/com/ogoglio/sim/SpaceSimulator.java
Added Paths:
-----------
spaces/trunk/shared-lib/
spaces/trunk/shared-lib/antlr-2.7.5H3.jar
spaces/trunk/shared-lib/asm-attrs.jar
spaces/trunk/shared-lib/asm.jar
spaces/trunk/shared-lib/cglib-2.1.jar
spaces/trunk/shared-lib/cglib-nodep-2.1_2.jar
spaces/trunk/shared-lib/commons-codec-1.3.jar
spaces/trunk/shared-lib/commons-collections-2.1.1.jar
spaces/trunk/shared-lib/commons-fileupload-1.1.1.jar
spaces/trunk/shared-lib/commons-httpclient-3.0.1.jar
spaces/trunk/shared-lib/commons-io-1.3.jar
spaces/trunk/shared-lib/commons-logging-1.0.4.jar
spaces/trunk/shared-lib/dom4j-1.6.jar
spaces/trunk/shared-lib/ehcache-1.1.jar
spaces/trunk/shared-lib/hibernate3.jar
spaces/trunk/shared-lib/hsqldb.jar
spaces/trunk/shared-lib/js.jar
spaces/trunk/shared-lib/jta.jar
spaces/trunk/shared-lib/junit-3.8.1.jar
spaces/trunk/shared-lib/junit.jar
spaces/trunk/shared-lib/log4j-1.2.9.jar
spaces/trunk/shared-lib/mysql-connector-java-3.1.11-bin.jar
spaces/trunk/shared-lib/rmock-2.0.0.jar
spaces/trunk/shared-lib/xbean.jar
Removed Paths:
-------------
spaces/trunk/war/WEB-INF/lib/antlr-2.7.5H3.jar
spaces/trunk/war/WEB-INF/lib/asm-attrs.jar
spaces/trunk/war/WEB-INF/lib/asm.jar
spaces/trunk/war/WEB-INF/lib/cglib-2.1.jar
spaces/trunk/war/WEB-INF/lib/cglib-nodep-2.1_2.jar
spaces/trunk/war/WEB-INF/lib/commons-codec-1.3.jar
spaces/trunk/war/WEB-INF/lib/commons-collections-2.1.1.jar
spaces/trunk/war/WEB-INF/lib/commons-fileupload-1.1.1.jar
spaces/trunk/war/WEB-INF/lib/commons-httpclient-3.0.1.jar
spaces/trunk/war/WEB-INF/lib/commons-io-1.3.jar
spaces/trunk/war/WEB-INF/lib/commons-logging-1.0.4.jar
spaces/trunk/war/WEB-INF/lib/dom4j-1.6.jar
spaces/trunk/war/WEB-INF/lib/ehcache-1.1.jar
spaces/trunk/war/WEB-INF/lib/hibernate3.jar
spaces/trunk/war/WEB-INF/lib/hsqldb.jar
spaces/trunk/war/WEB-INF/lib/js.jar
spaces/trunk/war/WEB-INF/lib/jta.jar
spaces/trunk/war/WEB-INF/lib/junit-3.8.1.jar
spaces/trunk/war/WEB-INF/lib/junit.jar
spaces/trunk/war/WEB-INF/lib/log4j-1.2.9.jar
spaces/trunk/war/WEB-INF/lib/mysql-connector-java-3.1.11-bin.jar
spaces/trunk/war/WEB-INF/lib/rmock-2.0.0.jar
spaces/trunk/war/WEB-INF/lib/xbean.jar
Property Changed:
----------------
spaces/trunk/
Property changes on: spaces/trunk
___________________________________________________________________
Name: svn:ignore
- test
db
ogoglio.war
javadoc
+ test
db
ogoglio.war
ogoglio-shared.jar
javadoc
Modified: spaces/trunk/.classpath
===================================================================
--- spaces/trunk/.classpath 2007-08-06 23:44:42 UTC (rev 237)
+++ spaces/trunk/.classpath 2007-08-07 00:22:09 UTC (rev 238)
@@ -4,29 +4,31 @@
<classpathentry kind="var" path="TOMCAT_HOME/common/lib/servlet-api.jar"/>
<classpathentry kind="var" path="TOMCAT_HOME/common/lib/jasper-runtime.jar"/>
<classpathentry kind="var" path="TOMCAT_HOME/common/lib/jsp-api.jar"/>
- <classpathentry kind="src" output="work" path="work"/>
+ <classpathentry output="work" kind="src" path="work"/>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/mysql-connector-java-3.1.11-bin.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/log4j-1.2.9.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/jta.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/hsqldb.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/hibernate3.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/ehcache-1.1.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/dom4j-1.6.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/commons-logging-1.0.4.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/commons-collections-2.1.1.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/asm-attrs.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/asm.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/antlr-2.7.5H3.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/commons-fileupload-1.1.1.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/commons-io-1.3.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/xbean.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/js.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/commons-httpclient-3.0.1.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/commons-codec-1.3.jar"/>
<classpathentry kind="var" path="BROWSER_PLUGIN"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/cglib-nodep-2.1_2.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/junit-3.8.1.jar"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/rmock-2.0.0.jar"/>
+ <classpathentry kind="lib" path="shared-lib/xbean.jar"/>
+ <classpathentry kind="lib" path="shared-lib/rmock-2.0.0.jar"/>
+ <classpathentry kind="lib" path="shared-lib/mysql-connector-java-3.1.11-bin.jar"/>
+ <classpathentry kind="lib" path="shared-lib/log4j-1.2.9.jar"/>
+ <classpathentry kind="lib" path="shared-lib/junit-3.8.1.jar"/>
+ <classpathentry kind="lib" path="shared-lib/junit.jar"/>
+ <classpathentry kind="lib" path="shared-lib/jta.jar"/>
+ <classpathentry kind="lib" path="shared-lib/js.jar"/>
+ <classpathentry kind="lib" path="shared-lib/hsqldb.jar"/>
+ <classpathentry kind="lib" path="shared-lib/hibernate3.jar"/>
+ <classpathentry kind="lib" path="shared-lib/ehcache-1.1.jar"/>
+ <classpathentry kind="lib" path="shared-lib/dom4j-1.6.jar"/>
+ <classpathentry kind="lib" path="shared-lib/commons-collections-2.1.1.jar"/>
+ <classpathentry kind="lib" path="shared-lib/cglib-nodep-2.1_2.jar"/>
+ <classpathentry kind="lib" path="shared-lib/cglib-2.1.jar"/>
+ <classpathentry kind="lib" path="shared-lib/asm-attrs.jar"/>
+ <classpathentry kind="lib" path="shared-lib/asm.jar"/>
+ <classpathentry kind="lib" path="shared-lib/commons-logging-1.0.4.jar"/>
+ <classpathentry kind="lib" path="shared-lib/commons-io-1.3.jar"/>
+ <classpathentry kind="lib" path="shared-lib/commons-httpclient-3.0.1.jar"/>
+ <classpathentry kind="lib" path="shared-lib/commons-fileupload-1.1.1.jar"/>
+ <classpathentry kind="lib" path="shared-lib/commons-codec-1.3.jar"/>
+ <classpathentry kind="lib" path="shared-lib/antlr-2.7.5H3.jar"/>
<classpathentry kind="output" path="war/WEB-INF/classes"/>
</classpath>
Modified: spaces/trunk/build.xml
===================================================================
--- spaces/trunk/build.xml 2007-08-06 23:44:42 UTC (rev 237)
+++ spaces/trunk/build.xml 2007-08-07 00:22:09 UTC (rev 238)
@@ -6,131 +6,11 @@
<property name="webLibDir" value="./war/WEB-INF/lib/" />
<property name="warName" value="ogoglio.war" />
- <!--code coverage with emma -->
- <property name="emmaData" value="working/emma"/>
- <property name="coverage.dir" value="${emmaData}/reports/emma" /> <!-- directory which emma coverage reports will be written to -->
- <property name="instr.dir" value="${emmaData}/target/emmainstr" /> <!-- directory which emma instrumentation classes will be written to -->
- <property name="emma.dir" value="dev-lib/emma" /> <!-- directory that contains emma.jar and emma_ant.jar -->
- <property name="emma.source_classes" value="${dest}"/>
- <!-- Set emma.lib to refer to the list of EMMA jar files -->
- <path id="emma.lib" >
- <fileset dir="${emma.dir}">
- <include name="*.jar"/>
- </fileset>
- </path>
-
- <!-- which classes to work on -->
- <path id="emma.coverage.classes" >
- <pathelement location="${dest}" />
- </path>
- <!-- Load <emma> and <emmajava> custom tasks so that they can be used in ANT -->
- <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
-
- <path id="classpath">
- <fileset dir="${webLibDir}">
- <include name="**/*.jar" />
- </fileset>
- <fileset dir="${tomcatHome}/common/lib/">
- <include name="**/*.jar" />
- </fileset>
- <fileset dir="${java.home}/lib/">
- <include name="plugin.jar" />
- </fileset>
- </path>
-
- <!-- Enable Emma -->
- <target name="emma" description="turns on EMMA's instrumentation/reporting" >
-
- <property name="emma.enabled" value="true" />
-
- <!-- EMMA instr class output directory (it is important to create this property only when EMMA is enabled) -->
- <mkdir dir="${instr.dir}" />
-
- <!-- this property, if overriden via -Demma.filter=<list of filter specs>
- on ANT's command line, will set the coverage filter; by default,
- all classes found in 'emma.coverage.classes' pathref will be instrumented:
- -->
- <property name="emma.filter" value="+com.ogoglio.*,-*Test*,-*Spec*" />
- <property name="debug.on" value="true"/>
- </target>
-
- <target name="coverage" depends="cleanInstrumented,emma,test">
- </target>
-
- <target name="test" depends="compile">
- <!-- ======================================================================= -->
- <!-- EMMA INSTRUMENTATION -->
- <!-- ======================================================================= -->
- <!-- Instrument the classes, this takes the normal classes, and makes instrumented classes instead -->
- <!-- Note that EMMA takes regular ANT path elements as instrumentation input, which is exceedingly convenient -->
- <emma enabled="${emma.enabled}" >
- <instr instrpath="${dest}"
- destdir="${instr.dir}"
- metadatafile="${coverage.dir}/metadata.emma"
- merge="false" mode="copy" filter="${emma.filter}">
- </instr>
- </emma>
- <junit fork="true" forkmode="once">
- <classpath>
- <pathelement location="${instr.dir}"/>
- <fileset dir="${webLibDir}">
- <include name="**/*.jar" />
- </fileset>
- <path refid="emma.lib" />
- <pathelement location="${dest}"/>
- </classpath>
- <formatter type="brief" usefile="false" />
- <!--<test name="com.ogoglio.templatesync.TemplateSyncTestSuite" /> -->
- <test name="com.ogoglio.OgoglioTestSuite" />
-
- <jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" />
- <jvmarg value="-Demma.coverage.out.merge=false" />
- </junit>
- <!-- if enabled, generate coverage report(s): -->
- <emma enabled="${emma.enabled}" >
- <report sourcepath="src"
- sort="+block,+name,+method,+class"
- metrics="method:90,block:90,line:90,class:100"
- >
- <!-- collect all EMMA data dumps (metadata and runtime)
- [this can be done via nested <fileset> fileset elements
- or <file> elements pointing to a single file]:
- -->
- <fileset dir="${coverage.dir}" >
- <include name="*.emma" />
- </fileset>
-
- <!-- for every type of report desired, configure a nested
- element; various report parameters
- can be inherited from the parent <report>
- and individually overridden for each report type:
- -->
- <txt outfile="${coverage.dir}/coverage.txt"
- depth="package"
- columns="class,method,block,line,name"
- />
- <xml outfile="${coverage.dir}/coverage.xml"
- depth="package"
- />
- <html outfile="${coverage.dir}/coverage.html"
- depth="method"
- columns="name,class,method,block,line"
- />
- </report>
- </emma>
- </target>
-
- <target name="cleanInstrumented">
- <delete>
- <fileset dir="${instr.dir}" includes="**/**"/>
- <fileset dir="${coverage.dir}" includes="**/**"/>
- </delete>
- </target>
-
<target name="clean">
<delete>
<fileset dir="${dest}" includes="**/*" />
<fileset dir="." file="${warName}" />
+ <fileset dir="." file="ogoglio-shared.jar" />
<fileset dir="war" file="testApplet.jar" />
<fileset dir="war" file="viewer.jar" />
<fileset dir="war" file="bodyEditor.jar" />
@@ -155,6 +35,18 @@
</copy>
</target>
+ <target name="sharedJar" depends="compile">
+ <jar destfile="ogoglio-shared.jar">
+ <fileset dir="${dest}">
+ <include name="com/ogoglio/util/**/*" />
+ <include name="com/ogoglio/media/**/*" />
+ <include name="com/ogoglio/site/AbstractResourceServlet*" />
+ <include name="com/ogoglio/site/SiteResource*" />
+ <include name="com/ogoglio/site/SiteInfo*" />
+ </fileset>
+ </jar>
+ </target>
+
<target name="testApplet" depends="compile">
<jar destfile="war/testApplet.jar">
<fileset dir="${dest}">
@@ -209,7 +101,7 @@
</jar>
</target>
- <target name="war" depends="compile, testApplet, viewerApplet, bodyEditorApplet">
+ <target name="war" depends="compile, testApplet, viewerApplet, bodyEditorApplet, sharedJar">
<jar destfile="${warName}" basedir="war" />
</target>
Added: spaces/trunk/shared-lib/antlr-2.7.5H3.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/antlr-2.7.5H3.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/asm-attrs.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/asm-attrs.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/asm.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/asm.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/cglib-2.1.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/cglib-2.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/cglib-nodep-2.1_2.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/cglib-nodep-2.1_2.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/commons-codec-1.3.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/commons-codec-1.3.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/commons-collections-2.1.1.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/commons-collections-2.1.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/commons-fileupload-1.1.1.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/commons-fileupload-1.1.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/commons-httpclient-3.0.1.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/commons-httpclient-3.0.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/commons-io-1.3.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/commons-io-1.3.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/commons-logging-1.0.4.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/commons-logging-1.0.4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/dom4j-1.6.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/dom4j-1.6.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/ehcache-1.1.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/ehcache-1.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/hibernate3.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/hibernate3.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/hsqldb.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/hsqldb.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/js.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/js.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/jta.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/jta.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/junit-3.8.1.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/junit-3.8.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/junit.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/junit.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/log4j-1.2.9.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/log4j-1.2.9.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/mysql-connector-java-3.1.11-bin.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/mysql-connector-java-3.1.11-bin.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/rmock-2.0.0.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/rmock-2.0.0.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/shared-lib/xbean.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/shared-lib/xbean.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: spaces/trunk/src/com/ogoglio/sim/Sim.java
===================================================================
--- spaces/trunk/src/com/ogoglio/sim/Sim.java 2007-08-06 23:44:42 UTC (rev 237)
+++ spaces/trunk/src/com/ogoglio/sim/Sim.java 2007-08-07 00:22:09 UTC (rev 238)
@@ -22,8 +22,6 @@
import nanoxml.XMLElement;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.SessionFactory;
import com.ogoglio.media.MediaService;
Modified: spaces/trunk/src/com/ogoglio/sim/SpaceSimulator.java
===================================================================
--- spaces/trunk/src/com/ogoglio/sim/SpaceSimulator.java 2007-08-06 23:44:42 UTC (rev 237)
+++ spaces/trunk/src/com/ogoglio/sim/SpaceSimulator.java 2007-08-07 00:22:09 UTC (rev 238)
@@ -26,9 +26,6 @@
import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import com.ogoglio.client.UserInputListener;
import com.ogoglio.client.model.Door;
import com.ogoglio.client.model.GeometryProvider;
Deleted: spaces/trunk/war/WEB-INF/lib/antlr-2.7.5H3.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/asm-attrs.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/asm.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/cglib-2.1.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/cglib-nodep-2.1_2.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/commons-codec-1.3.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/commons-collections-2.1.1.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/commons-fileupload-1.1.1.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/commons-httpclient-3.0.1.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/commons-io-1.3.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/commons-logging-1.0.4.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/dom4j-1.6.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/ehcache-1.1.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/hibernate3.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/hsqldb.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/js.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/jta.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/junit-3.8.1.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/junit.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/log4j-1.2.9.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/mysql-connector-java-3.1.11-bin.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/rmock-2.0.0.jar
===================================================================
(Binary files differ)
Deleted: spaces/trunk/war/WEB-INF/lib/xbean.jar
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-08-08 18:33:56
|
Revision: 239
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=239&view=rev
Author: trevorolio
Date: 2007-08-08 11:33:54 -0700 (Wed, 08 Aug 2007)
Log Message:
-----------
Changed ogoglio.js defined escape(...) and unescape(...) to be escapeHTML(...) and unescapeHTML(...) so that they don't conflict with javascript's native escape(...) and unescape(...), which are used for url [de|en]coding.
Modified Paths:
--------------
spaces/trunk/build.xml
spaces/trunk/war/account.html
spaces/trunk/war/admin.html
spaces/trunk/war/body.html
spaces/trunk/war/doorPopup.html
spaces/trunk/war/inventory.html
spaces/trunk/war/ogoglio.js
spaces/trunk/war/spaceEditor.html
spaces/trunk/war/spacePopulation.html
spaces/trunk/war/spaceSettings.html
spaces/trunk/war/spaceui.js
spaces/trunk/war/templateEditor.html
Modified: spaces/trunk/build.xml
===================================================================
--- spaces/trunk/build.xml 2007-08-07 00:22:09 UTC (rev 238)
+++ spaces/trunk/build.xml 2007-08-08 18:33:54 UTC (rev 239)
@@ -43,6 +43,9 @@
<include name="com/ogoglio/site/AbstractResourceServlet*" />
<include name="com/ogoglio/site/SiteResource*" />
<include name="com/ogoglio/site/SiteInfo*" />
+ <include name="com/ogoglio/persist/HibernateTask*" />
+ <include name="com/ogoglio/persist/PersistException*" />
+ <include name="nanoxml/*" />
</fileset>
</jar>
</target>
Modified: spaces/trunk/war/account.html
===================================================================
--- spaces/trunk/war/account.html 2007-08-07 00:22:09 UTC (rev 238)
+++ spaces/trunk/war/account.html 2007-08-08 18:33:54 UTC (rev 239)
@@ -87,9 +87,9 @@
if("true" == banned){
tableHTML += "<td>banned</td>";
} else {
- tableHTML += "<td>" + escape(role) + "</td>";
+ tableHTML += "<td>" + escapeHTML(role) + "</td>";
}
- tableHTML += "<td><a href='space.html?spaceID=" + spaceID + "'>Space " + escape(spaceID) + "</a></td>";
+ tableHTML += "<td><a href='space.html?spaceID=" + spaceID + "'>Space " + escapeHTML(spaceID) + "</a></td>";
tableHTML += "</tr>";
}
spaceMembershipTable.innerHTML = "<table>" + tableHTML + "</table>";
@@ -119,7 +119,7 @@
var spaceID = spaceListXML.childNodes[i].getAttribute("spaceid");
var displayName = spaceListXML.childNodes[i].getAttribute("displayname");
tableHTML += "<tr>";
- tableHTML += "<td>" + escape(displayName) + "</td>";
+ tableHTML += "<td>" + escapeHTML(displayName) + "</td>";
tableHTML += "<td><form onsubmit='document.location.href=\"space.html?spaceID=" + spaceID + "\"; return false;'><input type='submit' value='view'/></form></td>";
tableHTML += "<td><form onsubmit='document.location.href=\"spaceEditor.html?spaceID=" + spaceID + "\"; return false;'><input type='submit' value='edit'/></form></td>";
tableHTML += "</tr>";
@@ -165,10 +165,10 @@
profileGoButton.value = "edit";
- accountXML.setAttribute("firstname", escape(document.getElementById("firstname").value));
- accountXML.setAttribute("lastname", escape(document.getElementById("lastname").value));
- accountXML.setAttribute("homepage", escape(document.getElementById("homepage").value));
- accountXML.setAttribute("password", escape(document.getElementById("password").value));
+ accountXML.setAttribute("firstname", escapeHTML(document.getElementById("firstname").value));
+ accountXML.setAttribute("lastname", escapeHTML(document.getElementById("lastname").value));
+ accountXML.setAttribute("homepage", escapeHTML(document.getElementById("homepage").value));
+ accountXML.setAttribute("password", escapeHTML(document.getElementById("password").value));
updateAccountDocument(accountXML, handleAccount);
profileTable.innerHTML = "saving...";
}
@@ -179,16 +179,16 @@
return "";
}
if(link){
- return "<tr><th>" + heading + ":</th><td><a rel='nofollow' href='" + escape(value) +"'>" + escape(value) + "</a></td></tr>\n";
+ return "<tr><th>" + heading + ":</th><td><a rel='nofollow' href='" + escapeHTML(value) +"'>" + escapeHTML(value) + "</a></td></tr>\n";
} else {
- return "<tr><th>" + heading + ":</th><td>" + escape(value) + "</td></tr>\n";
+ return "<tr><th>" + heading + ":</th><td>" + escapeHTML(value) + "</td></tr>\n";
}
}
function generateProfileInput(heading, field, value, comment) {
var nonNullValue = value == null ? "" : value;
var nonNullComment = comment == null ? "" : comment;
- var result = "<tr><th>" + heading + ":</th><td><input id='" + field + "' name='" + field + "' type='text' value='" + escape(nonNullValue) + "' /></td><td>" + escape(nonNullComment) + "</td></tr>\n";
+ var result = "<tr><th>" + heading + ":</th><td><input id='" + field + "' name='" + field + "' type='text' value='" + escapeHTML(nonNullValue) + "' /></td><td>" + escapeHTML(nonNullComment) + "</td></tr>\n";
return result;
}
Modified: spaces/trunk/war/admin.html
===================================================================
--- spaces/trunk/war/admin.html 2007-08-07 00:22:09 UTC (rev 238)
+++ spaces/trunk/war/admin.html 2007-08-08 18:33:54 UTC (rev 239)
@@ -171,10 +171,10 @@
profileGoButton.value = "edit";
- accountXML.setAttribute("firstname", escape(document.getElementById("firstname").value));
- accountXML.setAttribute("lastname", escape(document.getElementById("lastname").value));
- accountXML.setAttribute("homepage", escape(document.getElementById("homepage").value));
- accountXML.setAttribute("password", escape(document.getElementById("password").value));
+ accountXML.setAttribute("firstname", escapeHTML(document.getElementById("firstname").value));
+ accountXML.setAttribute("lastname", escapeHTML(document.getElementById("lastname").value));
+ accountXML.setAttribute("homepage", escapeHTML(document.getElementById("homepage").value));
+ accountXML.setAttribute("password", escapeHTML(document.getElementById("password").value));
updateAccountDocument(accountXML, handleAccount);
profileTable.innerHTML = "saving...";
}
@@ -185,16 +185,16 @@
return "";
}
if(link){
- return "<tr><th>" + heading + ":</th><td><a rel='nofollow' href='" + escape(value) +"'>" + escape(value) + "</a></td></tr>\n";
+ return "<tr><th>" + heading + ":</th><td><a rel='nofollow' href='" + escapeHTML(value) +"'>" + escapeHTML(value) + "</a></td></tr>\n";
} else {
- return "<tr><th>" + heading + ":</th><td>" + escape(value) + "</td></tr>\n";
+ return "<tr><th>" + heading + ":</th><td>" + escapeHTML(value) + "</td></tr>\n";
}
}
function generateProfileInput(heading, field, value, comment) {
var nonNullValue = value == null ? "" : value;
var nonNullComment = comment == null ? "" : comment;
- var result = "<tr><th>" + heading + ":</th><td><input id='" + field + "' name='" + field + "' type='text' value='" + escape(nonNullValue) + "' /></td><td>" + escape(nonNullComment) + "</td></tr>\n";
+ var result = "<tr><th>" + heading + ":</th><td><input id='" + field + "' name='" + field + "' type='text' value='" + escapeHTML(nonNullValue) + "' /></td><td>" + escapeHTML(nonNullComment) + "</td></tr>\n";
return result;
}
Modified: spaces/trunk/war/body.html
===================================================================
--- spaces/trunk/war/body.html 2007-08-07 00:22:09 UTC (rev 238)
+++ spaces/trunk/war/body.html 2007-08-08 18:33:54 UTC (rev 239)
@@ -65,7 +65,7 @@
return;
}
bodyXML = xml;
- titleElement.innerHTML = escape(bodyXML.getAttribute("displayname"));
+ titleElement.innerHTML = escapeHTML(bodyXML.getAttribute("displayname"));
writeApplet();
}
Modified: spaces/trunk/war/doorPopup.html
===================================================================
--- spaces/trunk/war/doorPopup.html 2007-08-07 00:22:09 UTC (rev 238)
+++ spaces/trunk/war/doorPopup.html 2007-08-08 18:33:54 UTC (rev 239)
@@ -55,7 +55,7 @@
function linkChangeGo(){
if(linkForm.goButton.value == 'change'){
- linkForm.innerHTML = "<input id='linkInput' type='text' value='" + escape(doorXML.getAttribute('link')) + "' size='30' style='font-size: 1.2em;' />";
+ linkForm.innerHTML = "<input id='linkInput' type='text' value='" + escapeHTML(doorXML.getAttribute('link')) + "' size='30' style='font-size: 1.2em;' />";
linkForm.innerHTML += "<input id='goButton' type='submit' onclick='linkChangeGo(); return false;' value='save' />";
} else {
var linkValue = trim(linkForm.linkInput.value);
@@ -63,7 +63,7 @@
doorXML.setAttribute('link', linkValue);
updateDoor(spaceID, doorXML, handleDoorDocument);
}
- linkForm.innerHTML = escape(doorXML.getAttribute('link'));
+ linkForm.innerHTML = escapeHTML(doorXML.getAttribute('link'));
linkForm.innerHTML += "<input id='goButton' type='submit' onclick='linkChangeGo(); return false;' value='change' />";
}
}
@@ -89,7 +89,7 @@
//NOTE: the current viewer currently scales all dimensions using scalex
scaleInput.value = parseFloat(doorXML.getAttribute('scalex')).toFixed(4);
- linkForm.innerHTML = escape(doorXML.getAttribute('link')) + " <input type='submit' id='goButton' onclick='linkChangeGo(); return false;' value='change' />";
+ linkForm.innerHTML = escapeHTML(doorXML.getAttribute('link')) + " <input type='submit' id='goButton' onclick='linkChangeGo(); return false;' value='change' />";
}
Modified: spaces/trunk/war/inventory.html
===================================================================
--- spaces/trunk/war/inventory.html 2007-08-07 00:22:09 UTC (rev 238)
+++ spaces/trunk/war/inventory.html 2007-08-08 18:33:54 UTC (rev 239)
@@ -131,11 +131,11 @@
continue;
}
tableHTML += "<tr>";
- tableHTML += "<td>" + escape(templateListXML.childNodes[i].getAttribute('displayname')) + "</td>";
+ tableHTML += "<td>" + escapeHTML(templateListXML.childNodes[i].getAttribute('displayname')) + "</td>";
tableHTML += "<td>" + (templateArray[templateID].length - 1) + "</td>";
tableHTML += "<td><form onsubmit='addToGo(" + templateID + "); return false;'><input type='submit' value='add to...'/></form></td>";
var possID = templateArray[templateID][1].getAttribute("possessionid");
- tableHTML += "<td><form onsubmit='deletePossession(\"" + escape(requestedUsername) + "\", " + possID + ", handleChangePossession); return false;'><input type='submit' value='delete'/></form></td>";
+ tableHTML += "<td><form onsubmit='deletePossession(\"" + escapeHTML(requestedUsername) + "\", " + possID + ", handleChangePossession); return false;'><input type='submit' value='delete'/></form></td>";
tableHTML += "</tr>";
}
@@ -154,7 +154,7 @@
for(var j=0; j < spaceListXML.childNodes.length; j++){
var listSpaceID = spaceListXML.childNodes[j].getAttribute('spaceid');
var spaceName = spaceListXML.childNodes[j].getAttribute('displayname');
- html += "<option value='" + listSpaceID + "'>" + escape(spaceName) + "</option>";
+ html += "<option value='" + listSpaceID + "'>" + escapeHTML(spaceName) + "</option>";
}
html += "</select></form>";
@@ -220,7 +220,7 @@
var id = xml.childNodes[i].getAttribute("templateid");
var displayName = xml.childNodes[i].getAttribute("displayname");
tableHTML += "<tr>";
- tableHTML += "<td>" + escape(displayName) + "</td>";
+ tableHTML += "<td>" + escapeHTML(displayName) + "</td>";
tableHTML += "<td><input type='submit' onclick='document.location.href=\"templateEditor.html?templateID=" + id +"\"' value='edit' /></td>";
tableHTML += "<td><input type='submit' onclick='addMyTemplateToInventoryGo(" + id + "); return false;' value='add to inventory' /></td>";
tableHTML += "</tr>";
Modified: spaces/trunk/war/ogoglio.js
===================================================================
--- spaces/trunk/war/ogoglio.js 2007-08-07 00:22:09 UTC (rev 238)
+++ spaces/trunk/war/ogoglio.js 2007-08-08 18:33:54 UTC (rev 239)
@@ -190,7 +190,7 @@
if (end == -1) {
end = dc.length;
}
- return unescape(dc.substring(begin + prefix.length, end));
+ return unescapeHTML(dc.substring(begin + prefix.length, end));
}
function debug(message){
@@ -207,7 +207,7 @@
var attributes = xml.attributes;
for (var i = 0; i < attributes.length; i++){
- result += " " + attributes.item(i).name.toLowerCase() + "='" + escape(attributes.item(i).value) + "'";
+ result += " " + attributes.item(i).name.toLowerCase() + "='" + escapeHTML(attributes.item(i).value) + "'";
}
var hasText = (typeof xml.text != "undefined") && xml.text.length != 0;
@@ -230,14 +230,14 @@
return result;
}
-function escape(xml){
+function escapeHTML(xml){
if(xml == null || xml.length == 0){
return xml;
}
return xml.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
};
-function unescape(xml){
+function unescapeHTML(xml){
return xml.replace(/'/g,"'").replace(/"/g,"\"").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&");
};
@@ -510,7 +510,7 @@
function createSpace(username, spaceName, listener){
var bodyXML = document.createElement("space");
bodyXML.setAttribute("ownerusername", username);
- bodyXML.setAttribute("displayname", escape(spaceName));
+ bodyXML.setAttribute("displayname", escapeHTML(spaceName));
var manager = new XMLRequestManager(appPath + "/space/", new BasicHTTPListener(listener));
manager.setMethod("POST");
manager.send(serializeXML(bodyXML));
@@ -578,7 +578,7 @@
function createTemplate(username, templateName, listener){
var xml = document.createElement("template");
xml.setAttribute("ownerusername", username);
- xml.setAttribute("displayname", escape(templateName));
+ xml.setAttribute("displayname", escapeHTML(templateName));
var manager = new XMLRequestManager(appPath + "/account/" + username + "/template/", new BasicHTTPListener(listener));
manager.setMethod("POST");
manager.send(serializeXML(xml));
@@ -677,7 +677,7 @@
function createDoor(spaceID, displayName, templateID, templateOwner, link, listener){
var xml = document.createElement("door");
- xml.setAttribute("displayname", escape(displayName));
+ xml.setAttribute("displayname", escapeHTML(displayName));
xml.setAttribute("templateid", templateID);
xml.setAttribute("templateowner", templateOwner);
xml.setAttribute("link", link);
Modified: spaces/trunk/war/spaceEditor.html
===================================================================
--- spaces/trunk/war/spaceEditor.html 2007-08-07 00:22:09 UTC (rev 238)
+++ spaces/trunk/war/spaceEditor.html 2007-08-08 18:33:54 UTC (rev 239)
@@ -93,7 +93,7 @@
spaceDoc = xml;
- titleElement.innerHTML = 'Space Editor: ' + escape(spaceDoc.getAttribute('displayname')) +' <input type="submit" id="titleFormGoButton" value="rename" />';
+ titleElement.innerHTML = 'Space Editor: ' + escapeHTML(spaceDoc.getAttribute('displayname')) +' <input type="submit" id="titleFormGoButton" value="rename" />';
enter.innerHTML = '<a href="space.html?spaceID=' + spaceID +'">Enter this space »</a>';
var pubHTML = 'This space is <select id="pubSelect" onchange="pubFormGo();" name="publicity">';
@@ -154,7 +154,7 @@
var thingID = xml.childNodes[i].getAttribute("thingid");
tableHTML += "<tr>";
var thingURL = "thingPopup.html?thingID=" + thingID + "&spaceID=" + spaceID;
- tableHTML += "<td><a onclick='popUp(\"" + thingURL + "\", false, 375, 450); return false;' href='index.html'>" + clip(escape(displayName), 25, "...") + "</a></td>";
+ tableHTML += "<td><a onclick='popUp(\"" + thingURL + "\", false, 375, 450); return false;' href='index.html'>" + clip(escapeHTML(displayName), 25, "...") + "</a></td>";
tableHTML += "<td><form onsubmit='thingDeleteGo(" + thingID + "); return false;' /><input type='submit' value='move to inventory' /></form></td>"
tableHTML += "<td><form onsubmit='reloadThing(" + spaceID + ", "+ thingID + "); return false;'><input type='submit' value='reload'/></form></td>";
tableHTML += "</tr>";
@@ -205,8 +205,8 @@
var doorID = xml.childNodes[i].getAttribute("doorid");
var displayName = xml.childNodes[i].getAttribute("displayname");
var doorURL = "doorPopup.html?doorID=" + doorID + "&spaceID=" + spaceID;
- tableHTML += "<td><a onclick='popUp(\"" + doorURL + "\", false, 400, 650); return false;' href='index.html'>" + clip(escape(displayName), 25, "...") + "</a></td>";
- tableHTML += "<td>" + escape(xml.childNodes[i].getAttribute("link")) + "</td></tr>";
+ tableHTML += "<td><a onclick='popUp(\"" + doorURL + "\", false, 400, 650); return false;' href='index.html'>" + clip(escapeHTML(displayName), 25, "...") + "</a></td>";
+ tableHTML += "<td>" + escapeHTML(xml.childNodes[i].getAttribute("link")) + "</td></tr>";
}
doorsTable.innerHTML = "<table>" + tableHTML + "</table>";
@@ -320,13 +320,13 @@
function titleFormGo(){
var goButton = document.getElementById("titleFormGoButton");
if(goButton.value == "rename"){
- titleElement.innerHTML = '<input type="text" id="titleInput" style="font-size: 1.5em;" value="' + escape(spaceDoc.getAttribute('displayname')) + '" />';
+ titleElement.innerHTML = '<input type="text" id="titleInput" style="font-size: 1.5em;" value="' + escapeHTML(spaceDoc.getAttribute('displayname')) + '" />';
titleElement.innerHTML += '<input value="save" type="submit" id="titleFormGoButton" />';
} else if(goButton.value == "save"){
var newTitle = titleForm.titleInput.value;
if(newTitle != null && trim(newTitle).length != 0){
goButton.enabled = false;
- spaceDoc.setAttribute('displayname', escape(trim(newTitle)));
+ spaceDoc.setAttribute('displayname', escapeHTML(trim(newTitle)));
updateSpaceDocument(spaceDoc, handleSpaceDocument);
} else {
handleSpaceDocument(spaceDoc);
Modified: spaces/trunk/war/spacePopulation.html
===================================================================
--- spaces/trunk/war/spacePopulation.html 2007-08-07 00:22:09 UTC (rev 238)
+++ spaces/trunk/war/spacePopulation.html 2007-08-08 18:33:54 UTC (rev 239)
@@ -55,7 +55,7 @@
spaceDoc = xml;
- titleElement.innerHTML = 'Space Population: ' + escape(spaceDoc.getAttribute('displayname'));
+ titleElement.innerHTML = 'Space Population: ' + escapeHTML(spaceDoc.getAttribute('displayname'));
requestUserList(spaceID, handleUserList);
}
@@ -75,8 +75,8 @@
}
var username = usersDoc.childNodes[i].getAttribute('username')
HTML += '<tr>';
- HTML += '<td>' + escape(username) + '</td>';
- HTML += '<td><form onsubmit="goBoot(\'' + escape(username) + '\'); return false;"><input type="submit" value="boot" /></form></td>';
+ HTML += '<td>' + escapeHTML(username) + '</td>';
+ HTML += '<td><form onsubmit="goBoot(\'' + escapeHTML(username) + '\'); return false;"><input type="submit" value="boot" /></form></td>';
HTML += '</tr>';
}
userTable.innerHTML = "<table>" + HTML + "</table>";
Modified: spaces/trunk/war/spaceSettings.html
===================================================================
--- spaces/trunk/war/spaceSettings.html 2007-08-07 00:22:09 UTC (rev 238)
+++ spaces/trunk/war/spaceSettings.html 2007-08-08 18:33:54 UTC (rev 239)
@@ -54,8 +54,8 @@
var formHTML = "";
if(form.goButton.value == "edit"){
var value = form.settingValue.value;
- formHTML += "<input id='key' type='hidden' value='" + escape(key) + "' />";
- formHTML += "<input id='settingValue' type='input' value='" + escape(value) + "' />";
+ formHTML += "<input id='key' type='hidden' value='" + escapeHTML(key) + "' />";
+ formHTML += "<input id='settingValue' type='input' value='" + escapeHTML(value) + "' />";
formHTML += " <input id='goButton' type='submit' value='save' />";
} else if(form.goButton.value == "save"){
var value = form.settingValue.value;
@@ -86,12 +86,12 @@
var key = xml.childNodes[i].getAttribute("key");
var value = xml.childNodes[i].firstChild.nodeValue;
tableHTML += "<tr>";
- tableHTML += "<td>" + escape(key) + "</td>";
+ tableHTML += "<td>" + escapeHTML(key) + "</td>";
tableHTML += "<td>";
tableHTML += "<form onsubmit='editFormGo(this); return false;'>";
- tableHTML += "<input id='key' type='hidden' value='" + escape(key) + "' />";
- tableHTML += "<input id='settingValue' type='hidden' value='" + escape(value) + "' />";
- tableHTML += escape(value);
+ tableHTML += "<input id='key' type='hidden' value='" + escapeHTML(key) + "' />";
+ tableHTML += "<input id='settingValue' type='hidden' value='" + escapeHTML(value) + "' />";
+ tableHTML += escapeHTML(value);
tableHTML += " <input id='goButton' type='submit' value='edit' />";
tableHTML += "</form></td>";
tableHTML += "</tr>";
Modified: spaces/trunk/war/spaceui.js
===================================================================
--- spaces/trunk/war/spaceui.js 2007-08-07 00:22:09 UTC (rev 238)
+++ spaces/trunk/war/spaceui.js 2007-08-08 18:33:54 UTC (rev 239)
@@ -105,7 +105,7 @@
displayName = displayName + "";
link = link + "";
- displayChatMessage("Link: <a onclick='popUp(this.href, true); return false;' href='" + link + "'>" + escape(displayName) + "</a>");
+ displayChatMessage("Link: <a onclick='popUp(this.href, true); return false;' href='" + link + "'>" + escapeHTML(displayName) + "</a>");
}
//called by the viewer applet
Modified: spaces/trunk/war/templateEditor.html
===================================================================
--- spaces/trunk/war/templateEditor.html 2007-08-07 00:22:09 UTC (rev 238)
+++ spaces/trunk/war/templateEditor.html 2007-08-08 18:33:54 UTC (rev 239)
@@ -56,7 +56,7 @@
}
templateDoc = xml;
- titleElement.innerHTML = "Template: " + escape(templateDoc.getAttribute('displayname')) + " <input id='titleFormGoButton' type='submit' value='rename' onclick='titleFormGo(); return false;' />";
+ titleElement.innerHTML = "Template: " + escapeHTML(templateDoc.getAttribute('displayname')) + " <input id='titleFormGoButton' type='submit' value='rename' onclick='titleFormGo(); return false;' />";
obj0Form.action = appPath + "/account/" + authedUsername + "/template/" + templateID + "/geometry/data/0";
obj0Form.onsubmit = null;
@@ -84,13 +84,13 @@
function titleFormGo(){
var goButton = document.getElementById("titleFormGoButton");
if(goButton.value == "rename"){
- titleElement.innerHTML = '<input type="text" id="titleInput" style="font-size: 1.5em;" value="' + escape(templateDoc.getAttribute('displayname')) + '" />';
+ titleElement.innerHTML = '<input type="text" id="titleInput" style="font-size: 1.5em;" value="' + escapeHTML(templateDoc.getAttribute('displayname')) + '" />';
titleElement.innerHTML += '<input value="save" type="submit" id="titleFormGoButton" />';
} else if(goButton.value == "save"){
var newTitle = titleForm.titleInput.value;
if(newTitle != null && trim(newTitle).length != 0){
goButton.enabled = false;
- templateDoc.setAttribute('displayname', escape(trim(newTitle)));
+ templateDoc.setAttribute('displayname', escapeHTML(trim(newTitle)));
updateTemplate(templateDoc, handleTemplateDocument);
} else {
handleTemplateDocument(templateDoc);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-08-10 00:43:17
|
Revision: 242
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=242&view=rev
Author: trevorolio
Date: 2007-08-09 16:56:22 -0700 (Thu, 09 Aug 2007)
Log Message:
-----------
Added a way to get an auth document based on an auth cookie.
Rearranged the build.xml so that the shared files are in a named fileset.
Modified Paths:
--------------
spaces/trunk/build.xml
spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
Modified: spaces/trunk/build.xml
===================================================================
--- spaces/trunk/build.xml 2007-08-09 12:45:17 UTC (rev 241)
+++ spaces/trunk/build.xml 2007-08-09 23:56:22 UTC (rev 242)
@@ -38,7 +38,24 @@
<include name="plugin.jar" />
</fileset>
</path>
-
+
+ <!-- these are files which will end up in ogoglio-shared.jar in Tomcat's shared lib, and not in ogoglio.war -->
+ <fileset id="sharedFiles" dir="${dest}">
+ <include name="com/ogoglio/util/**/*" />
+ <include name="com/ogoglio/media/**/*" />
+ <include name="com/ogoglio/site/AbstractResourceServlet*" />
+ <include name="com/ogoglio/site/AuthServlet*" />
+ <include name="com/ogoglio/site/SiteResource*" />
+ <include name="com/ogoglio/site/DescendingSiteResource*" />
+ <include name="com/ogoglio/site/AuthenticatedSiteResource*" />
+ <include name="com/ogoglio/site/SiteInfo*" />
+ <include name="com/ogoglio/persist/HibernateTask*" />
+ <include name="com/ogoglio/persist/PersistException*" />
+ <include name="com/ogoglio/client/**/*" />
+ <include name="com/ogoglio/xml/**/*" />
+ <include name="nanoxml/*" />
+ </fileset>
+
<target name="compile">
<javac source="1.4" target="1.4" srcdir="${source}" destdir="${dest}" debug="${debug.on}">
<classpath refid="classpath" />
@@ -52,17 +69,7 @@
<target name="sharedJar" depends="compile">
<jar destfile="ogoglio-shared.jar">
- <fileset dir="${dest}">
- <include name="com/ogoglio/util/**/*" />
- <include name="com/ogoglio/media/**/*" />
- <include name="com/ogoglio/site/AbstractResourceServlet*" />
- <include name="com/ogoglio/site/SiteResource*" />
- <include name="com/ogoglio/site/DescendingSiteResource*" />
- <include name="com/ogoglio/site/SiteInfo*" />
- <include name="com/ogoglio/persist/HibernateTask*" />
- <include name="com/ogoglio/persist/PersistException*" />
- <include name="nanoxml/*" />
- </fileset>
+ <fileset refid="sharedFiles" />
</jar>
</target>
Modified: spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-08-09 12:45:17 UTC (rev 241)
+++ spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-08-09 23:56:22 UTC (rev 242)
@@ -97,6 +97,14 @@
return new AccountDocument(response);
}
+ public AuthDocument getAuthDocumentByAuthCookie(String authCookie) throws IOException {
+ XMLElement response = wire.fetchAuthenticatedXML(descriptor.getMeAuthURI(), authCookie);
+ if (response == null) {
+ return null;
+ }
+ return new AuthDocument(response);
+ }
+
public DoorDocument getDoorDocument(long spaceID, long doorID) throws IOException {
return new DoorDocument(wire.fetchAuthenticatedXML(descriptor.getDoorURI(spaceID, doorID), authenticator.getAuthCookie()));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2007-08-16 17:04:44
|
Revision: 243
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=243&view=rev
Author: iansmith
Date: 2007-08-16 10:04:44 -0700 (Thu, 16 Aug 2007)
Log Message:
-----------
Fixes to enhance chances of automation.
1) Fixed database mapping problem for MySql 5 that was causing timestamp problems. We now use a long in the DB.
2) Fixed a bug in MessageProxy that kept the heartbeat thread going after the service was supposed to shutdown. Now we shutdown cleanly. Added a bunch of debugging support for this so we get better error messages as we are going down and there are problems.
3) Incorporated changes in the build.xml and began support for ant-oriented automated testing.
Modified Paths:
--------------
spaces/trunk/build.xml
spaces/trunk/docs/properties-example.txt
spaces/trunk/src/com/ogoglio/client/ClientTests.java
spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
spaces/trunk/src/com/ogoglio/client/WebAPIClientWire.java
spaces/trunk/src/com/ogoglio/client/WebAPITests.java
spaces/trunk/src/com/ogoglio/message/NetworkChannelServer.java
spaces/trunk/src/com/ogoglio/message/TCPChannel.java
spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java
spaces/trunk/src/com/ogoglio/persist/AccountRecord.java
spaces/trunk/src/com/ogoglio/persist/HibernateBase.java
spaces/trunk/src/com/ogoglio/persist/Persist.hbm.xml
spaces/trunk/src/com/ogoglio/persist/SpacePersistTasks.java
spaces/trunk/src/com/ogoglio/sim/site/SimServlet.java
spaces/trunk/src/com/ogoglio/site/AccountServlet.java
spaces/trunk/src/com/ogoglio/site/AuthServlet.java
spaces/trunk/src/com/ogoglio/site/MessageProxy.java
spaces/trunk/src/com/ogoglio/site/SpaceServlet.java
spaces/trunk/src/com/ogoglio/util/PrepareDatabase.java
spaces/trunk/src/com/ogoglio/xml/AccountDocument.java
spaces/trunk/src/com/ogoglio/xml/XMLTests.java
Modified: spaces/trunk/build.xml
===================================================================
--- spaces/trunk/build.xml 2007-08-09 23:56:22 UTC (rev 242)
+++ spaces/trunk/build.xml 2007-08-16 17:04:44 UTC (rev 243)
@@ -2,10 +2,22 @@
<project default="war" basedir=".">
<property name="source" value="src" />
<property name="dest" value="war/WEB-INF/classes" />
- <property name="tomcatHome" value="../../tomcat/" />
<property name="webLibDir" value="./war/WEB-INF/lib/" />
<property name="warName" value="ogoglio.war" />
+
+ <echo message="reading properties from ${user.home}/.ogoglio-properties"/>
+ <loadproperties srcFile="${user.home}/.ogoglio-properties">
+ <filterchain>
+ <linecontains>
+ <contains value="ant."/>
+ </linecontains>
+ </filterchain>
+ </loadproperties>
+
+
+ <echo message="tomcat 5.5 dir found to be ${ant.tomcatDir}"/>
+
<target name="clean">
<delete>
<fileset dir="${dest}" includes="**/*" />
@@ -142,6 +154,16 @@
<bottom><![CDATA[<i>Copyright © 2007 Transmutable. All Rights Reserved.</i>]]></bottom>
</javadoc>
</target>
-
+
+ <target name="insureNoServer">
+ <exec executable="${ant.tomcatDir}/bin/shutdown.sh" failonerror="false"
+ errorProperty="ignored" outputProperty="ignoredalso"/>
+ </target>
+
+ <target name="test" depends="war,insureNoServer">
+ <exec executable="${ant.tomcatDir}/bin/startup.sh" failonerror="true"/>
+ <sleep seconds="5"/>
+ <exec executable="${ant.tomcatDir}/bin/shutdown.sh" failonerror="true"/>
+ </target>
</project>
Modified: spaces/trunk/docs/properties-example.txt
===================================================================
--- spaces/trunk/docs/properties-example.txt 2007-08-09 23:56:22 UTC (rev 242)
+++ spaces/trunk/docs/properties-example.txt 2007-08-16 17:04:44 UTC (rev 243)
@@ -8,7 +8,7 @@
# TOMCAT
#
# pointer to your tomcat 5.5 install
-tomcat_dir = /usr/share/tomcat5.5
+ant.tomcatDir = /usr/share/tomcat5.5
#
# LOCALHOST
Modified: spaces/trunk/src/com/ogoglio/client/ClientTests.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-08-09 23:56:22 UTC (rev 242)
+++ spaces/trunk/src/com/ogoglio/client/ClientTests.java 2007-08-16 17:04:44 UTC (rev 243)
@@ -135,9 +135,10 @@
assertEquals(AccountRecord.ACCOUNT_LEVEL_ADMIN, accountDoc.getAccountLevel());
accountDoc.setFrozenUntil(new Date(1000));
accountDoc.setAccountLevel(AccountRecord.ACCOUNT_LEVEL_BASIC);
- adminWebClient.updateAccount(accountDoc);
- accountDoc = adminWebClient.getAccountDocument(username);
- assertTrue(accountDoc.getFrozenUntil() == null);
+ accountDoc=adminWebClient.updateAccount(accountDoc);
+ AccountDocument ac2= adminWebClient.getAccountDocument(username);
+ assertNull(accountDoc.getFrozenUntil());
+ assertNull(ac2.getFrozenUntil());
assertEquals(AccountRecord.ACCOUNT_LEVEL_BASIC, accountDoc.getAccountLevel());
} catch (Exception e) {
@@ -163,30 +164,31 @@
checkNoConnectionToSpaceWithoutAuth(spaceDocument.getSpaceID());
checkAuthDoc(auth1, auth2);
-
+
spaceDocument = checkSpaceSeaLevel(webClient1, spaceDocument);
-
+
checkSettings(spaceDocument.getSpaceID(), webClient1);
-
+
checkBody(webClient1, auth1);
checkSpaceMembership(spaceDocument.getSpaceID(), webClient1);
checkSpaceAuthWithMembership(auth2, webClient2, webClient1, spaceDocument);
-
+
TemplateDocument newTemplateDoc = checkTemplateScriptAPI(webClient1);
ThingDocument[] thingDocs = checkTemplateGeomMaterialsAndPossessions(webClient1, newTemplateDoc, spaceDocument);
-
+
+
//IES CHECK: after messing around above, verify we are are ok
thingDocs = webClient1.getThingDocuments(spaceDocument.getSpaceID());
assertEquals(1, thingDocs.length);
checkPageManipulation(webClient1, thingDocs[0], spaceDocument);
-
+
//figure out the last template added
TemplateDocument[] templateDocs = webClient1.getTemplateDocuments(USERNAME1);
long lastTemplateID = templateDocs[templateDocs.length - 1].getTemplateID();
-
+
checkDoors(webClient1, spaceDocument, lastTemplateID);
spaceClient1 = checkConnectedUsersToSpace(auth1, webClient1, spaceDocument);
@@ -199,7 +201,7 @@
guestSpaceClient1 = checkGuestCookieOperation(spaceDocument.getSpaceID(), webClient1, AuthServlet.GUEST_COOKIE_PREFIX + "Test_Suite_Guest");
checkDeletingSpaceDestroysThings(spaceDocument.getSpaceID(), webClient1, USERNAME1);
-
+
} catch (IOException e) {
e.printStackTrace();
fail();
@@ -282,10 +284,13 @@
private void checkSettings(long spaceID, WebAPIClient webClient1) throws IOException {
String key1 = "ogoglio.key.1";
String value1 = "This is a very fine value which is < 1";
- assertNull(webClient1.getSpaceSetting(spaceID, key1));
+ Object v = webClient1.getSpaceSetting(spaceID, key1);
+
+ assertNull(v);
+
webClient1.putSpaceSetting(spaceID, key1, value1);
assertEquals(value1, webClient1.getSpaceSetting(spaceID, key1));
-
+
String key2 = "ogoglio.key.2";
String value2 = "This is a very fine value & it's value is > 2";
assertNull(webClient1.getSpaceSetting(spaceID, key2));
@@ -297,6 +302,7 @@
assertNull(webClient1.getSpaceSetting(spaceID, key1));
webClient1.removeSpaceSetting(spaceID, key2);
assertNull(webClient1.getSpaceSetting(spaceID, key2));
+
}
private void checkBody(WebAPIClient webClient1, WebAPIAuthenticator authenticator) throws IOException {
Modified: spaces/trunk/src/com/ogoglio/client/WebAPIClient.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-08-09 23:56:22 UTC (rev 242)
+++ spaces/trunk/src/com/ogoglio/client/WebAPIClient.java 2007-08-16 17:04:44 UTC (rev 243)
@@ -31,6 +31,7 @@
import nanoxml.XMLElement;
+import com.ogoglio.persist.AccountRecord;
import com.ogoglio.site.AuthServlet;
import com.ogoglio.site.SpaceServlet;
import com.ogoglio.util.ArgumentUtils;
@@ -66,7 +67,7 @@
}
public AccountDocument createAccount(String username, String accountLevel, String firstName, String lastName, String homepage, String email, String password) throws IOException {
- AccountDocument newAccountDoc = new AccountDocument(username, accountLevel, firstName, lastName, homepage, password, email, null, null, null, null, -1);
+ AccountDocument newAccountDoc = new AccountDocument(username, accountLevel, firstName, lastName, homepage, password, email, null, AccountRecord.NO_TIME_VALUE, null, AccountRecord.NO_TIME_VALUE, -1);
XMLElement result = wire.sendAuthenticatedXML(descriptor.getAccountURI(), newAccountDoc.toString(), "POST", authenticator.getAuthCookie());
return new AccountDocument(result);
}
Modified: spaces/trunk/src/com/ogoglio/client/WebAPIClientWire.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPIClientWire.java 2007-08-09 23:56:22 UTC (rev 242)
+++ spaces/trunk/src/com/ogoglio/client/WebAPIClientWire.java 2007-08-16 17:04:44 UTC (rev 243)
@@ -18,8 +18,9 @@
public class WebAPIClientWire {
- private boolean printedCacheComplaint = false;
-
+ private boolean printedCacheComplaint = false;
+ private static final String BAD_SUN_VERSION = "1.6;";
+
public InputStream performPUT(URI uri, InputStream input, String type, int length, String authCookie) throws IOException {
HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
connection.setRequestMethod("PUT");
@@ -140,7 +141,7 @@
public DecoratedInputStream performGET(URI uri, String authCookie, boolean requestCompression) throws IOException {
String version = System.getProperty("java.version");
- if ((version == null) || version.startsWith("1.6")) {
+ if ((version == null) || version.startsWith(BAD_SUN_VERSION)) {
//THIS IS TO WORK AROUND SUN'S ABSOLUTELY BROKEN APPLET CACHE IN JRE 1.6u1 & 2
String uriString = uri.toASCIIString();
try {
@@ -211,7 +212,7 @@
public DecoratedInputStream performGET(URI uri, String authCookie) throws IOException {
String version = System.getProperty("java.version");
- if ((version == null) || version.startsWith("1.6")) {
+ if ((version == null) || version.startsWith(BAD_SUN_VERSION)) {
//THIS IS TO WORK AROUND SUN'S ABSOLUTELY BROKEN APPLET CACHE IN JRE 1.6u1
String uriString = uri.toASCIIString();
try {
Modified: spaces/trunk/src/com/ogoglio/client/WebAPITests.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPITests.java 2007-08-09 23:56:22 UTC (rev 242)
+++ spaces/trunk/src/com/ogoglio/client/WebAPITests.java 2007-08-16 17:04:44 UTC (rev 243)
@@ -42,7 +42,7 @@
notAuthedAuthDoc = new AuthDocument("Ian", false);
authedAuthDoc = new AuthDocument("Ian", true);
- accountDoc = new AccountDocument(authedAuthDoc.getUsername(), AccountRecord.ACCOUNT_LEVEL_ADVANCED, null, null, null, null, null, null, null, null, null, -1);
+ accountDoc = new AccountDocument(authedAuthDoc.getUsername(), AccountRecord.ACCOUNT_LEVEL_ADVANCED, null, null, null, null, null, null, AccountRecord.NO_TIME_VALUE, null, AccountRecord.NO_TIME_VALUE, -1);
} catch (URISyntaxException e) {
fail("Bad URIL: " + e);
}
Modified: spaces/trunk/src/com/ogoglio/message/NetworkChannelServer.java
===================================================================
--- spaces/trunk/src/com/ogoglio/message/NetworkChannelServer.java 2007-08-09 23:56:22 UTC (rev 242)
+++ spaces/trunk/src/com/ogoglio/message/NetworkChannelServer.java 2007-08-16 17:04:44 UTC (rev 243)
@@ -122,6 +122,7 @@
try {
serverSocket.close();
} catch (Exception e) {
+ System.out.println("Trying to close server socket of NCServer:"+e.getMessage());
// don't care
}
TCPChannel[] channels = getChannels();
Modified: spaces/trunk/src/com/ogoglio/message/TCPChannel.java
===================================================================
--- spaces/trunk/src/com/ogoglio/message/TCPChannel.java 2007-08-09 23:56:22 UTC (rev 242)
+++ spaces/trunk/src/com/ogoglio/message/TCPChannel.java 2007-08-16 17:04:44 UTC (rev 243)
@@ -86,10 +86,12 @@
try {
readerThread.cleanup();
} catch (Exception e) {
+ System.out.println("TCPChannel: Trying to cleanup to readerThread:"+(e.getClass().getName())+":"+e.getMessage());
}
try {
senderQueue.cleanup();
} catch (Exception e) {
+ System.out.println("TCPChannel: Trying to cleanup to senderQueue:"+(e.getClass().getName())+":"+e.getMessage());
}
listener.channelClosed(this);
}
Modified: spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java
===================================================================
--- spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java 2007-08-09 23:56:22 UTC (rev 242)
+++ spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java 2007-08-16 17:04:44 UTC (rev 243)
@@ -21,168 +21,193 @@
public class AccountPersistTasks {
- public static final String ACCOUNT_BY_USERNAME = "com.ogoglio.persist.accountByUsername";
- public static final String ACCOUNT_BY_EMAIL = "com.ogoglio.persist.accountByEmail";
+ public static final String ACCOUNT_BY_USERNAME = "com.ogoglio.persist.accountByUsername";
+ public static final String ACCOUNT_BY_EMAIL = "com.ogoglio.persist.accountByEmail";
- public static final String ACCOUNT_BY_COOKIE = "com.ogoglio.persist.accountByCookie";
+ public static final String ACCOUNT_BY_COOKIE = "com.ogoglio.persist.accountByCookie";
- public static boolean update(final AccountRecord record, final AccountDocument document, SessionFactory sessionFactory) throws PersistException {
- HibernateTask task = new HibernateTask() {
- public Object run(Session hibernateSession) {
- boolean dirty = false;
- if (document.getAccountLevel() != null && !equals(record.getAccountlevel(), document.getAccountLevel())) {
- dirty = true;
- record.setAccountlevel(document.getAccountLevel());
- }
-
- if (document.getHomepage() != null && !equals(record.getHomepage(), document.getHomepage())) {
- dirty = true;
- record.setHomepage(document.getHomepage());
- }
+ public static boolean update(final AccountRecord record,
+ final AccountDocument document, SessionFactory sessionFactory)
+ throws PersistException {
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ boolean dirty = false;
+ if (document.getAccountLevel() != null
+ && !equals(record.getAccountlevel(), document
+ .getAccountLevel())) {
+ dirty = true;
+ record.setAccountlevel(document.getAccountLevel());
+ }
- if (document.getFirstName() != null && !equals(record.getFirstName(), document.getFirstName())) {
- dirty = true;
- record.setFirstName(document.getFirstName());
- }
+ if (document.getHomepage() != null
+ && !equals(record.getHomepage(), document.getHomepage())) {
+ dirty = true;
+ record.setHomepage(document.getHomepage());
+ }
- if (document.getLastName() != null && !equals(record.getLastName(), document.getLastName())) {
- dirty = true;
- record.setLastName(document.getLastName());
- }
+ if (document.getFirstName() != null
+ && !equals(record.getFirstName(), document
+ .getFirstName())) {
+ dirty = true;
+ record.setFirstName(document.getFirstName());
+ }
- if (document.getPassword() != null && !equals(record.getPassword(), document.getPassword())) {
- if (AccountRecord.cleanPassword(document.getPassword()) != null) {
- dirty = true;
- record.setPassword(document.getPassword());
- }
- }
+ if (document.getLastName() != null
+ && !equals(record.getLastName(), document.getLastName())) {
+ dirty = true;
+ record.setLastName(document.getLastName());
+ }
- if(document.getDefaultBodyID() != -1) {
- Query bodyQuery = hibernateSession.getNamedQuery(BodyPersistTasks.BODY_BY_ID);
- bodyQuery.setLong("bodyID", document.getDefaultBodyID());
- BodyRecord bodyRec = (BodyRecord)bodyQuery.uniqueResult();
- if(bodyRec != null && bodyRec.getOwnerUsername().equals(record.getUsername())) {
- dirty = true;
- record.setDefaultBodyID(document.getDefaultBodyID());
- }
- }
+ if (document.getPassword() != null
+ && !equals(record.getPassword(), document.getPassword())) {
+ if (AccountRecord.cleanPassword(document.getPassword()) != null) {
+ dirty = true;
+ record.setPassword(document.getPassword());
+ }
+ }
- if(document.getFrozenUntil() != null && !equals(record.getFrozenUntil(), document.getFrozenUntil())) {
- dirty = true;
- if(document.getFrozenUntil().getTime() < System.currentTimeMillis()) {
- record.setFrozenUntil(null);
- } else {
- record.setFrozenUntil(document.getFrozenUntil());
- }
- }
+ if (document.getDefaultBodyID() != -1) {
+ Query bodyQuery = hibernateSession
+ .getNamedQuery(BodyPersistTasks.BODY_BY_ID);
+ bodyQuery.setLong("bodyID", document.getDefaultBodyID());
+ BodyRecord bodyRec = (BodyRecord) bodyQuery.uniqueResult();
+ if (bodyRec != null
+ && bodyRec.getOwnerUsername().equals(
+ record.getUsername())) {
+ dirty = true;
+ record.setDefaultBodyID(document.getDefaultBodyID());
+ }
+ }
- if (dirty) {
- hibernateSession.update(record);
- return Boolean.TRUE;
- }
- return Boolean.FALSE;
- }
- };
- task.setSessionFactory(sessionFactory);
- return "true".equals(task.execute().toString());
- }
+
+ if (document.getFrozenUntil() != null) {
+ if (record.getFrozenUntil()!=document.getFrozenUntil().getTime()) {
+ dirty = true;
+ if (document.getFrozenUntil().getTime() < System.currentTimeMillis()) {
+ record.setNotFrozen();
+ } else {
+ record.setFrozenUntil(document.getFrozenUntil().getTime());
+ }
+ }
+ }
+ if (dirty) {
+ hibernateSession.update(record);
+ return Boolean.TRUE;
+ }
+ return Boolean.FALSE;
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ return "true".equals(task.execute().toString());
+ }
- public static void update(final AccountRecord record, SessionFactory sessionFactory) throws PersistException {
- HibernateTask task = new HibernateTask() {
- public Object run(Session hibernateSession) {
- hibernateSession.update(record);
- return null;
- }
- };
- task.setSessionFactory(sessionFactory);
- task.execute();
- }
+ public static void update(final AccountRecord record,
+ SessionFactory sessionFactory) throws PersistException {
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ hibernateSession.update(record);
+ return null;
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ task.execute();
+ }
- public static AccountRecord findAccountByCookie(final String cookie, SessionFactory sessionFactory) throws PersistException {
- HibernateTask task = new HibernateTask() {
- public Object run(Session hibernateSession) {
- Query query = hibernateSession.getNamedQuery(ACCOUNT_BY_COOKIE);
- query.setParameter("cookie", cookie);
- AccountRecord rec=(AccountRecord)query.uniqueResult();
- return rec;
- }
- };
- task.setSessionFactory(sessionFactory);
- return (AccountRecord) task.execute();
- }
+ public static AccountRecord findAccountByCookie(final String cookie,
+ SessionFactory sessionFactory) throws PersistException {
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ Query query = hibernateSession.getNamedQuery(ACCOUNT_BY_COOKIE);
+ query.setParameter("cookie", cookie);
+ AccountRecord rec = (AccountRecord) query.uniqueResult();
+ return rec;
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ return (AccountRecord) task.execute();
+ }
- public static AccountRecord[] findAllAccounts(SessionFactory sessionFactory) throws PersistException {
- HibernateTask task = new HibernateTask() {
- public Object run(Session hibernateSession) {
- Query query = hibernateSession.getNamedQuery("com.ogoglio.persist.accounts");
- return query.list().toArray(new AccountRecord[0]);
- }
- };
- task.setSessionFactory(sessionFactory);
- return (AccountRecord[]) task.execute();
- }
+ public static AccountRecord[] findAllAccounts(SessionFactory sessionFactory)
+ throws PersistException {
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ Query query = hibernateSession
+ .getNamedQuery("com.ogoglio.persist.accounts");
+ return query.list().toArray(new AccountRecord[0]);
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ return (AccountRecord[]) task.execute();
+ }
- public static AccountRecord createAccount(final String username, final String accountlevel, final String email, SessionFactory sessionFactory) throws PersistException {
- HibernateTask task = new HibernateTask() {
- public Object run(Session hibernateSession) {
- final String cleanedUsername = AccountRecord.cleanUsername(username);
- Query query = hibernateSession.getNamedQuery(ACCOUNT_BY_USERNAME);
- query.setParameter("username", cleanedUsername);
-
- AccountRecord record = (AccountRecord)query.uniqueResult();
- if(record != null) {
- return null; // XXX really weird semantic: try to create something and get null because it's there?
- }
-
- //IES:debug because unique constraint on this field!
- final String cleanedEmail = AccountRecord.cleanEmail(email);
- query = hibernateSession.getNamedQuery(ACCOUNT_BY_EMAIL);
- query.setParameter("email", email);
- record = (AccountRecord)query.uniqueResult();
- if (record!=null) {
- System.err.println("Whoa! Bad email value!"+email);
- }
-
-
- record = new AccountRecord(username, accountlevel, email);
- hibernateSession.save(record);
- BodyRecord bodyRec = new BodyRecord("Body", record.getUsername());
- hibernateSession.save(bodyRec);
-
- record.setDefaultBodyID(bodyRec.getBodyID());
- hibernateSession.update(record);
- return record;
- }
- };
- task.setSessionFactory(sessionFactory);
- return (AccountRecord) task.execute();
- }
+ public static AccountRecord createAccount(final String username,
+ final String accountlevel, final String email,
+ SessionFactory sessionFactory) throws PersistException {
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ final String cleanedUsername = AccountRecord
+ .cleanUsername(username);
+ Query query = hibernateSession
+ .getNamedQuery(ACCOUNT_BY_USERNAME);
+ query.setParameter("username", cleanedUsername);
- public static AccountRecord findAccountByUsername(String username, SessionFactory sessionFactory) throws PersistException {
- final String cleanedUsername = AccountRecord.cleanUsername(username);
- if (cleanedUsername == null) {
- return null;
- }
- HibernateTask task = new HibernateTask() {
- public Object run(Session hibernateSession) {
- Query query = hibernateSession.getNamedQuery(ACCOUNT_BY_USERNAME);
- query.setParameter("username", cleanedUsername);
- return query.uniqueResult();
- }
- };
- task.setSessionFactory(sessionFactory);
- return (AccountRecord) task.execute();
- }
+ AccountRecord record = (AccountRecord) query.uniqueResult();
+ if (record != null) {
+ return null; // XXX really weird semantic: try to create something and get null because it's there?
+ }
- public static void delete(final AccountRecord accRec,SessionFactory sessionFactory) throws PersistException {
- HibernateTask task = new HibernateTask() {
- public Object run(Session hibernateSession) {
- hibernateSession.delete(accRec);
- return null;
- }
- };
- task.setSessionFactory(sessionFactory);
- task.execute();
-
- }
+ //IES:debug because unique constraint on this field!
+ final String cleanedEmail = AccountRecord.cleanEmail(email);
+ query = hibernateSession.getNamedQuery(ACCOUNT_BY_EMAIL);
+ query.setParameter("email", email);
+ record = (AccountRecord) query.uniqueResult();
+ if (record != null) {
+ System.err.println("Whoa! Bad email value!" + email);
+ }
+
+ record = new AccountRecord(username, accountlevel, email);
+ hibernateSession.save(record);
+ BodyRecord bodyRec = new BodyRecord("Body", record
+ .getUsername());
+ hibernateSession.save(bodyRec);
+
+ record.setDefaultBodyID(bodyRec.getBodyID());
+ hibernateSession.update(record);
+ return record;
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ return (AccountRecord) task.execute();
+ }
+
+ public static AccountRecord findAccountByUsername(String username,
+ SessionFactory sessionFactory) throws PersistException {
+ final String cleanedUsername = AccountRecord.cleanUsername(username);
+ if (cleanedUsername == null) {
+ return null;
+ }
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ Query query = hibernateSession
+ .getNamedQuery(ACCOUNT_BY_USERNAME);
+ query.setParameter("username", cleanedUsername);
+ return query.uniqueResult();
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ return (AccountRecord) task.execute();
+ }
+
+ public static void delete(final AccountRecord accRec,
+ SessionFactory sessionFactory) throws PersistException {
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ hibernateSession.delete(accRec);
+ return null;
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ task.execute();
+
+ }
}
Modified: spaces/trunk/src/com/ogoglio/persist/AccountRecord.java
===================================================================
--- spaces/trunk/src/com/ogoglio/persist/AccountRecord.java 2007-08-09 23:56:22 UTC (rev 242)
+++ spaces/trunk/src/com/ogoglio/persist/AccountRecord.java 2007-08-16 17:04:44 UTC (rev 243)
@@ -17,6 +17,8 @@
public class AccountRecord {
+ public static final long NO_TIME_VALUE=-97;
+
public static final String ACCOUNT_LEVEL_BASIC = "basic";
public static final String ACCOUNT_LEVEL_ADVANCED = "advanced";
@@ -43,11 +45,11 @@
private String secret = null;
- private Date creationDate = null;
+ private long creationDate = NO_TIME_VALUE;
private String cookie = null;
- private Date frozenUntil = null;
+ private long frozenUntil = NO_TIME_VALUE;
private long defaultBodyId = 1;
@@ -185,11 +187,11 @@
this.cookie = cookie;
}
- public Date getCreationDate() {
- return creationDate;
+ public long getCreationDate() {
+ return creationDate;
}
- public void setCreationDate(Date creationDate) {
+ public void setCreationDate(long creationDate) {
this.creationDate = creationDate;
}
@@ -209,16 +211,16 @@
this.firstName = firstName;
}
- public Date getFrozenUntil() {
+ public long getFrozenUntil() {
return frozenUntil;
}
- public void setFrozenUntil(Date frozenUntil) {
+ public void setFrozenUntil(long frozenUntil) {
this.frozenUntil = frozenUntil;
}
public boolean isFrozen() {
- return frozenUntil != null && System.currentTimeMillis() < frozenUntil.getTime();
+ return frozenUntil != NO_TIME_VALUE && System.currentTimeMillis() < frozenUntil;
}
public String getLastName() {
@@ -260,4 +262,8 @@
public void setDefaultBodyID(long defaultBodyID) {
this.defaultBodyId = defaultBodyID;
}
+
+ public void setNotFrozen() {
+ this.frozenUntil=NO_TIME_VALUE;
+ }
}
Modified: spaces/trunk/src/com/ogoglio/persist/HibernateBase.java
===================================================================
--- spaces/trunk/src/...
[truncated message content] |
|
From: <ian...@us...> - 2007-08-16 19:33:37
|
Revision: 244
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=244&view=rev
Author: iansmith
Date: 2007-08-16 12:33:40 -0700 (Thu, 16 Aug 2007)
Log Message:
-----------
More cleanup to insure that the ogoglio server can be shutdown properly via a program.
Ant changes to allow "ant test" to work properly from the command line. Warning: If you are using eclipse, changes made to source code via eclipse don't seem to be automatically recompiled via the "compile" ant task. It always works to do "ant clean test".
For reasons I don't understand, rmock's expectThatExceptionThrown doesn't work when run via ant. There is some seriously weird classpath stuff going on so for now I just converted the tests that used that function to work the more traditional way. No test logic was lost.
Modified Paths:
--------------
spaces/trunk/build.xml
spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java
spaces/trunk/src/com/ogoglio/client/WebAPIClientWire.java
spaces/trunk/src/com/ogoglio/client/WebAPITests.java
spaces/trunk/src/com/ogoglio/message/SenderQueue.java
spaces/trunk/src/com/ogoglio/message/TCPChannel.java
spaces/trunk/src/com/ogoglio/message/TCPMessageReader.java
spaces/trunk/src/com/ogoglio/templatesync/OgoglioSpecBase.java
spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java
Modified: spaces/trunk/build.xml
===================================================================
--- spaces/trunk/build.xml 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/build.xml 2007-08-16 19:33:40 UTC (rev 244)
@@ -15,8 +15,11 @@
</filterchain>
</loadproperties>
-
<echo message="tomcat 5.5 dir found to be ${ant.tomcatDir}"/>
+
+ <target name="junitOk">
+ <available property="junitPresent" classname="junit.framework.TestCase" />
+ </target>
<target name="clean">
<delete>
@@ -43,13 +46,14 @@
<fileset dir="shared-lib">
<include name="**/*.jar" />
</fileset>
- <fileset dir="${tomcatHome}/common/lib/">
+ <fileset dir="${ant.tomcatDir}/common/lib/">
<include name="**/*.jar" />
</fileset>
<fileset dir="${java.home}/lib/">
<include name="plugin.jar" />
</fileset>
- </path>
+ <filelist dir="war/WEB-INF" files="classes"/>
+ </path>
<!-- these are files which will end up in ogoglio-shared.jar in Tomcat's shared lib, and not in ogoglio.war -->
<fileset id="sharedFiles" dir="${dest}">
@@ -160,10 +164,20 @@
errorProperty="ignored" outputProperty="ignoredalso"/>
</target>
- <target name="test" depends="war,insureNoServer">
+ <target name="test" depends="war,insureNoServer,junitOk">
+ <fail message="Couldn't find JUnit classes in classpath! You need to put shared-lib/junit-3.8.1.jar in ~/.ant/lib so ant can find it!" unless="junitPresent"/>
+ <echo message="starting ogoglio server..."/>
<exec executable="${ant.tomcatDir}/bin/startup.sh" failonerror="true"/>
<sleep seconds="5"/>
+
+ <junit>
+ <classpath refid="classpath"/>
+ <formatter type="brief" usefile="false" />
+ <test name="com.ogoglio.OgoglioTestSuite" />
+ </junit>
+
<exec executable="${ant.tomcatDir}/bin/shutdown.sh" failonerror="true"/>
</target>
+
</project>
Modified: spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java
===================================================================
--- spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -29,7 +29,7 @@
TestSuite suite = new TestSuite();
suite.addTestSuite(ObjTest.class);
suite.addTestSuite(XMLTests.class);
- //suite.addTestSuite(PersistTests.class);
+ suite.addTestSuite(PersistTests.class);
suite.addTestSuite(WebAPITests.class);
suite.addTestSuite(ClientTests.class);
suite.addTestSuite(ScriptTests.class);
Modified: spaces/trunk/src/com/ogoglio/client/WebAPIClientWire.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPIClientWire.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/client/WebAPIClientWire.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -294,18 +294,20 @@
// XXX seems to be required
String headerValue = null;
Object makeLinuxHappy = (connection.getRequestProperties().get(headerName));
- if (makeLinuxHappy instanceof String) {
- headerValue = (String) makeLinuxHappy;
- } else if (makeLinuxHappy instanceof List) {
- headerValue = (String) ((List) makeLinuxHappy).get(0);
- } else {
- // we don't understand this type at all
- System.err.println("Unable to understand the type returned by Linux workaround in WebAPIClient!");
+ if (makeLinuxHappy!=null) {
+ if (makeLinuxHappy instanceof String) {
+ headerValue = (String) makeLinuxHappy;
+ } else if (makeLinuxHappy instanceof List) {
+ headerValue = (String) ((List) makeLinuxHappy).get(0);
+ } else {
+ // we don't understand this type at all
+ System.err.println("Unable to understand the type returned by Linux workaround in WebAPIClient:"+makeLinuxHappy.getClass().getName());
+ return null;
+ }
+ }
+ if (makeLinuxHappy == null) {
return null;
}
- if (headerValue == null) {
- return null;
- }
return headerValue;
} catch (IOException e) {
return null;
Modified: spaces/trunk/src/com/ogoglio/client/WebAPITests.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPITests.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/client/WebAPITests.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -84,8 +84,9 @@
modify().multiplicity(expect.atMost(2));
modify().forward();
- expectThatExceptionThrown(is.instanceOf(AuthenticationFailedException.class));
-
+ //for reasons I don't understand this doesn't work when running via ant
+ //so we are going to not use it for now
+ //expectThatExceptionThrown(is.instanceOf(AuthenticationFailedException.class));
//###################################
startVerification();
@@ -94,9 +95,13 @@
assertEquals(GOOD_COOKIE, auth.getAuthCookie());
assertEquals(authedAuthDoc.getUsername(), auth.getUsername());
assertEquals(accountDoc, auth.getAccountDocument(true));
-
- mockAuthFactory.authenticate(mockWire, descriptor, BAD_COOKIE);
-
+
+ try {
+ auth = mockAuthFactory.authenticate(mockWire, descriptor, BAD_COOKIE);
+ fail("Should not be able to reach this point after bad authentication!");
+ } catch (AuthenticationFailedException e) {
+ assertThat(e, is.instanceOf(AuthenticationFailedException.class));
+ }
}
public void testWebAPIAuthenticatorViaUsernameAndPass() throws AuthenticationFailedException, URISyntaxException, IOException {
@@ -114,7 +119,9 @@
mockAuthFactory.authenticate(mockWire, descriptor, "Ian", "goodPW");
modify().forward();
- expectThatExceptionThrown(is.instanceOf(AuthenticationFailedException.class));
+ //for reasons I don't understand this doesn't work when running via ant
+ //so we are going to not use it for now
+ //expectThatExceptionThrown(is.instanceOf(AuthenticationFailedException.class));
//###################################
startVerification();
@@ -124,7 +131,12 @@
assertThat(auth.getAuthCookie(), is.eq(GOOD_COOKIE));
//try bad pw
- mockAuthFactory.authenticate(mockWire, descriptor, "Ian", "farts");
+ try {
+ mockAuthFactory.authenticate(mockWire, descriptor, "Ian", "farts");
+ fail("Should not be able to reach this point after bad pw!");
+ } catch (AuthenticationFailedException e) {
+ assertThat(e, is.instanceOf(AuthenticationFailedException.class));
+ }
}
}
Modified: spaces/trunk/src/com/ogoglio/message/SenderQueue.java
===================================================================
--- spaces/trunk/src/com/ogoglio/message/SenderQueue.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/message/SenderQueue.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -47,10 +47,17 @@
public void cleanup() {
cleaned = true;
try {
- clientSocket.close();
- socketOutput.close();
- messageQueue.close();
+ if (clientSocket!=null) {
+ clientSocket.close();
+ }
+ if (socketOutput!=null) {
+ socketOutput.close();
+ }
+ if (messageQueue!=null) {
+ messageQueue.close();
+ }
} catch (IOException e) {
+ System.out.println("IOException trying cleanup SenderQueue:"+e.getMessage());
}
}
Modified: spaces/trunk/src/com/ogoglio/message/TCPChannel.java
===================================================================
--- spaces/trunk/src/com/ogoglio/message/TCPChannel.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/message/TCPChannel.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -84,12 +84,16 @@
public void cleanup() {
cleaned = true;
try {
- readerThread.cleanup();
+ if (readerThread!=null) {
+ readerThread.cleanup();
+ }
} catch (Exception e) {
System.out.println("TCPChannel: Trying to cleanup to readerThread:"+(e.getClass().getName())+":"+e.getMessage());
}
try {
- senderQueue.cleanup();
+ if (senderQueue!=null) {
+ senderQueue.cleanup();
+ }
} catch (Exception e) {
System.out.println("TCPChannel: Trying to cleanup to senderQueue:"+(e.getClass().getName())+":"+e.getMessage());
}
Modified: spaces/trunk/src/com/ogoglio/message/TCPMessageReader.java
===================================================================
--- spaces/trunk/src/com/ogoglio/message/TCPMessageReader.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/message/TCPMessageReader.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -75,8 +75,11 @@
public void cleanup() {
cleaned = true;
try {
- socketInput.close();
+ if (socketInput!=null) {
+ socketInput.close();
+ }
} catch (IOException e) {
+ System.out.println("IOException caught trying to clean up TCPMessageReader:"+e.getMessage());
}
}
Modified: spaces/trunk/src/com/ogoglio/templatesync/OgoglioSpecBase.java
===================================================================
--- spaces/trunk/src/com/ogoglio/templatesync/OgoglioSpecBase.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/templatesync/OgoglioSpecBase.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -5,7 +5,7 @@
public class OgoglioSpecBase extends RMockTestCase {
public Object mock_ignoreEqualsAndToString(Class clazz) {
- return mock_ignoreEqualsAndToString(clazz,new Object[0], "mockOf:"+clazz.getName());
+ return mock_ignoreEqualsAndToString(clazz,new Object[0], "mockOf_"+clazz.toString().replace('.','_'));
}
public Object mock_ignoreEqualsAndToString(Class clazz, Object[] constructorParams, String name) {
Object result = mock(clazz,constructorParams,name);
Modified: spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java
===================================================================
--- spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -262,7 +262,6 @@
File template = ((File) serverTemplatesToAdd.get(i));
verifyDirContent(template);
long newID = createTemplate(template, client);
- System.out.println("ADDING:" + template.getName() + "," + newID);
serverTemplateNamesToIds.put(template.getName(), new Long(newID));
}
deleteTemplates(client, serverTemplatesToDelete);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-08-20 23:09:51
|
Revision: 248
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=248&view=rev
Author: trevorolio
Date: 2007-08-20 16:09:52 -0700 (Mon, 20 Aug 2007)
Log Message:
-----------
Added a fetal email toolset, which means we need mail and activation jars in ${TOMCAT_HOME}/common/lib/ and JNDI entries for mail sessions.
Modified Paths:
--------------
spaces/trunk/.classpath
spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java
spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java
spaces/trunk/src/com/ogoglio/persist/Persist.hbm.xml
spaces/trunk/src/com/ogoglio/persist/PersistTests.java
spaces/trunk/src/com/ogoglio/site/AccountServlet.java
spaces/trunk/src/com/ogoglio/util/ArgumentUtils.java
spaces/trunk/src/com/ogoglio/util/StreamUtils.java
Added Paths:
-----------
spaces/trunk/common-lib/
spaces/trunk/common-lib/activation.jar
spaces/trunk/common-lib/mail.jar
spaces/trunk/src/com/ogoglio/mail/
spaces/trunk/src/com/ogoglio/mail/MailClient.java
spaces/trunk/src/com/ogoglio/mail/MailFormatter.java
spaces/trunk/src/com/ogoglio/mail/MailSendException.java
spaces/trunk/src/com/ogoglio/mail/MailTests.java
spaces/trunk/src/com/ogoglio/mail/TestTemplate1.txt
spaces/trunk/src/com/ogoglio/persist/PendingEmailValidationRecord.java
Modified: spaces/trunk/.classpath
===================================================================
--- spaces/trunk/.classpath 2007-08-20 03:43:05 UTC (rev 247)
+++ spaces/trunk/.classpath 2007-08-20 23:09:52 UTC (rev 248)
@@ -30,5 +30,7 @@
<classpathentry kind="lib" path="shared-lib/commons-fileupload-1.1.1.jar"/>
<classpathentry kind="lib" path="shared-lib/commons-codec-1.3.jar"/>
<classpathentry kind="lib" path="shared-lib/antlr-2.7.5H3.jar"/>
+ <classpathentry kind="var" path="TOMCAT_HOME/common/lib/mail.jar"/>
+ <classpathentry kind="var" path="TOMCAT_HOME/common/lib/activation.jar"/>
<classpathentry kind="output" path="war/WEB-INF/classes"/>
</classpath>
Added: spaces/trunk/common-lib/activation.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/common-lib/activation.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: spaces/trunk/common-lib/mail.jar
===================================================================
(Binary files differ)
Property changes on: spaces/trunk/common-lib/mail.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java
===================================================================
--- spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java 2007-08-20 03:43:05 UTC (rev 247)
+++ spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java 2007-08-20 23:09:52 UTC (rev 248)
@@ -18,6 +18,7 @@
import com.ogoglio.client.ClientTests;
import com.ogoglio.client.WebAPITests;
+import com.ogoglio.mail.MailTests;
import com.ogoglio.persist.PersistTests;
import com.ogoglio.sim.script.ScriptTests;
import com.ogoglio.templatesync.TemplateSyncTestSuite;
@@ -34,6 +35,7 @@
suite.addTestSuite(ClientTests.class);
suite.addTestSuite(ScriptTests.class);
suite.addTest(TemplateSyncTestSuite.suite());
+ suite.addTestSuite(MailTests.class);
return suite;
}
Added: spaces/trunk/src/com/ogoglio/mail/MailClient.java
===================================================================
--- spaces/trunk/src/com/ogoglio/mail/MailClient.java (rev 0)
+++ spaces/trunk/src/com/ogoglio/mail/MailClient.java 2007-08-20 23:09:52 UTC (rev 248)
@@ -0,0 +1,92 @@
+package com.ogoglio.mail;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import com.ogoglio.util.ArgumentUtils;
+
+public class MailClient {
+
+ private boolean writeToDisk = false;
+
+ private File outputDir = null;
+
+ /**
+ * Sends all mail to individual files in outputDir
+ */
+ public MailClient(File outputDir) {
+ ArgumentUtils.assertReadableDir(outputDir, true);
+ this.outputDir = outputDir;
+ writeToDisk = true;
+ }
+
+ /**
+ * Sends all mail via JNDI:java:comp/env session at mail/Session
+ */
+ public MailClient() {
+ writeToDisk = false;
+ }
+
+ public void sendEmail(String to, String from, String subject, String body) throws MailSendException {
+ try {
+ if (writeToDisk) {
+ sendToDisk(to, from, subject, body);
+ } else {
+ sendViaContextSession(to, from, subject, body);
+ }
+ } catch (NamingException e) {
+ throw new MailSendException(e);
+ } catch (AddressException e) {
+ throw new MailSendException(e);
+ } catch (MessagingException e) {
+ throw new MailSendException(e);
+ } catch (IOException e) {
+ throw new MailSendException(e);
+ }
+ }
+
+ private void sendToDisk(String to, String from, String subject, String body) throws IOException {
+ FileOutputStream output = new FileOutputStream(new File(outputDir, "Mail-Message-" + System.currentTimeMillis()));
+ output.write(("to: " + to + "\n").getBytes());
+ output.write(("from: " + from + "\n").getBytes());
+ output.write(("subject: " + subject + "\n").getBytes());
+ output.write(("\n").getBytes());
+ output.write(body.getBytes());
+ output.flush();
+ output.close();
+ }
+
+ private void sendViaContextSession(String to, String from, String subject, String body) throws NamingException, AddressException, MessagingException {
+ Context initCtx = new InitialContext();
+ Context envCtx = (Context) initCtx.lookup("java:comp/env");
+ Session session = (Session) envCtx.lookup("mail/Session");
+
+ Message message = new MimeMessage(session);
+ message.setFrom(new InternetAddress(from));
+ InternetAddress toAddress[] = new InternetAddress[1];
+ toAddress[0] = new InternetAddress(to);
+ message.setRecipients(Message.RecipientType.TO, toAddress);
+ message.setSubject(subject);
+ message.setContent(body, "text/plain");
+ Transport.send(message);
+ }
+
+ /**
+ * @return null if this client is using the JNDI mail session instead of writing to disk
+ */
+ public File getOutputDir() {
+ return outputDir;
+ }
+}
Added: spaces/trunk/src/com/ogoglio/mail/MailFormatter.java
===================================================================
--- spaces/trunk/src/com/ogoglio/mail/MailFormatter.java (rev 0)
+++ spaces/trunk/src/com/ogoglio/mail/MailFormatter.java 2007-08-20 23:09:52 UTC (rev 248)
@@ -0,0 +1,29 @@
+package com.ogoglio.mail;
+
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import com.ogoglio.util.ArgumentUtils;
+
+public class MailFormatter {
+
+ public String format(Map map, String template) {
+ ArgumentUtils.assertNotNull(map);
+ ArgumentUtils.assertNotEmpty(template);
+ return stupidMerge(map, template);
+ }
+
+ private String stupidMerge(Map map, String template) {
+ String result = new String(template);
+ String[] keys = (String[])map.keySet().toArray(new String[0]);
+ for (int i = 0; i < keys.length; i++) {
+ String replacement = (String)map.get(keys[i]);
+ result = result.replaceAll(Pattern.quote(createVariableString((keys[i]))), replacement);
+ }
+ return result;
+ }
+
+ public String createVariableString(String variableName) {
+ return "${" + variableName + "}";
+ }
+}
Added: spaces/trunk/src/com/ogoglio/mail/MailSendException.java
===================================================================
--- spaces/trunk/src/com/ogoglio/mail/MailSendException.java (rev 0)
+++ spaces/trunk/src/com/ogoglio/mail/MailSendException.java 2007-08-20 23:09:52 UTC (rev 248)
@@ -0,0 +1,7 @@
+package com.ogoglio.mail;
+
+public class MailSendException extends Exception {
+ public MailSendException(Exception e) {
+ super(e);
+ }
+}
Added: spaces/trunk/src/com/ogoglio/mail/MailTests.java
===================================================================
--- spaces/trunk/src/com/ogoglio/mail/MailTests.java (rev 0)
+++ spaces/trunk/src/com/ogoglio/mail/MailTests.java 2007-08-20 23:09:52 UTC (rev 248)
@@ -0,0 +1,104 @@
+package com.ogoglio.mail;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+
+import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.util.StreamUtils;
+
+public class MailTests extends TestCase {
+
+ private static final String TEST_DIR_PATH = "mailTestFiles";
+
+ private static final String TEST_TEMPLATE_RESOURCE_PATH = "com/ogoglio/mail/";
+
+ private static final String TEST_TEMPLATE_1_NAME = "TestTemplate1.txt";
+
+ private File mailOutputDir = null;
+
+ private MailClient mailClient1 = null;
+
+ private MailFormatter mailFormatter1 = null;
+
+ private String testTemplate1 = null;
+
+ private HashMap testMap1 = null;
+
+ public void setUp() throws IOException {
+ mailOutputDir = new File(TEST_DIR_PATH);
+ if (mailOutputDir.exists()) {
+ delete(mailOutputDir);
+ }
+ assertTrue(mailOutputDir.mkdir());
+
+ mailClient1 = new MailClient(mailOutputDir);
+
+ mailFormatter1 = new MailFormatter();
+
+ testTemplate1 = StreamUtils.readResource(TEST_TEMPLATE_RESOURCE_PATH + TEST_TEMPLATE_1_NAME);
+ assertNotNull(testTemplate1);
+
+ testMap1 = new HashMap();
+ testMap1.put("username", "susan");
+ testMap1.put("url", "http://example.com/og/");
+ testMap1.put("moon.unit", "zappa");
+ testMap1.put("Kurt", "Vonnegut.");
+ }
+
+ private void delete(File dir) {
+ File[] children = dir.listFiles();
+ for (int i = 0; i < children.length; i++) {
+ assertTrue(children[i].delete());
+ }
+ assertTrue(dir.delete());
+ }
+
+ public void tearDown() {
+ if (mailOutputDir != null && mailOutputDir.exists()) {
+ delete(mailOutputDir);
+ }
+ }
+
+ public void testClientFileOutput() throws MailSendException, FileNotFoundException, IOException {
+ String body = "This is the body.";
+ String to = "to...@ex...";
+ String from = "ha...@ex...";
+ String subject = "OWLs 'n Stuff";
+ mailClient1.sendEmail(to, from, subject, body);
+ File[] files = mailClient1.getOutputDir().listFiles();
+ assertNotNull(files);
+ assertEquals(1, files.length);
+ assertFalse(files[0].length() == 0);
+ String fileContents = StreamUtils.readInput(new FileInputStream(files[0]));
+ assertTrue(fileContents.endsWith(body));
+ }
+
+ public void testFormat() {
+ String result = mailFormatter1.format(testMap1, testTemplate1);
+ assertNotNull(result);
+ assertTrue(result.length() > 1);
+ assertExactlyOne(result, (String) testMap1.get("username"));
+ assertMultiple(result, (String) testMap1.get("url"));
+ assertExactlyOne(result, (String) testMap1.get("moon.unit"));
+ assertExactlyOne(result, (String) testMap1.get("Kurt"));
+ }
+
+ private void assertExactlyOne(String data, String target) {
+ ArgumentUtils.assertNotEmpty(data);
+ ArgumentUtils.assertNotEmpty(target);
+ assertFalse(data.indexOf(target) == -1);
+ assertTrue(data.indexOf(target) == data.lastIndexOf(target));
+ }
+
+ private void assertMultiple(String data, String target) {
+ ArgumentUtils.assertNotEmpty(data);
+ ArgumentUtils.assertNotEmpty(target);
+ assertFalse(data.indexOf(target) == -1);
+ assertFalse(data.indexOf(target) == data.lastIndexOf(target));
+ }
+}
Added: spaces/trunk/src/com/ogoglio/mail/TestTemplate1.txt
===================================================================
--- spaces/trunk/src/com/ogoglio/mail/TestTemplate1.txt (rev 0)
+++ spaces/trunk/src/com/ogoglio/mail/TestTemplate1.txt 2007-08-20 23:09:52 UTC (rev 248)
@@ -0,0 +1,6 @@
+Replace this with username: ${username}
+Replace this with url: ${url}
+Also replace this with url: ${url}
+Replace this with moon.unit: ${moon.unit}
+Don't replace this with it, though: ${moonAunit}
+Replace this with Kurt: ${Kurt}
\ No newline at end of file
Modified: spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java
===================================================================
--- spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java 2007-08-20 03:43:05 UTC (rev 247)
+++ spaces/trunk/src/com/ogoglio/persist/AccountPersistTasks.java 2007-08-20 23:09:52 UTC (rev 248)
@@ -21,193 +21,160 @@
public class AccountPersistTasks {
- public static final String ACCOUNT_BY_USERNAME = "com.ogoglio.persist.accountByUsername";
- public static final String ACCOUNT_BY_EMAIL = "com.ogoglio.persist.accountByEmail";
+ public static final String ACCOUNT_BY_USERNAME = "com.ogoglio.persist.accountByUsername";
- public static final String ACCOUNT_BY_COOKIE = "com.ogoglio.persist.accountByCookie";
+ public static final String ACCOUNT_BY_EMAIL = "com.ogoglio.persist.accountByEmail";
- public static boolean update(final AccountRecord record,
- final AccountDocument document, SessionFactory sessionFactory)
- throws PersistException {
- HibernateTask task = new HibernateTask() {
- public Object run(Session hibernateSession) {
- boolean dirty = false;
- if (document.getAccountLevel() != null
- && !equals(record.getAccountlevel(), document
- .getAccountLevel())) {
- dirty = true;
- record.setAccountlevel(document.getAccountLevel());
- }
+ public static final String ACCOUNT_BY_COOKIE = "com.ogoglio.persist.accountByCookie";
- if (document.getHomepage() != null
- && !equals(record.getHomepage(), document.getHomepage())) {
- dirty = true;
- record.setHomepage(document.getHomepage());
- }
+ public static boolean update(final AccountRecord record, final AccountDocument document, SessionFactory sessionFactory) throws PersistException {
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ boolean dirty = false;
+ if (document.getAccountLevel() != null && !equals(record.getAccountlevel(), document.getAccountLevel())) {
+ dirty = true;
+ record.setAccountlevel(document.getAccountLevel());
+ }
- if (document.getFirstName() != null
- && !equals(record.getFirstName(), document
- .getFirstName())) {
- dirty = true;
- record.setFirstName(document.getFirstName());
- }
+ if (document.getHomepage() != null && !equals(record.getHomepage(), document.getHomepage())) {
+ dirty = true;
+ record.setHomepage(document.getHomepage());
+ }
- if (document.getLastName() != null
- && !equals(record.getLastName(), document.getLastName())) {
- dirty = true;
- record.setLastName(document.getLastName());
- }
+ if (document.getFirstName() != null && !equals(record.getFirstName(), document.getFirstName())) {
+ dirty = true;
+ record.setFirstName(document.getFirstName());
+ }
- if (document.getPassword() != null
- && !equals(record.getPassword(), document.getPassword())) {
- if (AccountRecord.cleanPassword(document.getPassword()) != null) {
- dirty = true;
- record.setPassword(document.getPassword());
- }
- }
+ if (document.getLastName() != null && !equals(record.getLastName(), document.getLastName())) {
+ dirty = true;
+ record.setLastName(document.getLastName());
+ }
- if (document.getDefaultBodyID() != -1) {
- Query bodyQuery = hibernateSession
- .getNamedQuery(BodyPersistTasks.BODY_BY_ID);
- bodyQuery.setLong("bodyID", document.getDefaultBodyID());
- BodyRecord bodyRec = (BodyRecord) bodyQuery.uniqueResult();
- if (bodyRec != null
- && bodyRec.getOwnerUsername().equals(
- record.getUsername())) {
- dirty = true;
- record.setDefaultBodyID(document.getDefaultBodyID());
- }
- }
+ if (document.getPassword() != null && !equals(record.getPassword(), document.getPassword())) {
+ if (AccountRecord.cleanPassword(document.getPassword()) != null) {
+ dirty = true;
+ record.setPassword(document.getPassword());
+ }
+ }
-
- if (document.getFrozenUntil() != null) {
- if (record.getFrozenUntil()!=document.getFrozenUntil().getTime()) {
- dirty = true;
- if (document.getFrozenUntil().getTime() < System.currentTimeMillis()) {
- record.setNotFrozen();
- } else {
- record.setFrozenUntil(document.getFrozenUntil().getTime());
- }
- }
- }
- if (dirty) {
- hibernateSession.update(record);
- return Boolean.TRUE;
- }
- return Boolean.FALSE;
- }
- };
- task.setSessionFactory(sessionFactory);
- return "true".equals(task.execute().toString());
- }
+ if (document.getDefaultBodyID() != -1) {
+ Query bodyQuery = hibernateSession.getNamedQuery(BodyPersistTasks.BODY_BY_ID);
+ bodyQuery.setLong("bodyID", document.getDefaultBodyID());
+ BodyRecord bodyRec = (BodyRecord) bodyQuery.uniqueResult();
+ if (bodyRec != null && bodyRec.getOwnerUsername().equals(record.getUsername())) {
+ dirty = true;
+ record.setDefaultBodyID(document.getDefaultBodyID());
+ }
+ }
- public static void update(final AccountRecord record,
- SessionFactory sessionFactory) throws PersistException {
- HibernateTask task = new HibernateTask() {
- public Object run(Session hibernateSession) {
- hibernateSession.update(record);
- return null;
- }
- };
- task.setSessionFactory(sessionFactory);
- task.execute();
- }
+ if (document.getFrozenUntil() != null) {
+ if (record.getFrozenUntil() != document.getFrozenUntil().getTime()) {
+ dirty = true;
+ if (document.getFrozenUntil().getTime() < System.currentTimeMillis()) {
+ record.setNotFrozen();
+ } else {
+ record.setFrozenUntil(document.getFrozenUntil().getTime());
+ }
+ }
+ }
+ if (dirty) {
+ hibernateSession.update(record);
+ return Boolean.TRUE;
+ }
+ return Boolean.FALSE;
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ return "true".equals(task.execute().toString());
+ }
- public static AccountRecord findAccountByCookie(final String cookie,
- SessionFactory sessionFactory) throws PersistException {
- HibernateTask task = new HibernateTask() {
- public Object run(Session hibernateSession) {
- Query query = hibernateSession.getNamedQuery(ACCOUNT_BY_COOKIE);
- query.setParameter("cookie", cookie);
- AccountRecord rec = (AccountRecord) query.uniqueResult();
- return rec;
- }
- };
- task.setSessionFactory(sessionFactory);
- return (AccountRecord) task.execute();
- }
+ public static void update(final AccountRecord record, SessionFactory sessionFactory) throws PersistException {
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ hibernateSession.update(record);
+ return null;
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ task.execute();
+ }
- public static AccountRecord[] findAllAccounts(SessionFactory sessionFactory)
- throws PersistException {
- HibernateTask task = new HibernateTask() {
- public Object run(Session hibernateSession) {
- Query query = hibernateSession
- .getNamedQuery("com.ogoglio.persist.accounts");
- return query.list().toArray(new AccountRecord[0]);
- }
- };
- task.setSessionFactory(sessionFactory);
- return (AccountRecord[]) task.execute();
- }
+ public static AccountRecord findAccountByCookie(final String cookie, SessionFactory sessionFactory) throws PersistException {
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ Query query = hibernateSession.getNamedQuery(ACCOUNT_BY_COOKIE);
+ query.setParameter("cookie", cookie);
+ AccountRecord rec = (AccountRecord) query.uniqueResult();
+ return rec;
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ return (AccountRecord) task.execute();
+ }
- public static AccountRecord createAccount(final String username,
- final String accountlevel, final String email,
- SessionFactory sessionFactory) throws PersistException {
- HibernateTask task = new HibernateTask() {
- public Object run(Session hibernateSession) {
- final String cleanedUsername = AccountRecord
- .cleanUsername(username);
- Query query = hibernateSession
- .getNamedQuery(ACCOUNT_BY_USERNAME);
- query.setParameter("username", cleanedUsername);
+ public static AccountRecord[] findAllAccounts(SessionFactory sessionFactory) throws PersistException {
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ Query query = hibernateSession.getNamedQuery("com.ogoglio.persist.accounts");
+ return query.list().toArray(new AccountRecord[0]);
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ return (AccountRecord[]) task.execute();
+ }
- AccountRecord record = (AccountRecord) query.uniqueResult();
- if (record != null) {
- return null; // XXX really weird semantic: try to create something and get null because it's there?
- }
+ public static AccountRecord createAccount(final String username, final String accountlevel, final String email, SessionFactory sessionFactory) throws PersistException {
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ final String cleanedUsername = AccountRecord.cleanUsername(username);
+ Query query = hibernateSession.getNamedQuery(ACCOUNT_BY_USERNAME);
+ query.setParameter("username", cleanedUsername);
- //IES:debug because unique constraint on this field!
- final String cleanedEmail = AccountRecord.cleanEmail(email);
- query = hibernateSession.getNamedQuery(ACCOUNT_BY_EMAIL);
- query.setParameter("email", email);
- record = (AccountRecord) query.uniqueResult();
- if (record != null) {
- System.err.println("Whoa! Bad email value!" + email);
- }
+ AccountRecord record = (AccountRecord) query.uniqueResult();
+ if (record != null) {
+ return null;
+ }
- record = new AccountRecord(username, accountlevel, email);
- hibernateSession.save(record);
- BodyRecord bodyRec = new BodyRecord("Body", record
- .getUsername());
- hibernateSession.save(bodyRec);
+ String cleanedEmail = AccountRecord.cleanEmail(email);
+ query = hibernateSession.getNamedQuery(ACCOUNT_BY_EMAIL);
+ query.setParameter("email", cleanedEmail);
+ record = (AccountRecord) query.uniqueResult();
+ if (record != null) {
+ System.err.println("Whoa! Bad email value!" + cleanedEmail);
+ }
- record.setDefaultBodyID(bodyRec.getBodyID());
- hibernateSession.update(record);
- return record;
- }
- };
- task.setSessionFactory(sessionFactory);
- return (AccountRecord) task.execute();
- }
+ record = new AccountRecord(username, accountlevel, cleanedEmail);
+ hibernateSession.save(record);
+ BodyRecord bodyRec = new BodyRecord("Body", record.getUsername());
+ hibernateSession.save(bodyRec);
- public static AccountRecord findAccountByUsername(String username,
- SessionFactory sessionFactory) throws PersistException {
- final String cleanedUsername = AccountRecord.cleanUsername(username);
- if (cleanedUsername == null) {
- return null;
- }
- HibernateTask task = new HibernateTask() {
- public Object run(Session hibernateSession) {
- Query query = hibernateSession
- .getNamedQuery(ACCOUNT_BY_USERNAME);
- query.setParameter("username", cleanedUsername);
- return query.uniqueResult();
- }
- };
- task.setSessionFactory(sessionFactory);
- return (AccountRecord) task.execute();
- }
+ record.setDefaultBodyID(bodyRec.getBodyID());
+ hibernateSession.update(record);
+
+ PendingEmailValidationRecord validationRecord = new PendingEmailValidationRecord(username, cleanedEmail);
+ hibernateSession.save(validationRecord);
+
+ return record;
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ return (AccountRecord) task.execute();
+ }
- public static void delete(final AccountRecord accRec,
- SessionFactory sessionFactory) throws PersistException {
- HibernateTask task = new HibernateTask() {
- public Object run(Session hibernateSession) {
- hibernateSession.delete(accRec);
- return null;
- }
- };
- task.setSessionFactory(sessionFactory);
- task.execute();
-
- }
+ public static AccountRecord findAccountByUsername(String username, SessionFactory sessionFactory) throws PersistException {
+ final String cleanedUsername = AccountRecord.cleanUsername(username);
+ if (cleanedUsername == null) {
+ return null;
+ }
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ Query query = hibernateSession.getNamedQuery(ACCOUNT_BY_USERNAME);
+ query.setParameter("username", cleanedUsername);
+ return query.uniqueResult();
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ return (AccountRecord) task.execute();
+ }
}
Added: spaces/trunk/src/com/ogoglio/persist/PendingEmailValidationRecord.java
===================================================================
--- spaces/trunk/src/com/ogoglio/persist/PendingEmailValidationRecord.java (rev 0)
+++ spaces/trunk/src/com/ogoglio/persist/PendingEmailValidationRecord.java 2007-08-20 23:09:52 UTC (rev 248)
@@ -0,0 +1,73 @@
+package com.ogoglio.persist;
+
+import java.util.Random;
+
+import com.ogoglio.util.ArgumentUtils;
+
+public class PendingEmailValidationRecord {
+
+ private static Random RANDOM = new Random();
+
+ private String username = null;
+
+ private String email = null;
+
+ private String secret = null;
+
+ private long creationDate = AccountRecord.NO_TIME_VALUE;
+
+ public PendingEmailValidationRecord() {
+ }
+
+ public PendingEmailValidationRecord(String username, String email) {
+ ArgumentUtils.assertNotEmpty(username);
+ ArgumentUtils.assertIsEmail(email);
+ this.username = username;
+ this.email = email;
+ this.secret = generateSecret();
+ creationDate = System.currentTimeMillis();
+ }
+
+ private static final String SECRET_SOURCE = "abcdefghijklmnopqrstuvwxyz1234567890";
+
+ private String generateSecret() {
+ StringBuffer result = new StringBuffer();
+ for (int i = 0; i < 25; i++) {
+ result.append(SECRET_SOURCE.charAt(Math.abs(RANDOM.nextInt()) % SECRET_SOURCE.length()));
+ }
+ return result.toString();
+ }
+
+ public long getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(long creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ ArgumentUtils.assertIsEmail(email);
+ this.email = email;
+ }
+
+ public String getSecret() {
+ return secret;
+ }
+
+ public void setSecret(String secret) {
+ this.secret = secret;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+}
Modified: spaces/trunk/src/com/ogoglio/persist/Persist.hbm.xml
===================================================================
--- spaces/trunk/src/com/ogoglio/persist/Persist.hbm.xml 2007-08-20 03:43:05 UTC (rev 247)
+++ spaces/trunk/src/com/ogoglio/persist/Persist.hbm.xml 2007-08-20 23:09:52 UTC (rev 248)
@@ -89,6 +89,13 @@
<property name="defaultBodyID" />
</class>
+ <class name="com.ogoglio.persist.PendingEmailValidationRecord" table="PendingEmailValidationRecords">
+ <id name="email"><generator class="assigned"/></id>
+ <property name="username" not-null=...
[truncated message content] |