|
From: <ian...@us...> - 2007-08-21 16:22:47
|
Revision: 255
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=255&view=rev
Author: iansmith
Date: 2007-08-21 09:22:50 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
Moved hibernate config files to be a resources.
Added forgotten code in com.ogoglio.util.*
Moved log4j config files.
Upgraded pom to start server now at integration test time.
Got data sources into context.xml
We are passing the two big integration tests now.
Added sample-art3d as needed for tests.
Modified Paths:
--------------
maven/trunk/ogoglio-server/.classpath
maven/trunk/ogoglio-server/pom.xml
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/PossessionRecord.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimRecord.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpaceMemberRecord.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/TemplateRecord.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/xml/server/DocumentFactory.java
maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml
Added Paths:
-----------
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/ArgumentUtils.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/BlockingQueue.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/ContextMenuInfo.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/LimitedInputStream.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/NetworkUtils.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/OgoglioProperties.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/PrepareDatabase.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/StreamUtils.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/TwoWayMap.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/URLUTF8Encoder.java
maven/trunk/ogoglio-server/src/main/resources/hibernate/
maven/trunk/ogoglio-server/src/main/resources/hibernate/Persist.hbm.xml
maven/trunk/ogoglio-server/src/main/resources/hibernate/Persist_NoTemplateTables.hbm.xml
maven/trunk/ogoglio-server/src/main/resources/log4j/
maven/trunk/ogoglio-server/src/main/resources/log4j/log4j.properties
maven/trunk/ogoglio-server/src/test/java/com/
maven/trunk/ogoglio-server/src/test/java/com/ogoglio/
maven/trunk/ogoglio-server/src/test/java/com/ogoglio/client/
maven/trunk/ogoglio-server/src/test/java/com/ogoglio/client/test/
maven/trunk/ogoglio-server/src/test/resources/sample-art3d/
maven/trunk/ogoglio-server/src/test/resources/sample-art3d/TestCube.gif
maven/trunk/ogoglio-server/src/test/resources/sample-art3d/TestCube.js
maven/trunk/ogoglio-server/src/test/resources/sample-art3d/TestCube.mtl
maven/trunk/ogoglio-server/src/test/resources/sample-art3d/TestCube.obj
maven/trunk/ogoglio-server/src/test/resources/sample-art3d/TestCylinder.obj
Removed Paths:
-------------
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/Persist.hbm.xml
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/Persist_NoTemplateTables.hbm.xml
Property Changed:
----------------
maven/trunk/ogoglio-server/
Property changes on: maven/trunk/ogoglio-server
___________________________________________________________________
Name: svn:ignore
+ target
Modified: maven/trunk/ogoglio-server/.classpath
===================================================================
--- maven/trunk/ogoglio-server/.classpath 2007-08-21 16:17:53 UTC (rev 254)
+++ maven/trunk/ogoglio-server/.classpath 2007-08-21 16:22:50 UTC (rev 255)
@@ -6,6 +6,5 @@
<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ogoglio-common"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: maven/trunk/ogoglio-server/pom.xml
===================================================================
--- maven/trunk/ogoglio-server/pom.xml 2007-08-21 16:17:53 UTC (rev 254)
+++ maven/trunk/ogoglio-server/pom.xml 2007-08-21 16:22:50 UTC (rev 255)
@@ -3,14 +3,69 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
+
<groupId>com.ogoglio</groupId>
<artifactId>ogoglio-server</artifactId>
<packaging>war</packaging>
<version>0.0.1</version>
<build>
+ <!-- RESOURCES -->
+ <resources>
+ <resource>
+ <directory>src/main/resources/hibernate</directory>
+ <includes>
+ <include>hibernate.cfg.xml</include>
+ </includes>
+ </resource>
+ <resource>
+ <targetPath>com/ogoglio/persist</targetPath>
+ <directory>src/main/resources/hibernate</directory>
+ <includes>
+ <include>Persist.hbm.xml</include>
+ </includes>
+ </resource>
+
+ <resource>
+ <directory>src/main/resources/log4j</directory>
+ <includes>
+ <include>log4j.properties</include>
+ </includes>
+ </resource>
+
+ </resources>
+ <!-- PLUGINS -->
<plugins>
+
+ <!-- SUREFIRE INTEGRATION TEST HACK -->
+
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip><!-- this is critical to avoid running unit tests, sets default value for skip -->
+ </configuration>
+ <executions>
+ <execution>
+ <id>over the wire tests</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <includes>
+ <!-- we seem to like plurals -->
+ <include>**/*Tests.java</include>
+ </includes>
+ <skip>false</skip><!-- don't skip unit tests -->
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- CARGO -->
+
+ <plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>0.3-SNAPSHOT</version>
@@ -39,7 +94,6 @@
<containerId>tomcat5x</containerId>
<home>/usr/share/tomcat5.5</home>
<type>installed</type>
- <timeout>120</timeout>
<log>
${project.build.directory}/tomcat5x.log
</log>
@@ -57,7 +111,8 @@
8080
</cargo.servlet.port>
<cargo.logging>high</cargo.logging>
- <cargo.datasource.datasource>
+ <!--
+ <cargo.datasource.datasource>
cargo.datasource.url=jdbc:mysql://127.0.0.1/og|
cargo.datasource.driver=com.mysql.jdbc.Driver|
cargo.datasource.username=oguser|
@@ -67,15 +122,21 @@
cargo.datasource.maxIdle=5|
cargo.datasource.maxActive=50|
cargo.datasource.scope=Shareable
- </cargo.datasource.datasource>
-
+ </cargo.datasource.datasource>
+ -->
</properties>
<!-- our app to deploy -->
<deployables>
<deployable>
- <properties>
+
+ <groupId>com.ogoglio</groupId>
+ <artifactId>ogoglio-server</artifactId>
+ <type>war</type>
+
+ <properties>
<context>ogoglio-server</context>
- </properties>
+ </properties>
+
</deployable>
</deployables>
@@ -87,6 +148,7 @@
</build>
+ <!-- where to get cargo -->
<pluginRepositories>
<pluginRepository>
<id>codehaus snapshot repository</id>
@@ -103,34 +165,44 @@
<groupId>com.agical.rmock</groupId>
<artifactId>rmock</artifactId>
<version>2.0.0-rc-6</version>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.1.ga</version>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.3</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>rhino</groupId>
<artifactId>js</artifactId>
<version>1.6R6</version>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.0.1</version>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2</version>
+ <scope>compile</scope>
</dependency>
-
-
+ <dependency>
+ <groupId>com.ogoglio</groupId>
+ <artifactId>ogoglio-common</artifactId>
+ <version>0.0.1</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
</project>
Deleted: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/Persist.hbm.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/Persist.hbm.xml 2007-08-21 16:17:53 UTC (rev 254)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/Persist.hbm.xml 2007-08-21 16:22:50 UTC (rev 255)
@@ -1,215 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<!--
- Copyright 2007 Transmutable (http://transmutable.com/)
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
--->
-
-<hibernate-mapping>
-
- <class name="com.ogoglio.persist.PossessionRecord" table="PossessionRecords">
- <id name="possessionID">
- <generator class="increment"/>
- </id>
-
- <property name="ownerUsername" not-null="true" />
- <property name="templateID" />
- <property name="spaceID" />
- <property name="thingID" />
- </class>
-
- <class name="com.ogoglio.persist.BodyRecord" table="BodyRecords">
- <id name="bodyID">
- <generator class="increment"/>
- </id>
-
- <property name="displayName" not-null="true" />
- <property name="ownerUsername" not-null="true" update="false" />
- <property name="hairIndex" />
- <property name="eyesIndex" />
- <property name="noseIndex" />
- <property name="mouthIndex" />
- <property name="faceIndex" />
- <property name="girth" />
- <property name="height" />
- <property name="male" />
- </class>
-
- <class name="com.ogoglio.persist.SpaceRecord" table="SpaceRecords">
- <id name="spaceID" access="field">
- <generator class="increment"/>
- </id>
-
- <property name="displayName" not-null="true" />
- <property name="ownerUsername" not-null="true" update="false" />
- <property name="published" />
- <property name="maxGuests" />
- <property name="displaySea" access="field" />
- <property name="seaLevel" />
- <property name="simID" />
- </class>
-
- <class name="com.ogoglio.persist.SpaceMemberRecord" table="SpaceMemberRecords">
- <id name="spaceMemberID">
- <generator class="increment"/>
- </id>
-
- <property name="spaceID" update="false" />
- <property name="memberUsername" not-null="true" />
- <property name="banned" />
- <property name="role" />
- </class>
-
- <class name="com.ogoglio.persist.SimRecord" table="SimRecords">
- <id name="simID">
- <generator class="increment"/>
- </id>
-
- <property name="displayName" />
- <property name="simURIString" column="simURI" />
- <property name="active" />
- <property name="eventPort" />
- </class>
-
- <class name="com.ogoglio.persist.AccountRecord" table="AccountRecords">
- <id name="username">
- </id>
- <property name="email" not-null="true" unique="true" />
- <property name="accountlevel" not-null="true" />
- <property name="password"/>
- <property name="firstName"/>
- <property name="lastName"/>
- <property name="homepage"/>
- <property name="creationDate" update="false"/>
- <property name="cookie"/>
- <property name="secret"/>
- <property name="frozenUntil"/>
- <property name="defaultBodyID" />
- </class>
-
- <class name="com.ogoglio.persist.TemplateRecord" table="TemplateRecords">
- <id name="templateID">
- <generator class="increment"/>
- </id>
-
- <property name="ownerUsername" not-null="true"/>
- <property name="displayName" not-null="true"/>
- <property name="description"/>
-
- <set name="supportFiles" table="TemplateTemplateSupportFiles" cascade="all">
- <key column="templateID"/>
- <many-to-many
- column="templateSupportFileID"
- unique="true"
- class="com.ogoglio.persist.TemplateSupportFileRecord"/>
- </set>
- </class>
-
- <class name="com.ogoglio.persist.TemplateSupportFileRecord" table="TemplateSupportFileRecords">
- <id name="templateSupportFileID">
- <generator class="increment"/>
- </id>
- <property name="supportFile"/>
- <property name="script" not-null="true"/>
- <property name="levelOfDetail" not-null="true"/>
- <property name="lastChanged" not-null="true"/>
- </class>
- <query name="com.ogoglio.persist.possessionByPossessionID">
- <![CDATA[ from com.ogoglio.persist.PossessionRecord as possession where possession.possessionID = :possessionID ]]>
- </query>
-
- <query name="com.ogoglio.persist.possessionsByOwnerUsername">
- <![CDATA[ from com.ogoglio.persist.PossessionRecord as possession where possession.ownerUsername = :ownerUsername ]]>
- </query>
-
- <query name="com.ogoglio.persist.possessionsBySpaceID">
- <![CDATA[ from com.ogoglio.persist.PossessionRecord as possession where possession.spaceID = :spaceID ]]>
- </query>
-
- <query name="com.ogoglio.persist.templateByID">
- <![CDATA[ from com.ogoglio.persist.TemplateRecord as template where template.templateID = :templateID ]]>
- </query>
-
- <query name="com.ogoglio.persist.templateByIDs">
- <![CDATA[ from com.ogoglio.persist.TemplateRecord as template where template.templateID in ( :templateIDs ) ]]>
- </query>
-
- <query name="com.ogoglio.persist.templateByOwner">
- <![CDATA[ from com.ogoglio.persist.TemplateRecord as template where template.ownerUsername = :ownerUsername ]]>
- </query>
-
- <query name="com.ogoglio.persist.bodyByID">
- <![CDATA[ from com.ogoglio.persist.BodyRecord as body where body.bodyID = :bodyID ]]>
- </query>
-
- <query name="com.ogoglio.persist.bodiesByUsername">
- <![CDATA[ from com.ogoglio.persist.BodyRecord as body where body.ownerUsername = :username ]]>
- </query>
-
- <query name="com.ogoglio.persist.accountByUsername">
- <![CDATA[ from com.ogoglio.persist.AccountRecord as account where account.username = :username ]]>
- </query>
-
- <query name="com.ogoglio.persist.accountByEmail">
- <![CDATA[ from com.ogoglio.persist.AccountRecord as account where account.email = :email ]]>
- </query>
-
- <query name="com.ogoglio.persist.accountByCookie">
- <![CDATA[ from com.ogoglio.persist.AccountRecord as account where account.cookie = :cookie ]]>
- </query>
-
- <query name="com.ogoglio.persist.simByURI">
- <![CDATA[ from com.ogoglio.persist.SimRecord as sim where sim.simURIString = :simURI ]]>
- </query>
-
- <query name="com.ogoglio.persist.simBySimID">
- <![CDATA[ from com.ogoglio.persist.SimRecord as sim where sim.simID = :simID ]]>
- </query>
-
- <query name="com.ogoglio.persist.simsByActive">
- <![CDATA[ from com.ogoglio.persist.SimRecord as sim where sim.active = :active ]]>
- </query>
-
- <query name="com.ogoglio.persist.sims">
- <![CDATA[ from com.ogoglio.persist.SimRecord ]]>
- </query>
-
- <query name="com.ogoglio.persist.accounts">
- <![CDATA[ from com.ogoglio.persist.AccountRecord ]]>
- </query>
-
- <query name="com.ogoglio.persist.bodies">
- <![CDATA[ from com.ogoglio.persist.BodyRecord order by BodyID asc]]>
- </query>
- <query name="com.ogoglio.persist.possessions">
- <![CDATA[ from com.ogoglio.persist.PossessionRecord order by PossessionID asc ]]>
- </query>
- <query name="com.ogoglio.persist.spaces">
- <![CDATA[ from com.ogoglio.persist.SpaceRecord order by SpaceID asc]]>
- </query>
- <query name="com.ogoglio.persist.spacemembers">
- <![CDATA[ from com.ogoglio.persist.SpaceMemberRecord order by SpaceMemberID asc]]>
- </query>
-
- <query name="com.ogoglio.persist.spacesByOwnerUsername">
- <![CDATA[ from com.ogoglio.persist.SpaceRecord as space where space.ownerUsername = :ownerUsername ]]>
- </query>
-
- <query name="com.ogoglio.persist.spaceBySpaceID">
- <![CDATA[ from com.ogoglio.persist.SpaceRecord as space where space.spaceID = :spaceID ]]>
- </query>
-
- <query name="com.ogoglio.persist.spaceMembersBySpaceID">
- <![CDATA[ from com.ogoglio.persist.SpaceMemberRecord as spaceMember where spaceMember.spaceID = :spaceID ]]>
- </query>
-
- <query name="com.ogoglio.persist.spaceMembershipByMemberUsername">
- <![CDATA[ from com.ogoglio.persist.SpaceMemberRecord as spaceMember where spaceMember.memberUsername = :memberUsername ]]>
- </query>
-
- <query name="com.ogoglio.persist.spaceMemberByUsername">
- <![CDATA[ from com.ogoglio.persist.SpaceMemberRecord as spaceMember where spaceMember.spaceID = :spaceID and spaceMember.memberUsername = :username ]]>
- </query>
-</hibernate-mapping>
\ No newline at end of file
Deleted: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/Persist_NoTemplateTables.hbm.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/Persist_NoTemplateTables.hbm.xml 2007-08-21 16:17:53 UTC (rev 254)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/Persist_NoTemplateTables.hbm.xml 2007-08-21 16:22:50 UTC (rev 255)
@@ -1,191 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<!--
- Copyright 2007 Transmutable (http://transmutable.com/)
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
--->
-
-<hibernate-mapping>
-
- <class name="com.ogoglio.persist.PossessionRecord" table="PossessionRecords">
- <id name="possessionID">
- <generator class="increment"/>
- </id>
-
- <property name="ownerUsername" not-null="true" />
- <property name="templateID" />
- <property name="spaceID" />
- <property name="thingID" />
- </class>
-
- <class name="com.ogoglio.persist.BodyRecord" table="BodyRecords">
- <id name="bodyID">
- <generator class="increment"/>
- </id>
-
- <property name="displayName" not-null="true" />
- <property name="ownerUsername" not-null="true" update="false" />
- <property name="hairIndex" />
- <property name="eyesIndex" />
- <property name="noseIndex" />
- <property name="mouthIndex" />
- <property name="faceIndex" />
- <property name="girth" />
- <property name="height" />
- <property name="male" />
- </class>
-
- <class name="com.ogoglio.persist.SpaceRecord" table="SpaceRecords">
- <id name="spaceID" access="field">
- <generator class="increment"/>
- </id>
-
- <property name="displayName" not-null="true" />
- <property name="ownerUsername" not-null="true" update="false" />
- <property name="published" />
- <property name="maxGuests" />
- <property name="displaySea" access="field" />
- <property name="seaLevel" />
- <property name="simID" />
- </class>
-
- <class name="com.ogoglio.persist.SpaceMemberRecord" table="SpaceMemberRecords">
- <id name="spaceMemberID">
- <generator class="increment"/>
- </id>
-
- <property name="spaceID" update="false" />
- <property name="memberUsername" not-null="true" />
- <property name="banned" />
- <property name="role" />
- </class>
-
- <class name="com.ogoglio.persist.SimRecord" table="SimRecords">
- <id name="simID">
- <generator class="increment"/>
- </id>
-
- <property name="displayName" />
- <property name="simURIString" column="simURI" />
- <property name="active" />
- <property name="eventPort" />
- </class>
-
- <class name="com.ogoglio.persist.AccountRecord" table="AccountRecords">
- <id name="username">
- </id>
-
- <property name="email" not-null="true" unique="true" />
- <property name="accountlevel" not-null="true" />
- <property name="password"/>
- <property name="firstName"/>
- <property name="lastName"/>
- <property name="homepage"/>
- <property name="creationDate" update="false" />
- <property name="cookie"/>
- <property name="secret"/>
- <property name="frozenUntil"/>
- <property name="defaultBodyID" />
- </class>
-
- <class name="com.ogoglio.persist.TemplateRecord" table="TemplateRecords">
- <id name="templateID">
- <generator class="increment"/>
- </id>
-
- <property name="ownerUsername" not-null="true"/>
- <property name="displayName" not-null="true"/>
- <property name="description"/>
- </class>
- <query name="com.ogoglio.persist.possessionByPossessionID">
- <![CDATA[ from com.ogoglio.persist.PossessionRecord as possession where possession.possessionID = :possessionID ]]>
- </query>
-
- <query name="com.ogoglio.persist.possessionsByOwnerUsername">
- <![CDATA[ from com.ogoglio.persist.PossessionRecord as possession where possession.ownerUsername = :ownerUsername ]]>
- </query>
-
- <query name="com.ogoglio.persist.possessionsBySpaceID">
- <![CDATA[ from com.ogoglio.persist.PossessionRecord as possession where possession.spaceID = :spaceID ]]>
- </query>
-
- <query name="com.ogoglio.persist.templateByID">
- <![CDATA[ from com.ogoglio.persist.TemplateRecord as template where template.templateID = :templateID ]]>
- </query>
-
- <query name="com.ogoglio.persist.templateByIDs">
- <![CDATA[ from com.ogoglio.persist.TemplateRecord as template where template.templateID in ( :templateIDs ) ]]>
- </query>
-
- <query name="com.ogoglio.persist.templateByOwner">
- <![CDATA[ from com.ogoglio.persist.TemplateRecord as template where template.ownerUsername = :ownerUsername ]]>
- </query>
-
- <query name="com.ogoglio.persist.bodyByID">
- <![CDATA[ from com.ogoglio.persist.BodyRecord as body where body.bodyID = :bodyID ]]>
- </query>
-
- <query name="com.ogoglio.persist.bodiesByUsername">
- <![CDATA[ from com.ogoglio.persist.BodyRecord as body where body.ownerUsername = :username ]]>
- </query>
-
- <query name="com.ogoglio.persist.accountByUsername">
- <![CDATA[ from com.ogoglio.persist.AccountRecord as account where account.username = :username ]]>
- </query>
-
- <query name="com.ogoglio.persist.accountByCookie">
- <![CDATA[ from com.ogoglio.persist.AccountRecord as account where account.cookie = :cookie ]]>
- </query>
-
- <query name="com.ogoglio.persist.simByURI">
- <![CDATA[ from com.ogoglio.persist.SimRecord as sim where sim.simURIString = :simURI ]]>
- </query>
-
- <query name="com.ogoglio.persist.simBySimID">
- <![CDATA[ from com.ogoglio.persist.SimRecord as sim where sim.simID = :simID ]]>
- </query>
-
- <query name="com.ogoglio.persist.simsByActive">
- <![CDATA[ from com.ogoglio.persist.SimRecord as sim where sim.active = :active ]]>
- </query>
-
- <query name="com.ogoglio.persist.sims">
- <![CDATA[ from com.ogoglio.persist.SimRecord ]]>
- </query>
- <query name="com.ogoglio.persist.accounts">
- <![CDATA[ from com.ogoglio.persist.AccountRecord ]]>
- </query>
- <query name="com.ogoglio.persist.bodies">
- <![CDATA[ from com.ogoglio.persist.BodyRecord ]]>
- </query>
- <query name="com.ogoglio.persist.possessions">
- <![CDATA[ from com.ogoglio.persist.PossessionRecord ]]>
- </query>
- <query name="com.ogoglio.persist.spaces">
- <![CDATA[ from com.ogoglio.persist.SpaceRecord ]]>
- </query>
- <query name="com.ogoglio.persist.spacemembers">
- <![CDATA[ from com.ogoglio.persist.SpaceMemberRecord ]]>
- </query>
- <query name="com.ogoglio.persist.spacesByOwnerUsername">
- <![CDATA[ from com.ogoglio.persist.SpaceRecord as space where space.ownerUsername = :ownerUsername ]]>
- </query>
-
- <query name="com.ogoglio.persist.spaceBySpaceID">
- <![CDATA[ from com.ogoglio.persist.SpaceRecord as space where space.spaceID = :spaceID ]]>
- </query>
-
- <query name="com.ogoglio.persist.spaceMembersBySpaceID">
- <![CDATA[ from com.ogoglio.persist.SpaceMemberRecord as spaceMember where spaceMember.spaceID = :spaceID ]]>
- </query>
-
- <query name="com.ogoglio.persist.spaceMembershipByMemberUsername">
- <![CDATA[ from com.ogoglio.persist.SpaceMemberRecord as spaceMember where spaceMember.memberUsername = :memberUsername ]]>
- </query>
-
- <query name="com.ogoglio.persist.spaceMemberByUsername">
- <![CDATA[ from com.ogoglio.persist.SpaceMemberRecord as spaceMember where spaceMember.spaceID = :spaceID and spaceMember.memberUsername = :username ]]>
- </query>
-</hibernate-mapping>
\ No newline at end of file
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/PossessionRecord.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/PossessionRecord.java 2007-08-21 16:17:53 UTC (rev 254)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/PossessionRecord.java 2007-08-21 16:22:50 UTC (rev 255)
@@ -42,17 +42,21 @@
return ownerUsername;
}
- /*
+ //hibernate access
private void setOwnerUsername(String ownerUsername) {
this.ownerUsername = ownerUsername;
}
+
+ //hibernate access
private void setTemplateID(long templateID) {
this.templateID = templateID;
}
+
+ //hibernate access
private void setPossessionID(long possessionID) {
this.possessionID = possessionID;
}
- */
+
public long getPossessionID() {
return possessionID;
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimRecord.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimRecord.java 2007-08-21 16:17:53 UTC (rev 254)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SimRecord.java 2007-08-21 16:22:50 UTC (rev 255)
@@ -78,18 +78,20 @@
}
return ArgumentUtils.createURI(simURIString);
}
- /*
+
+ //hibernate access
private String getSimURIString() {
return simURIString;
}
+ //hibernate access
private void setSimURIString(String simURIString) {
if(simURIString != null) {
ArgumentUtils.assertIsURI(simURIString);
}
this.simURIString = simURIString;
}
-*/
+
public boolean equals(Object obj) {
if(obj == null || !(obj instanceof SimRecord)) {
return false;
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpaceMemberRecord.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpaceMemberRecord.java 2007-08-21 16:17:53 UTC (rev 254)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpaceMemberRecord.java 2007-08-21 16:22:50 UTC (rev 255)
@@ -62,19 +62,22 @@
public String getMemberUsername() {
return memberUsername;
}
- /*
+
+ //hibernate access
private void setMemberUsername(String memberUsername) {
this.memberUsername = memberUsername;
}
+ //hibernate access
private void setSpaceID(long spaceID) {
this.spaceID = spaceID;
}
+ //hibernate access
private void setSpaceMemberID(long spaceMemberID) {
this.spaceMemberID = spaceMemberID;
}
- */
+
public long getSpaceID() {
return spaceID;
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/TemplateRecord.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/TemplateRecord.java 2007-08-21 16:17:53 UTC (rev 254)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/TemplateRecord.java 2007-08-21 16:22:50 UTC (rev 255)
@@ -54,14 +54,17 @@
public String getOwnerUsername() {
return ownerUsername;
}
- /*
+
+ //hibernate access
private void setOwnerUsername(String ownerUsername) {
this.ownerUsername = ownerUsername;
}
+
+ //hibernate access
private void setTemplateID(long templateID) {
this.templateID = templateID;
}
- */
+
public long getTemplateID() {
return templateID;
}
Added: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/ArgumentUtils.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/ArgumentUtils.java (rev 0)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/ArgumentUtils.java 2007-08-21 16:22:50 UTC (rev 255)
@@ -0,0 +1,104 @@
+/* Copyright 2007 Transmutable (http://transmutable.com/)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
+package com.ogoglio.util;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public class ArgumentUtils {
+
+ public static void assertNotEmpty(String value) {
+ if (value == null || value.trim().length() == 0) {
+ throw new IllegalArgumentException("String was empty.");
+ }
+ }
+
+ public static void assertNotNull(Object object) {
+ if (object == null) {
+ throw new IllegalArgumentException("Argument was null");
+ }
+ }
+
+ public static void assertNotNegative(long bodyID) {
+ if (bodyID < 0) {
+ throw new IllegalArgumentException("Argument was less than zero");
+ }
+ }
+
+ public static void assertNotNegative(float skinRed) {
+ if (skinRed < 0) {
+ throw new IllegalArgumentException("Argument was less than zero");
+ }
+ }
+
+ public static void assertIsURI(String uri) {
+ try {
+ new URI(uri);
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException("Bad uri: " + uri);
+ }
+ }
+
+ public static URI createURI(String uriString) {
+ try {
+ return new URI(uriString);
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException("Bad uri: " + uriString);
+ }
+ }
+
+ public static void assertReadableFile(String path) {
+ File file = new File(path);
+ if(!file.exists() || !file.canRead() || !file.isFile()) {
+ throw new IllegalArgumentException("No readable file at " + path);
+ }
+ }
+
+ public static void assertReadableDir(File file, boolean createIfPossible) {
+ if (file == null) {
+ throw new IllegalArgumentException("Null directory");
+ }
+
+ if (file.exists()) {
+ if(!file.isDirectory()) {
+ throw new IllegalArgumentException("Expected a directory: " + file);
+ }
+ if (!file.canRead()) {
+ throw new IllegalArgumentException("Can't read this directory: " + file);
+ }
+ return;
+ } else if(createIfPossible && file.mkdirs()){
+ return;
+ }
+ throw new IllegalArgumentException("Can't read this directory: " + file);
+ }
+
+ public static void assertNoPaths(String name) {
+ if(name == null || name.trim().length() == 0) {
+ return;
+ }
+ if(name.indexOf("..") != -1) {
+ throw new IllegalArgumentException("Bad name: " + name);
+ }
+ }
+
+ public static void assertBoringDouble(double value) {
+ if(Double.isInfinite(value) || Double.isInfinite(value)) {
+ throw new IllegalArgumentException("Bad double: " + value);
+ }
+ }
+
+
+}
Added: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/BlockingQueue.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/BlockingQueue.java (rev 0)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/BlockingQueue.java 2007-08-21 16:22:50 UTC (rev 255)
@@ -0,0 +1,84 @@
+/* Copyright 2007 Transmutable (http://transmutable.com/)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
+
+package com.ogoglio.util;
+
+import java.util.LinkedList;
+import java.util.NoSuchElementException;
+
+public class BlockingQueue {
+
+ private int maxSize = -1;
+
+ private LinkedList elements = new LinkedList();
+
+ private boolean closed = false;
+
+ public class QueueClosedException extends RuntimeException {
+ }
+
+ public class QueueOverflowException extends RuntimeException {
+ }
+
+ public synchronized final void enqueue(Object element) throws QueueClosedException, QueueOverflowException {
+ if (closed) {
+ throw new QueueClosedException();
+ }
+ if (maxSize > -1 && elements.size() >= maxSize) {
+ throw new QueueOverflowException();
+ }
+ elements.addLast(element);
+ notify();
+ }
+
+ public synchronized final int size() {
+ return elements.size();
+ }
+
+ public synchronized final Object dequeue() throws InterruptedException, QueueClosedException {
+ try {
+ while (elements.size() <= 0) {
+ wait();
+ if (closed) {
+ throw new QueueClosedException();
+ }
+ }
+ return elements.removeFirst();
+ } catch (NoSuchElementException e) {
+ throw new Error("No such element exception: " + e);
+ }
+ }
+
+ public synchronized final boolean isEmpty() {
+ return elements.size() == 0;
+ }
+
+ public synchronized boolean isClosed() {
+ return closed;
+ }
+
+ public synchronized void close() {
+ closed = true;
+ notifyAll();
+ elements.clear();
+ }
+
+ public synchronized int getMaxSize() {
+ return maxSize;
+ }
+
+ public synchronized void setMaxSize(int maxSize) {
+ this.maxSize = maxSize;
+ }
+}
\ No newline at end of file
Added: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/ContextMenuInfo.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/ContextMenuInfo.java (rev 0)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/ContextMenuInfo.java 2007-08-21 16:22:50 UTC (rev 255)
@@ -0,0 +1,23 @@
+package com.ogoglio.util;
+
+public class ContextMenuInfo {
+ private String userVisibleString;
+ private String id;
+ private boolean enabled;
+
+ public String getUserVisibleString() {
+ return userVisibleString;
+ }
+ public String getId() {
+ return id;
+ }
+ public boolean getEnabled() {
+ return enabled;
+ }
+ public void setValues(String textToShow, boolean notGrayedOut, String forCallback) {
+ userVisibleString=textToShow;
+ enabled=notGrayedOut;
+ id=forCallback;
+ }
+
+}
Added: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/LimitedInputStream.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/LimitedInputStream.java (rev 0)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/LimitedInputStream.java 2007-08-21 16:22:50 UTC (rev 255)
@@ -0,0 +1,56 @@
+/* Copyright 2007 Transmutable (http://transmutable.com/)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
+
+package com.ogoglio.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class LimitedInputStream extends InputStream {
+
+ private InputStream input = null;
+
+ private int maxRead = -1;
+
+ private int read = 0;
+
+ public LimitedInputStream(InputStream input, int maxRead) {
+ this.input = input;
+ this.maxRead = maxRead;
+ }
+
+ public int read(byte[] buffer) throws IOException {
+ return read(buffer, 0, buffer.length);
+ }
+
+ public int read(byte[] buffer, int offset, int len) throws IOException {
+ if (read >= maxRead) {
+ return -1;
+ }
+
+ if (read + len > maxRead) {
+ len = maxRead - read;
+ }
+ return super.read(buffer, offset, len);
+ }
+
+ public int read() throws IOException {
+ if (read >= maxRead) {
+ return -1;
+ }
+ int result = input.read();
+ read++;
+ return result;
+ }
+}
Added: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/NetworkUtils.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/NetworkUtils.java (rev 0)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/NetworkUtils.java 2007-08-21 16:22:50 UTC (rev 255)
@@ -0,0 +1,61 @@
+/* Copyright 2007 Transmutable (http://transmutable.com/)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
+
+package com.ogoglio.util;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.Enumeration;
+
+public class NetworkUtils {
+
+ public static String LOCAL_HOST_ADDRESS = null;
+
+ static boolean notified = false;
+
+ public static void setLocalHostAddress(String hostAddress) {
+ if (hostAddress == null || hostAddress.trim().length() == 0) {
+ throw new IllegalArgumentException("bad host address: " + hostAddress);
+ }
+ LOCAL_HOST_ADDRESS = hostAddress;
+ }
+
+ public static String getLocalHostAddress() {
+ if (LOCAL_HOST_ADDRESS != null) {
+ return LOCAL_HOST_ADDRESS;
+ }
+ try {
+ Enumeration interfaces = NetworkInterface.getNetworkInterfaces();
+ while (interfaces.hasMoreElements()) {
+ NetworkInterface netInterface = (NetworkInterface) interfaces.nextElement();
+ Enumeration addresses = netInterface.getInetAddresses();
+ while (addresses.hasMoreElements()) {
+ InetAddress address = (InetAddress) addresses.nextElement();
+ if (!address.isLoopbackAddress() && address.getHostAddress().indexOf(":") == -1) {
+ return address.getHostAddress();
+ }
+ }
+ }
+ } catch (SocketException e) {
+ throw new IllegalStateException("Could not find local addresses");
+ }
+ if (!notified) {
+ notified = true;
+ System.out.println("Using 127.0.0.1 as local address");
+ }
+ return "127.0.0.1";
+ }
+
+}
Added: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/OgoglioProperties.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/OgoglioProperties.java (rev 0)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/OgoglioProperties.java 2007-08-21 16:22:50 UTC (rev 255)
@@ -0,0 +1,74 @@
+package com.ogoglio.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+public class OgoglioProperties extends Properties {
+
+ public static final String PROPERTY_FILE_NAME = ".ogoglio-properties";
+ private static OgoglioProperties prop=null;
+
+ public static String WHICH_DB = "database_choice";
+ public static String WHICH_MYSQL = "mysql";
+ public static String WHICH_HSQL = "hsql";
+
+ // the reason these properties are duplicated is to make it easy to switch in the configuration
+ // file by changing only one line and leaving everything else in place
+ public static String MYSQL_DB_DIALECT = "database_mysql_hibernate_dialect";
+ public static String MYSQL_DB_DRIVER= "database_mysql_driver";
+
+ public static String MYSQL_DB_SERVER_URI = "database_mysql_server_uri";
+ public static String MYSQL_DB_SERVER_USER = "database_mysql_server_user";
+ public static String MYSQL_DB_SERVER_PASS = "database_mysql_server_pass";
+
+ public static String MYSQL_DB_TEST_URI = "database_mysql_test_uri";
+ public static String MYSQL_DB_TEST_USER = "database_mysql_test_user";
+ public static String MYSQL_DB_TEST_PASS = "database_mysql_test_pass";
+
+ public static String HSQL_DB_DIALECT = "database_hsql_hibernate_dialect";
+ public static String HSQL_DB_DRIVER= "database_hsql_driver";
+
+ public static String HSQL_DB_SERVER_URI = "database_hsql_server_uri";
+ public static String HSQL_DB_SERVER_USER = "database_hsql_server_user";
+ public static String HSQL_DB_SERVER_PASS = "database_hsql_server_pass";
+
+ public static String HSQL_DB_TEST_URI = "database_hsql_test_uri";
+ public static String HSQL_DB_TEST_USER = "database_hsql_test_user";
+ public static String HSQL_DB_TEST_PASS = "database_hsql_test_pass";
+
+ private OgoglioProperties() {
+
+ }
+
+ public static void validate() {
+ if (prop!=null) {
+ return;
+ }
+ //init
+ File f = new File(System.getProperty("user.home"),PROPERTY_FILE_NAME);
+ prop=new OgoglioProperties();
+ try {
+ prop.load(new FileInputStream(f));
+ } catch (FileNotFoundException e) {
+ System.err.println("Can't find ogoglio properties file ("+f.getPath()+"):"+e.getMessage());
+ System.exit(1);
+ } catch (IOException e) {
+ System.err.println("Error reading ogoglio properties file ("+f.getPath()+"):"+e.getMessage());
+ System.exit(1);
+ }
+ }
+
+ public static String getOgoglioProperty(String pname)
+ {
+ validate();
+ String result = prop.getProperty(pname,null);
+ if (result==null) {
+ System.out.println("Unable to locate property "+pname+" in your "+PROPERTY_FILE_NAME+" file! Aborting!");
+ System.exit(1);
+ }
+ return result;
+ }
+}
Added: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/PrepareDatabase.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/PrepareDatabase.java (rev 0)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/PrepareDatabase.java 2007-08-21 16:22:50 UTC (rev 255)
@@ -0,0 +1,95 @@
+package com.ogoglio.util;
+
+import java.net.URI;
+
+import org.hibernate.SessionFactory;
+
+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!=0) {
+ System.out.println("Dosen't take command line parameters, use the .ogoglio-properties file!");
+ System.exit(1);
+ }
+ PrepareDatabase db= new PrepareDatabase();
+ db.start(false);
+ db.start(true);
+ System.out.println("Completed successfully. DBs are now ready.");
+ }
+
+ public void setupSessionFactory(boolean isServer) {
+ String autoDDL = "create";
+
+ if (isServer) {
+ if (OgoglioProperties.getOgoglioProperty(OgoglioProperties.WHICH_DB).equals(OgoglioProperties.WHICH_MYSQL)) {
+ setupSessionFactory("com/ogoglio/persist/Persist.hbm.xml", autoDDL,
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.MYSQL_DB_DIALECT),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.MYSQL_DB_DRIVER),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.MYSQL_DB_SERVER_URI),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.MYSQL_DB_SERVER_USER),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.MYSQL_DB_SERVER_PASS),
+ "5");
+
+ } else {
+ setupSessionFactory("com/ogoglio/persist/Persist.hbm.xml", autoDDL,
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.HSQL_DB_DIALECT),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.HSQL_DB_DRIVER),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.HSQL_DB_SERVER_URI),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.HSQL_DB_SERVER_USER),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.HSQL_DB_SERVER_PASS),
+ "5");
+ }
+ } else {
+ if (OgoglioProperties.getOgoglioProperty(OgoglioProperties.WHICH_DB).equals(OgoglioProperties.WHICH_MYSQL)) {
+ setupSessionFactory("com/ogoglio/persist/Persist.hbm.xml", autoDDL,
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.MYSQL_DB_DIALECT),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.MYSQL_DB_DRIVER),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.MYSQL_DB_TEST_URI),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.MYSQL_DB_TEST_USER),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.MYSQL_DB_TEST_PASS),
+ "5");
+
+ } else {
+ setupSessionFactory("com/ogoglio/persist/Persist.hbm.xml", autoDDL,
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.HSQL_DB_DIALECT),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.HSQL_DB_DRIVER),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.HSQL_DB_TEST_URI),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.HSQL_DB_TEST_USER),
+ OgoglioProperties.getOgoglioProperty(OgoglioProperties.HSQL_DB_TEST_PASS),
+ "5");
+ }
+ }
+ }
+ public void start(boolean isServer) {
+ setupSessionFactory(isServer);
+ String host = "127.0.0.1";
+ String siteInfo = "http://"+host+":8080/og"; //configured in server.xml
+ SessionFactory sessionFactory = getSessionFactory();
+ System.out.println("start:"+isServer+": with session Factory:"+sessionFactory.toString());
+ try {
+ ServiceInitializationPersistTasks.initializeLocalSim(new URI(siteInfo), sessionFactory);
+ ServiceInitializationPersistTasks.initializeLibraryAccount(sessionFactory,host);
+ sessionFactory.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.err.println("Exception during attempt to init DB:\n"+e.getMessage());
+ }
+ }
+
+}
Added: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/StreamUtils.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/StreamUtils.java (rev 0)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/StreamUtils.java 2007-08-21 16:22:50 UTC (rev 255)
@@ -0,0 +1,85 @@
+/* Copyright 2007 Transmutable (http://transmutable.com/)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
+
+package com.ogoglio.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class StreamUtils {
+
+ public static final String readInput(InputStream input) throws IOException {
+ StringBuffer results = new StringBuffer();
+ byte[] buffer = new byte[2048];
+ int read = -1;
+ while ((read = input.read(buffer)) > 0) {
+ results.append(new String(buffer, 0, read));
+ }
+ input.close();
+ return results.toString();
+ }
+
+ public static final void write(String input, OutputStream output) throws IOException {
+ write(new ByteArrayInputStream(input.getBytes()), output);
+ }
+
+ public static void write(InputStream input, OutputStream output) throws IOException {
+ write(input, output, -1);
+ }
+
+ public static void write(InputStream input, OutputStream output, long maxLength) throws IOException {
+ byte[] buffer = new byte[2048];
+ int read = -1;
+ int totalRead = 0;
+ while ((read = input.read(buffer)) > 0) {
+ totalRead += read;
+ if (maxLength > -1 && totalRead > maxLength) {
+ throw new IOException("Exceded max length (" + maxLength + "): " + totalRead);
+ }
+ output.write(buffer, 0, read);
+ }
+ input.close();
+ output.flush();
+ output.close();
+ }
+
+ public static void copyResource(String resourceName, File destinationDir) throws IOException {
+ InputStream resourceStream = StreamUtils.class.getClassLoader().getResourceAsStream(resourceName);
+ if (resourceStream == null) {
+ throw new IOException("No such resource: " + resourceName);
+ }
+ write(resourceStream, new FileOutputStream(destinationDir), -1);
+ }
+
+ public static String readInput(InputStream input, int maxLength) throws IOException {
+ StringBuffer results = new StringBuffer();
+ byte[] buffer = new byte[2048];
+ int read = -1;
+ int totalRead = 0;
+ while ((read = input.read(buffer)) > 0) {
+ totalRead += read;
+ if (maxLength > -1 && totalRead > maxLength) {
+ throw new IOException("Exceded max length (" + maxLength + "): " + totalRead);
+ }
+ results.append(new String(buffer, 0, read));
+ }
+ input.close();
+ return results.toString();
+ }
+
+}
Added: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/TwoWayMap.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/TwoWayMap.java (rev 0)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/TwoWayMap.java 2007-08-21 16:22:50 UTC (rev 255)
@@ -0,0 +1,106 @@
+/* Copyright 2007 Transmutable (http://transmutable.com/)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
+
+package com.ogoglio.util;
+
+import java.util.HashMap;
+import java.util.Vector;
+
+public class TwoWayMap {
+
+ private HashMap forwardMap = new HashMap();
+
+ private HashMap backwardMap = new HashMap();
+
+ public synchronized void put(Object obj1, Object obj2) {
+ if (obj1 == null || obj2 == null) {
+ throw new IllegalArgumentException("Cannot add nulls");
+ }
+ forwardMap.put(obj1, obj2);
+ backwardMap.put(obj2, obj1);
+ }
+
+ public synchronized Object removeForward(Object key) {
+ Object obj2 = forwardMap.remove(key);
+ if (obj2 == null) {
+ return null;
+ }
+ backwardMap.remove(obj2);
+ return obj2;
+ }
+
+ public synchronized Object removeBackward(Object key) {
+ Object obj1 = backwardMap.remove(key);
+ if (obj1 == null) {
+ return null;
+ }
+ forwardMap.remove(obj1);
+ return obj1;
+ }
+
+ public synchronized Object getForward(Object obj1) {
+ return forwardMap.get(obj1);
+ }
+
+ public synchronized Object getBackward(Object obj2) {
+ return backwardMap.get(obj2);
+ }
+
+ public synchronized boolean containsForward(Object obj) {
+ return forwardMap.containsValue(obj);
+ }
+
+ public synchronized boolean containsBackward(Object obj) {
+ return backwardMap.containsValue(obj);
+ }
+
+ public synchronized Object[] getValues() {
+ return forwardMap.values().toArray();
+ }
+
+ public synchronized Object[] getValues(Filter keyFilter) {
+ Vector results = new Vector();
+ Object[] keys = forwardMap.keySet().toArray();
+ for (int i = 0; i < keys.length; i++) {
+ if (keyFilter.matches(keys[i])) {
+ results.add(forwardMap.get(keys[i]));
+ }
+ }
+ return results.toArray();
+ }
+
+ public Object[] getKeys() {
+ return forwardMap.keySet().toArray();
+ }
+
+ public Object[] getKeys(Filter valueFilter) {
+ Vector results = new Vector();
+ Object[] keys = forwardMap.keySet().toArray();
+ for (int i = 0; i < keys.length; i++) {
+ if (valueFilter.matches(forwardMap.get(keys[i]))) {
+ results.add(keys[i]);
+ }
+ }
+ return results.toArray();
+ }
+
+ public interface Filter {
+ public boolean matches(Object obj);
+ }
+
+ public long getSize() {
+ return forwardMap.size();
+ }
+
+}
Added: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/URLUTF8Encoder.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/URLUTF8Encoder.java (rev 0)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/util/URLUTF8Encoder.java 2007-08-21 16:22:50 UTC (rev 255)
@@ -0,0 +1,108 @@
+package com.ogoglio.util;
+
+/**
+ * From the excellent WWW Consortium: http://www.w3.org/
+ * Provides a method to encode any string into a URL-safe
+ * form.
+ * Non-ASCII characters are first encoded as sequences of
+ * two or three bytes, using the UTF-8 algorithm, before being
+ * encoded as %HH escapes.
+ */
+public class URLUTF8Encoder
+{
+
+ final static String[] hex = {
+ "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07",
+ "%08", "%09", "%0a", "%0b", "%0c", "%0d", "%0e", "%0f",
+ "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17",
+ "%18", "%19", "%1a", "%1b", "%1c", "%1d", "%1e", "%1f",
+ "%20", "%21", "%22", "%23", "%24", "%25", "%26", "%27",
+ "%28", "%29", "%2a", "%2b", "%2c", "%2d", "%2e", "%2f",
+ "%30", "%31", "%32", "%33", "%34", "%35", "%36", "%37",
+ "%38", "%39", "%3a", "%3b", "%3c", "%3d", "%3e", "%3f",
+ "%40", "%41", "%42", "%43", "%44", "%45", "%46", "%47",
+ "%48", "%49", "%4a", "%4b", "%4c", "%4d", "%4e", "%4f",
+ "%50", "%51", "%52", "%53", "%54", "%55", "%56", "%57",
+ "%58", "%59", "%5a", "%5b", "%5c", "%5d", "%5e", "%5f",
+ "%60", "%61", "%62", "%63", "%64", "%65", "%66", "%67",
+ "%68", "%69", "%6a", "%6b", "%6c", "%6d", "%6e", "%6f",
+ "%70", "%71", "%72", "%73", "%74", "%75", "%76", "%77",
+ "%78", "%79", "%7a", "%7b", "%7c", "%7d", "%7e", "%7f",
+ "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87",
+ "%88", "%89", "%8a", "%8b", "%8c", "%8d", "%8e", "%8f",
+ "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97",
+ "%98", "%99", "%9a", "%9b", "%9c", "%9d", "%9e", "%9f",
+ "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%a7",
+ "%a8", "%a9", "%aa", "%ab", "%ac", "%ad", "%ae", "%af",
+ "%b0", "%b1", "%b2", "%b3", "%b4", "%b5", "%b6", "%b7",
+ "%b8", "%b9", "%ba", "%bb", "%bc", "%bd", "%be", "%bf",
+ "%c0", "%c1", "%c2", "%c3", "%c4", "%c5", "%c6", "%c7",
+ "%c8", "%c9", "%ca", "%cb", "%cc", "%cd", "%ce", "%cf",
+ "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7",
+ "%d8", "%d9", "%da", "%db", "%dc", "%dd", "%de", "%df",
+ "%e0", "%e1", "%e2", "%e3", "%e4", "%e5", "%e6", "%e7",
+ "%e8", "%e9", "%ea", "%eb", "%ec", "%ed", "%ee", "%ef",
+ "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
+ "%f8", "%f9", "%fa", "%fb", "%fc", "%fd", "%fe", "%ff"
+ };
+
+ /**
+ * Encode a string to the "x-www-form-urlencoded" form, enhanced
+ * with the UTF-8-in-URL proposal. This is what happens:
+ *
+ * <ul>
+ * <li><p>The ASCII characters 'a' through 'z', 'A' through 'Z',
+ * and '0' through '9' remain the same.
+ *
+ * <li><p>The unreserved ch...
[truncated message content] |