You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(7) |
Jul
(26) |
Aug
(85) |
Sep
(141) |
Oct
(85) |
Nov
(60) |
Dec
(29) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(38) |
Feb
(78) |
Mar
(10) |
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <tre...@us...> - 2007-09-07 21:40:38
|
Revision: 386
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=386&view=rev
Author: trevorolio
Date: 2007-09-07 14:40:40 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
Tweaked db log.
Added javascript login functionality such that the usual authListeners can be bypassed.
Fixed createAccount.html, which was weirdly replaced with an old ogoglio.js contents (bad cut and paste)?
Made SpaceMemberRecord creation honor the role indicated by the incoming SpaceMemberDocument.
Fixed the hanging "Receiving items..." context menu for scriptless objects.
Changed page permissions so that editors can now post contents to them.
Modified Paths:
--------------
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpaceMemberPersistTasks.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpaceMemberRecord.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/createAccount.html
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpaceMemberPersistTasks.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpaceMemberPersistTasks.java 2007-09-07 21:40:36 UTC (rev 385)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpaceMemberPersistTasks.java 2007-09-07 21:40:40 UTC (rev 386)
@@ -61,7 +61,7 @@
return (SpaceMemberRecord[]) task.execute();
}
- public static SpaceMemberRecord createSpaceMember(final long spaceID, final String memberUsername, final boolean banned, SessionFactory sessionFactory) throws PersistException {
+ public static SpaceMemberRecord createSpaceMember(final long spaceID, final String memberUsername, final boolean banned, final int role, SessionFactory sessionFactory) throws PersistException {
HibernateTask task = new HibernateTask() {
public Object run(Session hibernateSession) {
Query accountQuery = hibernateSession.getNamedQuery(AccountPersistTasks.ACCOUNT_BY_USERNAME);
@@ -79,7 +79,7 @@
return null;
}
- record = new SpaceMemberRecord(spaceID, memberUsername, banned);
+ record = new SpaceMemberRecord(spaceID, memberUsername, banned, role);
hibernateSession.save(record);
return record;
}
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-09-07 21:40:36 UTC (rev 385)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpaceMemberRecord.java 2007-09-07 21:40:40 UTC (rev 386)
@@ -32,12 +32,13 @@
public SpaceMemberRecord() {
}
- public SpaceMemberRecord(long spaceID, String memberUsername, boolean banned) {
+ public SpaceMemberRecord(long spaceID, String memberUsername, boolean banned, int role) {
ArgumentUtils.assertNotNegative(spaceID);
this.spaceID = spaceID;
ArgumentUtils.assertNotNull(memberUsername);
this.memberUsername = memberUsername;
this.banned = banned;
+ setRole(role);
}
public boolean isBanned() {
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java 2007-09-07 21:40:36 UTC (rev 385)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java 2007-09-07 21:40:40 UTC (rev 386)
@@ -173,17 +173,24 @@
}
} else if (SpaceEvent.THING_CONTEXT_CLICKED_EVENT.equals(event.getName())) {
Long thingID = event.getLongProperty(SpaceEvent.THING_ID);
+ String shapeName = event.getStringProperty(SpaceEvent.SHAPE_NAME);
+ String username = event.getStringProperty(SpaceEvent.USERNAME);
+ long nonce = event.getLongProperty(SpaceEvent.NONCE).longValue();
+
+ SpaceEvent resultEvent = new SpaceEvent(SpaceEvent.CONTEXT_MENU_DATA_EVENT);
+ resultEvent.setProperty(SpaceEvent.NONCE, new Long(nonce));
+
if (thingID == null) {
+ spaceSimulator.getListener().generatedSpaceEventForUser(username, resultEvent, spaceSimulator);
return;
}
+
ScriptableObject thingScope = getThingScope(thingID.longValue());
if (thingScope == null) {
+ spaceSimulator.getListener().generatedSpaceEventForUser(username, resultEvent, spaceSimulator);
return;
}
- String shapeName = event.getStringProperty(SpaceEvent.SHAPE_NAME);
- String username = event.getStringProperty(SpaceEvent.USERNAME);
- long nonce = event.getLongProperty(SpaceEvent.NONCE).longValue();
String functionName = ONCONTEXTCLICK_FUNCTION_NAME;
@@ -191,9 +198,6 @@
functionArgs[0] = username;
functionArgs[1] = shapeName;
- SpaceEvent resultEvent = new SpaceEvent(SpaceEvent.CONTEXT_MENU_DATA_EVENT);
- resultEvent.setProperty(SpaceEvent.NONCE, new Long(nonce));
-
Context context = Context.enter();
try {
Object callResult = callJavascriptFunction(context, thingScope, functionName, functionArgs);
@@ -235,10 +239,12 @@
} else if (SpaceEvent.THING_CONTEXT_SELECTION_MADE_EVENT.equals(event.getName())) {
Long thingID = event.getLongProperty(SpaceEvent.THING_ID);
if (thingID == null) {
+ spaceSimulator.log("Context selection with no thing ID!");
return;
}
ScriptableObject thingScope = getThingScope(thingID.longValue());
if (thingScope == null) {
+ spaceSimulator.log("Context selection on a thing with no script!: " + thingID);
return;
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-09-07 21:40:36 UTC (rev 385)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-09-07 21:40:40 UTC (rev 386)
@@ -32,6 +32,7 @@
import com.ogoglio.appdev.servlet.SiteResource;
import com.ogoglio.client.DecoratedInputStream;
import com.ogoglio.media.MediaService;
+import com.ogoglio.persist.AccountPersistTasks;
import com.ogoglio.persist.AccountRecord;
import com.ogoglio.persist.SimPersistTasks;
import com.ogoglio.persist.SimRecord;
@@ -43,7 +44,6 @@
import com.ogoglio.sim.script.ScriptHTTPRequest;
import com.ogoglio.sim.script.ScriptHTTPResponse;
import com.ogoglio.site.AuthServlet;
-import com.ogoglio.site.AuthenticatedSiteResource;
import com.ogoglio.site.OgoglioServletBase;
import com.ogoglio.site.SpaceServlet;
import com.ogoglio.util.Log;
@@ -456,6 +456,13 @@
return;
}
+
+ AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
+ if (!SpacePersistTasks.canReadSpace(authedAccount, spaceID, getSessionFactory())) {
+ response.setStatus(HttpServletResponse.SC_FORBIDDEN);
+ return;
+ }
+
SpaceSimulator simulator = sim.getOrCreateSpaceSimulator(spaceRecord);
long thingID = Long.parseLong(pathElements[4]);
@@ -492,7 +499,7 @@
}
AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (authedAccount != null && !authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
+ if (!SpacePersistTasks.canWriteSpace(authedAccount, spaceID, getSessionFactory())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -765,17 +772,7 @@
}
public void doPost(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
- try {
- AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (authedAccount == null) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return;
- }
- doScriptService(request, response, pathElements);
- } catch (PersistException e) {
- e.printStackTrace();
- response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- }
+ doScriptService(request, response, pathElements);
}
public void doScriptService(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
@@ -890,7 +887,7 @@
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
-
+
AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
if (authedAccount != null && !SpacePersistTasks.canWriteSpace(authedAccount, requestedSpaceID, getSessionFactory())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
@@ -1048,7 +1045,7 @@
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
-
+
AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
if (authedAccount != null && !SpacePersistTasks.canWriteSpace(authedAccount, requestedSpaceID, getSessionFactory())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2007-09-07 21:40:36 UTC (rev 385)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2007-09-07 21:40:40 UTC (rev 386)
@@ -683,7 +683,7 @@
}
SpaceMemberDocument newMemberDoc = new SpaceMemberDocument(parseXML(request.getInputStream()));
- SpaceMemberRecord rec = SpaceMemberPersistTasks.createSpaceMember(spaceID, newMemberDoc.getMemberUsername(), newMemberDoc.isBanned(), getSessionFactory());
+ SpaceMemberRecord rec = SpaceMemberPersistTasks.createSpaceMember(spaceID, newMemberDoc.getMemberUsername(), newMemberDoc.isBanned(), newMemberDoc.getRoleAsInt(), getSessionFactory());
if (rec == null) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
Modified: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/createAccount.html
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/siteTemplates/createAccount.html 2007-09-07 21:40:36 UTC (rev 385)
+++ maven/trunk/ogoglio-server/src/main/resources/siteTemplates/createAccount.html 2007-09-07 21:40:40 UTC (rev 386)
@@ -1,775 +1,140 @@
-var appPath = "/og"; //do not put a slash on the end
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<link rel="stylesheet" href="style.css" type="text/css" />
+<script type="text/javascript" src="/og/ogoglio.js"></script>
+<script type="text/javascript" src="site.js"></script>
-function getServiceURI(){
- var locLink = document.location;
- return locLink.protocol + "//" + locLink.host + appPath;
-}
+<title>Ogoglio Example: create account</title>
-
-//BEGIN GENERAL UTILS
-function parseLocationParameters(){
- var paramPhrases = location.search.substring(1, location.search.length).split("&");
- var paramDict = new Object();
- for(var i=0; i < paramPhrases.length; i++){
- paramDict[paramPhrases[i].split("=")[0]] = paramPhrases[i].split("=")[1];
- }
- return paramDict;
+<style type="text/css">
+#main {
+ overflow: hidden;
+ width: 750px;
}
-var locationParameters = parseLocationParameters();
-
-function getFloatParameter(paramName, defaultValue){
- var value = locationParameters[paramName];
- if(typeof value == 'undefined' || value == null){
- return defaultValue;
- }
- try {
- return parseFloat(value);
- } catch (error){
- return defaultValue;
- }
+#content {
+ width: 750px;
+ border-right: 1px solid #FFF;
+ margin-right: 1px;
+ float: left;
}
-function getIntParameter(paramName, defaultValue){
- var value = locationParameters[paramName];
- if(typeof value == 'undefined' || value == null){
- return defaultValue;
- }
- try {
- return parseInt(value);
- } catch (error){
- return defaultValue;
- }
+.section form {
+ margin-top: 10px;
}
-var isIE = false;
-if (window.ActiveXObject) {
- isIE = true;
+.section {
+ border: solid 1px #CCD;
+ border-top: solid 5px #CCD;
+ margin: 0px 25px 10px 0px;
+ padding: 0px 5px 5px 5px;
}
-function XMLRequestManager(theURL, theListener){
- var that = this;
- this.url = theURL;
- this.listener = theListener;
- this.request = getXMLHttpRequest();
- this.method = "GET";
-
- function processRequestChange() {
- if(that.request.readyState == 4){
- if(that.request.status == 200){
- if(that.request.responseXML && that.request.responseXML.documentElement && that.listener.handleResponseXML ){
- that.listener.handleResponseXML(that.request.responseXML);
- } else if(that.request.responseText != "undefined" && that.listener.handleResponseText){
- that.listener.handleResponseText(that.request.responseText);
- } else {
- that.listener.handleFailure("Found the file, but it is not a handled type (text or xml)");
- }
- } else {
- that.listener.handleFailure(that.request.statusText);
- }
- }
- }
- this.request.onreadystatechange = processRequestChange;
+#profileTable th {
+ text-align: right;
}
-XMLRequestManager.prototype.setMethod = function (newMethod) {
- this.method = newMethod;
+.includedFeedItem {
+ margin-top: 10px;
}
+</style>
+<script type="text/javascript">
-XMLRequestManager.prototype.send = function (data, contentType) {
- if(this.method == "DELETE"){ //a workaround for WebKit's tendency to do only GET and POST
- if(this.url.indexOf("?") == -1){
- this.url += "?method=DELETE";
- } else {
- this.url += "&method=DELETE";
- }
- }
-
- this.request.open(this.method, this.url, true);
- if(data){
- if(contentType != null){
- this.request.setRequestHeader('Content-Type', contentType);
- } else {
- this.request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
- }
- this.request.send(data);
- } else if(isIE){
- this.request.send();
- } else {
- this.request.send(null);
- }
-}
+var mainElement = null;
+var newUserDiv = null;
-
-function BasicHTTPListener(callbackFunction) {
- this.callback = callbackFunction;
-}
-
-BasicHTTPListener.prototype.handleResponseXML = function (responseXML) {
- this.callback(responseXML.documentElement);
-}
-
-BasicHTTPListener.prototype.handleResponseText = function (responseText) {
- this.callback(responseText);
-}
-
-BasicHTTPListener.prototype.handleFailure = function (statusText) {
- this.callback(null);
-}
-
-function getXMLHttpRequest(){
- if (window.XMLHttpRequest) {
- return new XMLHttpRequest();
- } else if (window.ActiveXObject) {
- return new ActiveXObject("Microsoft.XMLHTTP");
- }
- return null;
-}
-
-function getFirstChildByTagName(localName, parentNode){
- var children = parentNode.childNodes;
- for(var i=0; children[i]; i++){
- if(children[i].name == localName || children[i].nodeName == localName || children[i].localName == localName){
- return children[i];
- }
- }
-}
-
-function trim(str) {
- return str.replace(/^\s*|\s*$/g,"");
-}
-
-function shorten(str, len){
- if(typeof str == "undefined" || str == null || str.length <= len){
- return str;
- }
- return str.substring(0, len);
-}
-
-function trimPX(value){
- if(value.indexOf("px") != -1){
- value = value.substring(0, value.indexOf("px"));
- }
- return value;
-}
-
-function clip(text, maxLength, elipseText){
- var eLength = elipseText == null ? 0 : elipseText.length;
- if(text == null || text.length <= maxLength){
- return text;
- }
- return text.substring(0, maxLength - eLength) + (elipseText == null ? "" : elipseText);
-}
-
-function popUp(URL, decorated, width, height) {
- var id = "page-" + new Date().getTime();
- var params = "";
- if(typeof width != "undefined"){
- params += ",width=" + width;
- }
- if(typeof height != undefined){
- params += ",height=" + height;
- }
- if(decorated == null || decorated == true){
- params += ',toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1';
- }
- return window.open(URL, id, params);
-}
-
-function getCookie(name) {
- var dc = document.cookie;
- var prefix = name + "=";
- var begin = dc.indexOf("; " + prefix);
- if (begin == -1) {
- begin = dc.indexOf(prefix);
- if (begin != 0) return null;
- } else {
- begin += 2;
- }
- var end = document.cookie.indexOf(";", begin);
- if (end == -1) {
- end = dc.length;
- }
- return unescapeHTML(dc.substring(begin + prefix.length, end));
-}
-
-function debug(message){
- var debugDiv = document.getElementById('debugMessages');
- if(debugDiv == null || typeof debugDiv == "undefined"){
+function handleAuth(){
+ if(authedUsername == null){
+ mainElement.innerHTML = "<h2>You must log in as an admin.</h2>";
return;
}
- debugDiv.innerHTML += message + "<br/>";
+ requestAccountDocument(authedUsername, handleAdminTest);
}
-//this only serializes simple XML and it casts all tag and attribute names to lower case
-//TODO handle all the various warts of XML
-function serializeXML(xml){
- var result = "<" + xml.tagName.toLowerCase();
- var attributes = xml.attributes;
- for (var i = 0; i < attributes.length; i++){
- result += " " + attributes.item(i).name.toLowerCase() + "='" + escapeHTML(attributes.item(i).value) + "'";
- }
- var hasText = (typeof xml.text != "undefined") && xml.text.length != 0;
-
- if(!hasText && xml.childNodes.length == 0){
- result += " />";
-
- return result;
- } else {
- result += ">";
- }
-
- if(hasText){
- result += xml.text;
- }
-
- for(var i = 0; i < xml.childNodes.length; i++){
- result += serializeXML(xml.childNodes[i]);
- }
- result += "</" + xml.tagName.toLowerCase() + ">";
- return result;
-}
-
-function escapeHTML(xml){
- if(xml == null || xml.length == 0){
- return xml;
- }
- return xml.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
-};
-
-function unescapeHTML(xml){
- return xml.replace(/'/g,"'").replace(/"/g,"\"").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&");
-};
-
-// BEGIN QUATERION CLASS
-
-function Quaternion(wValue, xValue, yValue, zValue){
- this.w = wValue;
- this.x = xValue;
- this.y = yValue;
- this.z = zValue;
- this.normalize();
-}
-
-Quaternion.prototype.set = function(wValue, xValue, yValue, zValue){
- this.w = wValue;
- this.x = xValue;
- this.y = yValue;
- this.z = zValue;
- this.normalize();
-}
-
-Quaternion.prototype.normalize = function(){
- var norm = (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
-
- if (norm > 0.0) {
- norm = 1.0 / Math.sqrt(norm);
- this.x *= norm;
- this.y *= norm;
- this.z *= norm;
- this.w *= norm;
- } else {
- this.x = 0.0;
- this.y = 0.0;
- this.z = 0.0;
- this.w = 0.0;
- }
-}
-
-Quaternion.prototype.mul = function(q1){
- var nw = this.w * q1.w - this.x * q1.x - this.y * q1.y - this.z * q1.z;
- var nx = this.w * q1.x + q1.w * this.x + this.y * q1.z - this.z * q1.y;
- var ny = this.w * q1.y + q1.w * this.y - this.x * q1.z + this.z * q1.x;
- this.z = this.w * q1.z + q1.w * this.z + this.x * q1.y - this.y * q1.x;
- this.w = nw;
- this.x = nx;
- this.y = ny;
- this.normalize();
-}
-
-Quaternion.prototype.rotateEuler = function(rotX, rotY, rotZ){
- var quat = new Quaternion(1, 0, 0, 0);
- quat.setEuler(rotX, rotY, rotZ);
- this.mul(quat);
-}
-
-Quaternion.prototype.toString = function(){
- return "<" + this.w + ", " + this.x + ", " + this.y + ", " + this.z + ">";
-}
-
-Quaternion.prototype.setEuler = function(rotX, rotY, rotZ){
- var c1 = Math.cos(rotY / 2);
- var c2 = Math.cos(rotX / 2);
- var c3 = Math.cos(rotZ / 2);
- var s1 = Math.sin(rotY / 2);
- var s2 = Math.sin(rotX / 2);
- var s3 = Math.sin(rotZ / 2);
-
- this.w = (c1 * c2 * c3) - (s1 * s2 * s3);
- this.x = (s1 * s2 * c3) + (c1 * c2 * s3);
- this.y = (s1 * c2 * c3) + (c1 * s2 * s3);
- this.z = (c1 * s2 * c3) - (s1 * c2 * s3);
- this.normalize();
-}
-
-Quaternion.prototype.getEuler = function(){
- var heading = 0;
- var attitude = 0;
- var bank = 0;
- if(this.x * this.y + this.z * this.w == 0.5){ //North Pole
- attitude = Math.PI / 2;
- bank = 0;
- heading = 2 * Math.atan2(this.x, this.w);
- } else if (this.x * this.y + this.z * this.w == -0.5) { // South Pole
- attitude = -Math.PI / 2;
- heading = -2 * Math.atan2(this.x, this.w)
- bank = 0;
- } else {
- heading = Math.atan2(2 * this.y * this.w - 2 * this.x * this.z, 1 - 2 * (this.y * this.y) - 2 * (this.z * this.z)) % (2 * Math.PI);
- attitude = Math.asin(2 * this.x * this.y + 2 * this.z * this.w) % (2 * Math.PI);
- bank = Math.atan2(2 * this.x * this.w - 2 * this.y * this.z , 1 - 2 * (this.x * this.x) - 2 * (this.z * this.z)) % (2 * Math.PI);
- }
- return new Array(cleanRotation(attitude), cleanRotation(heading), cleanRotation(bank));
-}
-
-function cleanRotation(rotation){ //in radians
- while(rotation < 0){
- rotation += 2 * Math.PI;
- }
- while(rotation >= 2 * Math.PI){
- rotation -= 2 * Math.PI;
- }
- if(rotation < 0.0001){
- return 0;
- }
- return rotation.toFixed(4);
-}
-
-//BEGIN AUTH UTILS
-
-var completedAuthRequest = false;
-var authedUsername = null;
-var authedUserLevel = null;
-var errorText = null;
-
-
-function logout(){
- var logoutRequestManager = new XMLRequestManager(appPath + "/auth?logout=true", new AuthListener());
- logoutRequestManager.send();
-}
-
-function addAuthListeners(authFunction, failedFunction){
- authedListeners[authedListeners.length] = authFunction;
- failedListeners[failedListeners.length] = failedFunction;
- if(completedAuthRequest){
- if(authedUsername == null){
- failedFunction();
- } else {
- authFunction();
- }
- }
-}
-
-var authedListeners = new Array();
-var failedListeners = new Array();
-
-function AuthListener() {
-}
-
-AuthListener.prototype.handleResponseXML = function (responseXML) {
- var xmlDoc = responseXML.documentElement;
- var successAttribute = xmlDoc.getAttribute('authenticated');
- var idAttribute = xmlDoc.getAttribute('username');
- var levelAttribute = xmlDoc.getAttribute('accountlevel');
-
- if(successAttribute == "true" && typeof idAttribute != "undefined" && typeof levelAttribute != "undefined") {
- authedUsername = idAttribute;
- authedUserLevel = levelAttribute;
-
- for(var i=0; i < authedListeners.length; i++){
- authedListeners[i]();
- }
- completedAuthRequest = true;
- } else {
- authedUsername = null;
- for(var i=0; i < authedListeners.length; i++){
- authedListeners[i]();
- }
- completedAuthRequest = true;
- }
-}
-
-AuthListener.prototype.handleFailure = function (statusText) {
- for(var i=0;i < failedListeners.length; i++){
- failedListeners[i]();
- }
- errorText = statusText;
- completedAuthRequest = true;
- authedUsername = null;
-}
-
-var authRequestManager = new XMLRequestManager(appPath + "/auth", new AuthListener());
-authRequestManager.send();
-
-function login(username, password){
- if(!username || trim(username).length == 0 || !password || trim(password).length == 0){
+function handleAdminTest(xml){
+ if(xml == null){
+ mainElement.innerHTML = "<h2>There was an error checking your account for admin access.</h2>";
return;
}
-
- var manager = new XMLRequestManager(appPath + "/auth", new AuthListener());
-
- manager.setMethod("POST");
- manager.send("username=" + trim(username) + "&password=" + trim(password));
-}
-
-function requestMyAuthDocument(listener){
- new XMLRequestManager(appPath + "/auth/me", new BasicHTTPListener(listener)).send();
-}
-
-function requestGuestCookie(listener){
- var manager = new XMLRequestManager(appPath + "/auth/guest", new BasicHTTPListener(listener));
- manager.setMethod("POST");
- manager.send();
-}
-
-// BEGIN ACCOUNT UTILS
-
-function createAccount(username, email, listener){
- var xml = document.createElement("account");
- xml.setAttribute("username", username);
- xml.setAttribute("email", email);
- xml.setAttribute("accountlevel", "basic");
- var manager = new XMLRequestManager(appPath + "/account/", new BasicHTTPListener(listener));
- manager.setMethod("POST");
- manager.send(serializeXML(xml));
-}
-
-function requestAccountDocument(username, listener){
- var accountListener = new BasicHTTPListener(listener);
- new XMLRequestManager(appPath + "/account/" + username, accountListener).send();
-}
-
-function updateAccountDocument(accountXML, listener){
- if(accountXML == null){
+ if("admin" != xml.getAttribute("accountlevel")){
+ mainElement.innerHTML = "<h2>You must be an admin to use this page.</h2>";
return;
}
- var username = accountXML.getAttribute("username");
- var accountListener = new BasicHTTPListener(listener);
- var manager = new XMLRequestManager(appPath + "/account/" + username, accountListener);
- manager.setMethod("POST");
- var xmlString = serializeXML(accountXML);
- manager.send(xmlString);
-}
-
-function requestAccountMembership(username, listener){
- new XMLRequestManager(appPath + "/account/" + username + "/membership", new BasicHTTPListener(listener)).send();
-}
-
-function validate(secret, listener){
- new XMLRequestManager(appPath + "/account/validate?secret=" + secret, new BasicHTTPListener(listener)).send();
-}
-
-// BEGIN SPACE UTILS
-
-function requestSpaceList(username, listener){
- new XMLRequestManager(appPath + "/account/" + username + "/space/", new BasicHTTPListener(listener)).send();
-}
-
-function requestSpaceDocument(spaceID, listener){
- new XMLRequestManager(appPath + "/space/" + spaceID, new BasicHTTPListener(listener)).send();
-}
-
-function requestSpaceMembers(spaceID, listener){
- new XMLRequestManager(appPath + "/space/" + spaceID + "/member", new BasicHTTPListener(listener)).send();
-}
-
-function addSpaceMember(spaceID, memberUsername, role, listener){
- var memberXML = document.createElement("spacemember");
- memberXML.setAttribute("spaceid", spaceID);
- memberXML.setAttribute("memberusername", memberUsername);
- memberXML.setAttribute("role", role);
- memberXML.setAttribute("banned", false);
- var manager = new XMLRequestManager(appPath + "/space/" + spaceID + "/member/", new BasicHTTPListener(listener));
- manager.setMethod("POST");
- manager.send(serializeXML(memberXML));
-}
-
-function removeSpaceMember(spaceID, memberUsername, listener){
- var manager = new XMLRequestManager(appPath + "/space/" + spaceID + "/member/" + memberUsername, new BasicHTTPListener(listener));
- manager.setMethod("DELETE");
- manager.send();
-}
-
-function updateMemberRole(spaceID, memberUsername, newRole, listener){
- var memberXML = document.createElement("spacemember");
- memberXML.setAttribute("spaceid", spaceID);
- memberXML.setAttribute("memberusername", memberUsername);
- memberXML.setAttribute("role", newRole);
- memberXML.setAttribute("banned", false);
- var manager = new XMLRequestManager(appPath + "/space/" + spaceID + "/member/" + memberUsername, new BasicHTTPListener(listener));
- manager.setMethod("POST");
- manager.send(serializeXML(memberXML));
-}
-
-function createSpace(username, spaceName, listener){
- var bodyXML = document.createElement("space");
- bodyXML.setAttribute("ownerusername", username);
- bodyXML.setAttribute("displayname", escapeHTML(spaceName));
- var manager = new XMLRequestManager(appPath + "/space/", new BasicHTTPListener(listener));
- manager.setMethod("POST");
- manager.send(serializeXML(bodyXML));
-}
-
-function deleteSpace(spaceID, listener){
- var req = new XMLRequestManager(appPath + "/space/" + spaceID, new BasicHTTPListener(listener));
- req.setMethod("DELETE");
- req.send();
-}
-
-function updateSpaceDocument(xml, listener){
- if(xml == null){
- return;
- }
- var spaceID = xml.getAttribute("spaceid");
-
- var spaceListener = new BasicHTTPListener(listener);
- var manager = new XMLRequestManager(appPath + "/space/" + spaceID, spaceListener);
- manager.setMethod("POST");
- manager.send(serializeXML(xml));
-}
-
-function requestUserList(spaceID, listener){
- new XMLRequestManager(appPath + "/space/" + spaceID + "/user", new BasicHTTPListener(listener)).send();
-}
-
-function bootUser(spaceID, username, listener){
- var req = new XMLRequestManager(appPath + "/space/" + spaceID + "/user/" + username, new BasicHTTPListener(listener));
- req.setMethod("DELETE");
- req.send();
-}
-
-function requestSettingList(spaceID, listener){
- new XMLRequestManager(appPath + "/space/" + spaceID + "/setting", new BasicHTTPListener(listener)).send();
-}
-
-function requestSetting(spaceID, key, listener){
- new XMLRequestManager(appPath + "/space/" + spaceID + "/setting/" + key, new BasicHTTPListener(listener)).send();
-}
-
-function updateSetting(spaceID, key, value, listener){
- var manager = new XMLRequestManager(appPath + "/space/" + spaceID + "/setting/" + key, new BasicHTTPListener(listener));
- manager.setMethod("POST");
- manager.send("value=" + value);
+ writeNewUserForm();
}
-function removeSetting(spaceID, key, listener){
- var manager = new XMLRequestManager(appPath + "/space/" + spaceID + "/setting/" + key, new BasicHTTPListener(listener));
- manager.setMethod("DELETE");
- manager.send();
+function writeNewUserForm(){
+ var html = "<form id='newUserForm' onsubmit='newUserGo(); return false;'>";
+ html += "<table>"
+ html += "<tr><th>username:</th><td><input type='text' name='username' /></td><td> all lower case, number and letters</td></tr>"
+ html += "<tr><th>email:</th><td><input type='text' name='email' /></td><td></td></tr>"
+ html += "<tr><th>password:</th><td><input type='text' name='password' /></td><td></td></tr>"
+ html += "<tr><td></td><td><input type='submit' value='create account' /></td></tr>";
+ html += "</form>";
+ newUserDiv.innerHTML = html;
}
-
-// BEGIN TEMPLATE UTILS
-function requestTemplateList(username, listener){
- new XMLRequestManager(appPath + "/account/" + username + "/template/", new BasicHTTPListener(listener)).send();
-}
-
-function requestTemplate(username, templateID, listener){
- new XMLRequestManager(appPath + "/account/" + username + "/template/" + templateID, new BasicHTTPListener(listener)).send();
-}
-
-function createTemplate(username, templateName, listener){
- var xml = document.createElement("template");
- xml.setAttribute("ownerusername", username);
- xml.setAttribute("displayname", escapeHTML(templateName));
- var manager = new XMLRequestManager(appPath + "/account/" + username + "/template/", new BasicHTTPListener(listener));
- manager.setMethod("POST");
- manager.send(serializeXML(xml));
-}
-
-function updateTemplate(xml, listener){
- if(xml == null){
+function newUserGo(){
+ var form = document.getElementById("newUserForm");
+ if(form == null){
return;
}
- var username = xml.getAttribute("ownerusername");
- var templateID = xml.getAttribute("templateid");
-
- var manager = new XMLRequestManager(appPath + "/account/" + username + "/template/" + templateID, new BasicHTTPListener(listener));
- manager.setMethod("POST");
- manager.send(serializeXML(xml));
+ var username = form.username.value;
+ var email = form.email.value;
+ var password = form.password.value;
+ createAccount(username, email, password, handleNewAccount);
}
-function requestTemplateScript(username, templateID, listener){
- new XMLRequestManager(appPath + "/account/" + username + "/template/" + templateID + "/script/", new BasicHTTPListener(listener)).send();
-}
-
-function updateTemplateScript(username, templateID, script, listener){
- var manager = new XMLRequestManager(appPath + "/account/" + username + "/template/" + templateID + "/script/", new BasicHTTPListener(listener));
- manager.setMethod("POST");
- manager.send(script, "text/plain");
-}
-
-function requestTemplates(idArray, listener){
- if(idArray.length == 0){
- return;
- }
- var idPathElement = "";
- for(var i = 0; i < idArray.length; i++){
- idPathElement += idArray[i];
- if(i != idArray.length - 1){
- idPathElement += ",";
- }
- }
- new XMLRequestManager(appPath + "/account/template/" + idPathElement, new BasicHTTPListener(listener)).send();
-}
-
-// BEGIN THING UTILS
-
-function requestThing(spaceID, thingID, listener){
- new XMLRequestManager(appPath + "/space/" + spaceID + "/thing/" + thingID, new BasicHTTPListener(listener)).send();
-}
-
-function requestThingList(spaceID, listener){
- new XMLRequestManager(appPath + "/space/" + spaceID + "/thing", new BasicHTTPListener(listener)).send();
-}
-
-function updateThing(spaceID, xml, listener){
+function handleNewAccount(xml){
if(xml == null){
- return;
+ alert("Could not create that account.");
+ } else {
+ document.location.href = "admin.html?username=" + xml.getAttribute('username');
}
- var thingID = xml.getAttribute("thingid");
- var manager = new XMLRequestManager(appPath + "/space/" + spaceID + "/thing/" + thingID, new BasicHTTPListener(listener));
- manager.setMethod("POST");
- manager.send(serializeXML(xml));
}
-function reloadThing(spaceID, thingID){
- var nullFunction = function(xml) {};
- new XMLRequestManager(appPath + "/space/" + spaceID + "/thing/" + thingID + "?reload=true", new BasicHTTPListener(nullFunction)).send();
-}
+function init(){
+ populateMemberMenuItem();
-// BEGIN PAGE UTILS
-
-function requestPage(spaceID, thingID, pageID, listener){
- new XMLRequestManager(appPath + "/space/" + spaceID + "/thing/" + thingID + "/page/" + pageID, new BasicHTTPListener(listener)).send();
-}
-
-function requestPageList(spaceID, thingID, listener){
- new XMLRequestManager(appPath + "/space/" + spaceID + "/thing/" + thingID + "/page/", new BasicHTTPListener(listener)).send();
-}
-
-function createPage(spaceID, thingID, width, height, contentType, listener){
- var manager = new XMLRequestManager(appPath + "/space/" + spaceID + "/thing/" + thingID + "/page/", new BasicHTTPListener(listener));
- manager.setMethod("POST");
- var xml = document.createElement("page");
- xml.setAttribute("contenttype", contentType);
- xml.setAttribute("width", width);
- xml.setAttribute("height", height);
- manager.send(serializeXML(xml));
-}
-
-// BEGIN DOOR UTILS
-
-function requestDoorList(spaceID, listener){
- new XMLRequestManager(appPath + "/space/" + spaceID + "/door/", new BasicHTTPListener(listener)).send();
-}
-
-function requestDoor(spaceID, doorID, listener){
- new XMLRequestManager(appPath + "/space/" + spaceID + "/door/" + doorID + "/", new BasicHTTPListener(listener)).send();
-}
-
-function createDoor(spaceID, displayName, templateID, templateOwner, link, listener){
- var xml = document.createElement("door");
- xml.setAttribute("displayname", escapeHTML(displayName));
- xml.setAttribute("templateid", templateID);
- xml.setAttribute("templateowner", templateOwner);
- xml.setAttribute("link", link);
- var manager = new XMLRequestManager(appPath + "/space/" + spaceID + "/door/", new BasicHTTPListener(listener));
- manager.setMethod("POST");
- manager.send(serializeXML(xml));
-}
-
-function updateDoor(spaceID, xml, listener){
- if(xml == null){
- return;
- }
- var id = xml.getAttribute("doorid");
- var manager = new XMLRequestManager(appPath + "/space/" + spaceID + "/door/" + id, new BasicHTTPListener(listener));
- manager.setMethod("POST");
- manager.send(serializeXML(xml));
-}
-
-
-// BEGIN BODY UTILS
-
-function requestBodyList(username, listener){
- var httpListener = new BasicHTTPListener(listener);
- new XMLRequestManager(appPath + "/account/" + username + "/body/", httpListener).send();
-}
-
-function requestBodyDocument(username, bodyID, listener){
- var httpListener = new BasicHTTPListener(listener);
- new XMLRequestManager(appPath + "/account/" + username + "/body/" + bodyID, httpListener).send();
-}
-
-function createBody(username, bodyName, listener){
- var bodyXML = document.createElement("body");
- bodyXML.setAttribute("ownerusername", username);
- bodyXML.setAttribute("displayname", bodyName);
- var manager = new XMLRequestManager(appPath + "/account/" + username + "/body/", new BasicHTTPListener(listener));
- manager.setMethod("POST");
- manager.send(serializeXML(bodyXML));
-}
-
-function updateBodyDocument(xml, listener){
- if(xml == null){
- return;
- }
- var username = xml.getAttribute("ownerusername");
- var bodyID = xml.getAttribute("bodyid");
- var httpListener = new BasicHTTPListener(listener);
- var manager = new XMLRequestManager(appPath + "/account/" + username + "/body/" + bodyID, httpListener);
- manager.setMethod("POST");
- var xmlString = serializeXML(xml);
- manager.send(xmlString);
-}
-
-// BEGIN POSSESSION UTILS
-
-function requestPossession(username, possessionID, listener){
- new XMLRequestManager(appPath + "/account/" + username + "/possession/" + possessionID, new BasicHTTPListener(listener)).send();
-}
-
-function requestPossessionList(username, listener){
- new XMLRequestManager(appPath + "/account/" + username + "/possession/", new BasicHTTPListener(listener)).send();
-}
-
-function createPossession(username, templateID, listener){
- var possXML = document.createElement("possession");
- possXML.setAttribute("ownerusername", username);
- possXML.setAttribute("templateid", templateID);
- var manager = new XMLRequestManager(appPath + "/account/" + username + "/possession/", new BasicHTTPListener(listener));
- manager.setMethod("POST");
- manager.send(serializeXML(possXML));
-}
-
-function updatePossession(possXML, listener){
- var username = possXML.getAttribute('ownerusername');
- var possID = possXML.getAttribute('possessionid');
- if(username == null || possID == null){
- return;
- }
+ mainElement = document.getElementById("main");
+ newUserDiv = document.getElementById("newUserDiv");
- var manager = new XMLRequestManager(appPath + "/account/" + username + "/possession/" + possID, new BasicHTTPListener(listener));
- manager.setMethod("POST");
- manager.send(serializeXML(possXML));
+ addAuthListeners(handleAuth, handleAuth);
}
+</script>
+</head>
+<body onload="init();">
+<div id="header">
+ <strong><a href="index.html">Ogoglio Example</a></strong>
+ <span id="search">
+ <!-- <form style="margin: 0px;" method="get" action="http://www.google.com/search">
+ <input type="text" size="20" name="q"/>
+ <input type="hidden" name="q" value="site:example.com"/>
+ <input type="submit" value="find"/>
+ </form> -->
+ </span>
+</div> <!-- end header -->
-function deletePossession(username, possessionID, listener){
- var manager = new XMLRequestManager(appPath + "/account/" + username + "/possession/" + possessionID, new BasicHTTPListener(listener));
- manager.setMethod("DELETE");
- manager.send();
-}
+<div id="headerMenu">
+ <a href="index.html">Home</a>
+ <span id="memberMenuItem"> </span>
+</div> <!-- end header menu -->
-// 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.
+<div id="main">
+ <h2 style="color: #4F4;">Create User:</h2>
+
+ <div id="content">
+ <div class="section">
+ <div id="newUserDiv">
+ </div>
+ </div>
+ </div><!-- end content -->
+</div> <!-- end main -->
+<div id="footer">
+
+</div>
+<!-- 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.-->
+</body>
+</html>
\ No newline at end of file
Modified: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js 2007-09-07 21:40:36 UTC (rev 385)
+++ maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js 2007-09-07 21:40:40 UTC (rev 386)
@@ -422,13 +422,14 @@
var authRequestManager = new XMLRequestManager(appPath + "/auth", new AuthListener());
authRequestManager.send();
-function login(username, password){
+function login(username, password, optionalHandlerFunction){
if(!username || trim(username).length == 0 || !password || trim(password).length == 0){
return;
}
-
- var manager = new XMLRequestManager(appPath + "/auth", new AuthListener());
+ var listener = optionalHandlerFunction == null ? new AuthListener() : new BasicHTTPListener(optionalHandlerFunction);
+ var manager = new XMLRequestManager(appPath + "/auth", listener);
+
manager.setMethod("POST");
manager.send("username=" + trim(username) + "&password=" + trim(password));
}
@@ -445,10 +446,11 @@
// BEGIN ACCOUNT UTILS
-function createAccount(username, email, listener){
+function createAccount(username, email, password, listener){
var xml = document.createElement("account");
xml.setAttribute("username", username);
xml.setAttribute("email", email);
+ xml.setAttribute("password", password);
xml.setAttribute("accountlevel", "basic");
var manager = new XMLRequestManager(appPath + "/account/", new BasicHTTPListener(listener));
manager.setMethod("POST");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-07 21:40:33
|
Revision: 385
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=385&view=rev
Author: trevorolio
Date: 2007-09-07 14:40:36 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
Tweaked db log.
Added javascript login functionality such that the usual authListeners can be bypassed.
Fixed createAccount.html, which was weirdly replaced with an old ogoglio.js contents (bad cut and paste)?
Made SpaceMemberRecord creation honor the role indicated by the incoming SpaceMemberDocument.
Fixed the hanging "Receiving items..." context menu for scriptless objects.
Changed page permissions so that editors can now post contents to them.
Modified Paths:
--------------
maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/servlet/MigratedResourceServlet.java
Modified: maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/servlet/MigratedResourceServlet.java
===================================================================
--- maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/servlet/MigratedResourceServlet.java 2007-09-07 21:20:08 UTC (rev 384)
+++ maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/servlet/MigratedResourceServlet.java 2007-09-07 21:40:36 UTC (rev 385)
@@ -13,32 +13,36 @@
public abstract class MigratedResourceServlet extends AbstractResourceServlet {
private static final String HIBERNATE_SESSION_FACTORY_KEY = "com.ogoglio.hibernateSessionFactory";
+
private SessionFactory hibernateSessionFactory = null;
- public abstract MigrationSupport getMigration();
-
+
+ public abstract MigrationSupport getMigration();
+
public void init(ServletConfig config) throws ServletException {
- try {
- initBaseUrl();
- Context envCtx = (Context) initCtx.lookup("java:comp/env");
- hibernateSessionFactory = getOrCreateHibernateSessionFactory(config,envCtx);
- if (hibernateSessionFactory==null) {
- throw new IllegalStateException("Unable to create sensible hibernate configuration!");
- }
-
- //CALL THIS LAST
- super.init(config);
- } catch (NamingException e) {
- throw new ServletException("Unable to initialize Migrated resource servlet:"+e.getMessage());
- }
+ try {
+ initBaseUrl();
+ Context envCtx = (Context) initCtx.lookup("java:comp/env");
+ hibernateSessionFactory = getOrCreateHibernateSessionFactory(config, envCtx);
+ if (hibernateSessionFactory == null) {
+ throw new IllegalStateException("Unable to create sensible hibernate configuration!");
+ }
+
+ //CALL THIS LAST
+ super.init(config);
+ } catch (NamingException e) {
+ throw new ServletException("Unable to initialize Migrated resource servlet:" + e.getMessage());
+ }
}
+
public void destroy() {
- super.destroy();
+ super.destroy();
try {
hibernateSessionFactory.close();
} catch (Throwable e) {
}
super.destroy();
}
+
public SessionFactory getSessionFactory() {
return hibernateSessionFactory;
}
@@ -46,16 +50,16 @@
private SessionFactory getOrCreateHibernateSessionFactory(ServletConfig config, Context context) {
SessionFactory sessionFactory = (SessionFactory) config.getServletContext().getAttribute(HIBERNATE_SESSION_FACTORY_KEY);
if (sessionFactory == null) {
- Log.info(config.getServletName()+" checking DB Version...");
- MigrationSupport ms= getMigration();
- if (!ms.verifyVersion(config,context)) {
- throw new IllegalStateException("Cannot find a DB configuration for hibernate!");
- }
- sessionFactory= ms.getCurrentConfiguration().configure().buildSessionFactory();
+ Log.test(config.getServletName() + ": checking DB version");
+ MigrationSupport ms = getMigration();
+ if (!ms.verifyVersion(config, context)) {
+ throw new IllegalStateException("Cannot find a DB configuration for hibernate!");
+ }
+ sessionFactory = ms.getCurrentConfiguration().configure().buildSessionFactory();
config.getServletContext().setAttribute(HIBERNATE_SESSION_FACTORY_KEY, sessionFactory);
+ Log.test(config.getServletName() + ": DB version OK");
}
return sessionFactory;
}
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2007-09-07 21:20:04
|
Revision: 384
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=384&view=rev
Author: iansmith
Date: 2007-09-07 14:20:08 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
More context futzing. Upgrading to later configuration format.
Modified Paths:
--------------
maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml
Modified: maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml 2007-09-07 21:08:36 UTC (rev 383)
+++ maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml 2007-09-07 21:20:08 UTC (rev 384)
@@ -18,7 +18,8 @@
maxActive="50" />
<tomcat-users>
- <user name="seattle" password="demolove" roles="demo"/>
+ <role rolename="admin"/>
+ <user username="seattle" password="demolove" roles="demo"/>
</tomcat-users>
<Environment name="ogoglio/oktoZapDB" value="false" type="java.lang.String"/> <!-- not running tests! -->
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2007-09-07 21:08:32
|
Revision: 383
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=383&view=rev
Author: iansmith
Date: 2007-09-07 14:08:36 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
More futzing with security stuff. This passes "clean install" so should have no effect on
non-demo users.
Modified Paths:
--------------
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/media/site/MediaServlet.java
maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml
maven/trunk/ogoglio-server/src/main/webapp/WEB-INF/web.xml
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/media/site/MediaServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/media/site/MediaServlet.java 2007-09-07 20:37:27 UTC (rev 382)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/media/site/MediaServlet.java 2007-09-07 21:08:36 UTC (rev 383)
@@ -118,8 +118,8 @@
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
-
String name = pathElements[pathElements.length - 1];
+ Log.debug("in doPut of media servlet:"+name);
fileStore.write(name, request.getInputStream(), -1);
response.setStatus(HttpServletResponse.SC_OK);
response.setContentLength(0);
Modified: maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml 2007-09-07 20:37:27 UTC (rev 382)
+++ maven/trunk/ogoglio-server/src/main/webapp/META-INF/context.xml 2007-09-07 21:08:36 UTC (rev 383)
@@ -2,7 +2,9 @@
<Context reloadable="true" path="/og" >
<Realm className="org.apache.catalina.realm.MemoryRealm" />
-
+ <tomcat-users>
+
+ </tomcat-users>
<Resource name="jdbc/space" scope="Shareable"
type="javax.sql.DataSource" auth='Container'
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
@@ -14,6 +16,10 @@
show_sql="false"
maxIdle="5"
maxActive="50" />
+
+ <tomcat-users>
+ <user name="seattle" password="demolove" roles="demo"/>
+ </tomcat-users>
<Environment name="ogoglio/oktoZapDB" value="false" type="java.lang.String"/> <!-- not running tests! -->
<Environment name="ogoglio/okToMigrateDB" value="${ogoglio.okToMigrateDB}" type="java.lang.String"/>
Modified: maven/trunk/ogoglio-server/src/main/webapp/WEB-INF/web.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/webapp/WEB-INF/web.xml 2007-09-07 20:37:27 UTC (rev 382)
+++ maven/trunk/ogoglio-server/src/main/webapp/WEB-INF/web.xml 2007-09-07 21:08:36 UTC (rev 383)
@@ -41,7 +41,7 @@
</servlet-mapping>
<servlet-mapping>
- <servlet-name>SpaceServlet</servlet-name>
+ <servlet-name>SpaceServlet</servlet-name>test
<url-pattern>/space/*</url-pattern>
</servlet-mapping>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2007-09-07 20:37:24
|
Revision: 382
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=382&view=rev
Author: iansmith
Date: 2007-09-07 13:37:27 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
Futzing with authorization. Only used by the demo system. SVN as transport.
Modified Paths:
--------------
maven/trunk/ogoglio-server/src/main/webapp/WEB-INF/web-demo.xml
Modified: maven/trunk/ogoglio-server/src/main/webapp/WEB-INF/web-demo.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/webapp/WEB-INF/web-demo.xml 2007-09-07 20:18:14 UTC (rev 381)
+++ maven/trunk/ogoglio-server/src/main/webapp/WEB-INF/web-demo.xml 2007-09-07 20:37:27 UTC (rev 382)
@@ -66,7 +66,7 @@
<web-resource-collection>
<web-resource-name>SecurityRestriction</web-resource-name>
<description>Demo For Friends Only</description>
- <url-pattern>/og</url-pattern>
+ <url-pattern>/</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2007-09-07 20:18:11
|
Revision: 381
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=381&view=rev
Author: iansmith
Date: 2007-09-07 13:18:14 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
Dead code to everybody except the demo instance. Using SVN as transport.
Added Paths:
-----------
maven/trunk/ogoglio-server/src/main/webapp/WEB-INF/web-demo.xml
Added: maven/trunk/ogoglio-server/src/main/webapp/WEB-INF/web-demo.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/webapp/WEB-INF/web-demo.xml (rev 0)
+++ maven/trunk/ogoglio-server/src/main/webapp/WEB-INF/web-demo.xml 2007-09-07 20:18:14 UTC (rev 381)
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
+ <servlet>
+ <servlet-name>AccountServlet</servlet-name>
+ <servlet-class>com.ogoglio.site.AccountServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>AuthServlet</servlet-name>
+ <servlet-class>com.ogoglio.site.AuthServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>SpaceServlet</servlet-name>
+ <servlet-class>com.ogoglio.site.SpaceServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>MediaServlet</servlet-name>
+ <servlet-class>com.ogoglio.media.site.MediaServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>SimServlet</servlet-name>
+ <servlet-class>com.ogoglio.sim.site.SimServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>AccountServlet</servlet-name>
+ <url-pattern>/account/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>AuthServlet</servlet-name>
+ <url-pattern>/auth/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>SpaceServlet</servlet-name>test
+ <url-pattern>/space/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>SimServlet</servlet-name>
+ <url-pattern>/sim/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>MediaServlet</servlet-name>
+ <url-pattern>/media/*</url-pattern>
+ </servlet-mapping>
+
+ <error-page>
+ <error-code>404</error-code>
+ <location>/notFound.html</location>
+ </error-page>
+
+<!-- Start Authentication -->
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>SecurityRestriction</web-resource-name>
+ <description>Demo For Friends Only</description>
+ <url-pattern>/og</url-pattern>
+ <http-method>GET</http-method>
+ <http-method>POST</http-method>
+ <http-method>PUT</http-method>
+ <http-method>DELETE</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <description>Demo Users Group</description>
+ <role-name>demo</role-name>
+ </auth-constraint>
+ <user-data-constraint>
+ <transport-guarantee>NONE</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+
+ <security-role>
+ <description>Demo role</description>
+ <role-name>demo</role-name>
+ </security-role>
+
+ <!-- End Authentication -->
+</web-app>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2007-09-07 16:32:52
|
Revision: 380
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=380&view=rev
Author: iansmith
Date: 2007-09-07 09:32:49 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
developers should ogoglio.interacte_boot property to their settings.xml file
Modified Paths:
--------------
maven/trunk/ogoglio/pom.xml
maven/trunk/ogoglio/src/main/resources/scripts/testApplet.sh
Modified: maven/trunk/ogoglio/pom.xml
===================================================================
--- maven/trunk/ogoglio/pom.xml 2007-09-07 00:27:17 UTC (rev 379)
+++ maven/trunk/ogoglio/pom.xml 2007-09-07 16:32:49 UTC (rev 380)
@@ -30,7 +30,8 @@
<version>0.3-SNAPSHOT</version>
<!-- CARGO INTERACTIONS WITH TOMCAT FOR BOOTING SERVER ONLY -->
<configuration>
- <wait>true</wait>
+
+<wait>${ogoglio.interactive_boot}</wait>
<!-- tomcat 5.5 running on the same machine...-->
<container>
<containerId>tomcat5x</containerId>
Modified: maven/trunk/ogoglio/src/main/resources/scripts/testApplet.sh
===================================================================
--- maven/trunk/ogoglio/src/main/resources/scripts/testApplet.sh 2007-09-07 00:27:17 UTC (rev 379)
+++ maven/trunk/ogoglio/src/main/resources/scripts/testApplet.sh 2007-09-07 16:32:49 UTC (rev 380)
@@ -8,7 +8,7 @@
LIVEC=~/.m2/repository/netscape/liveConnect/1.0/liveConnect-1.0.jar
APPLET=../../../../../ogoglio-viewer-applet/target/ogoglio-viewer-applet-0.0.1-SNAPSHOT.jar
-SPACE=2
+SPACE=$1
ls -l $INT_TEST/*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-07 00:27:20
|
Revision: 379
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=379&view=rev
Author: trevorolio
Date: 2007-09-06 17:27:17 -0700 (Thu, 06 Sep 2007)
Log Message:
-----------
Fixed a bug in SpaceScriptEngine which caused a silent ECMA script failue.
Consolidated some of the login cookie script functionality.
Changed the REST api permissions on a thing's service resource.
Modified Paths:
--------------
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/MessageProxy.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/body.html
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java 2007-09-07 00:27:11 UTC (rev 378)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java 2007-09-07 00:27:17 UTC (rev 379)
@@ -112,7 +112,7 @@
public void cleanup() { //this happens when a space is stopped, not necessarily when it's deleted
Object[] scopes = thingScopes.getValues();
for (int i = 0; i < scopes.length; i++) {
- callAndIgnoreFunction(DESTRUCT_FUNCTION_NAME, (ScriptableObject) scopes[i]); //yes, we call destruct in cleanup()... it's weird but right
+ callAndIgnoreFunction(DESTRUCT_FUNCTION_NAME, (ScriptableObject) scopes[i]); //yes, we call destruct in cleanup()... it's weird but right
}
scriptSpace.cleanup();
}
@@ -277,7 +277,12 @@
return null;
} else {
Function function = (Function) functionObject;
- return function.call(context, thingScope, thingScope, functionArgs);
+ try {
+ return function.call(context, thingScope, thingScope, functionArgs);
+ } catch (EcmaError e) {
+ spaceSimulator.log("Error calling " + functionName + ": " + e);
+ return null;
+ }
}
}
@@ -373,7 +378,7 @@
public void thingAdded(Thing thing) {
}
- private void callAndIgnoreFunction(String functionName, ScriptableObject thingScope){
+ private void callAndIgnoreFunction(String functionName, ScriptableObject thingScope) {
Context context = Context.enter();
try {
callJavascriptFunction(context, thingScope, functionName, new Object[0]);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-09-07 00:27:11 UTC (rev 378)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-09-07 00:27:17 UTC (rev 379)
@@ -61,6 +61,8 @@
public class SimServlet extends OgoglioServletBase {
private static final String RELOAD_PARAMETER = "reload";
+ public static final String THING_SERVICE_PATH_ELEMENT = "service";
+
private Sim sim = null;
private URI simURI = null;
@@ -755,7 +757,7 @@
private class ThingServiceResource extends SiteResource {
public ThingServiceResource() {
- super("service");
+ super(THING_SERVICE_PATH_ELEMENT);
}
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/MessageProxy.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/MessageProxy.java 2007-09-07 00:27:11 UTC (rev 378)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/MessageProxy.java 2007-09-07 00:27:17 UTC (rev 379)
@@ -181,7 +181,7 @@
}
int userCount = element.getChildren(UserDocument.NAME).length;
if(userCount >= spaceRecord.getMaxGuests()) {
- Log.error("Refused guest to space " + spaceRecord.getSpaceID() + " for reasons of max guest limit: " + payload.getSpaceID());
+ Log.error("Refused guest to space " + spaceRecord.getSpaceID() + " for reasons of max guest limit: " + spaceRecord.getMaxGuests());
Message failureMessage = new Message(channelServer.getLocator(), request.getOrigin(), payload.getSpaceID(), new PayloadFactory.AuthenticationFailurePayload("This space has reached its guest limit."));
sourceChannel.sendMessage(failureMessage);
return;
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2007-09-07 00:27:11 UTC (rev 378)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2007-09-07 00:27:17 UTC (rev 379)
@@ -16,7 +16,6 @@
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.Date;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -41,6 +40,7 @@
import com.ogoglio.persist.SpaceMemberRecord;
import com.ogoglio.persist.SpacePersistTasks;
import com.ogoglio.persist.SpaceRecord;
+import com.ogoglio.sim.site.SimServlet;
import com.ogoglio.util.Log;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.ServiceDocument;
@@ -362,7 +362,7 @@
}
AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if(!canUseMethodOnSpace(method, authedAccount, spaceRecord)){
+ if(!canUseMethodOnSpace(method, authedAccount, spaceRecord) && !SimServlet.THING_SERVICE_PATH_ELEMENT.equals(pathElements[pathElements.length - 1])){
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
Modified: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/body.html
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/siteTemplates/body.html 2007-09-07 00:27:11 UTC (rev 378)
+++ maven/trunk/ogoglio-server/src/main/resources/siteTemplates/body.html 2007-09-07 00:27:17 UTC (rev 379)
@@ -31,7 +31,7 @@
<script type="text/javascript">
var bodyID = locationParameters['bodyID'];
-var loginCookie = getCookie('loginCookie');
+var loginCookie = getLoginCookie();
var titleElement = null;
var mainElement = null;
Modified: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js 2007-09-07 00:27:11 UTC (rev 378)
+++ maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js 2007-09-07 00:27:17 UTC (rev 379)
@@ -1,4 +1,5 @@
var appPath = "/og"; //do not put a slash on the end
+var loginCookieName = "loginCookie";
function getServiceURI(){
var locLink = document.location;
@@ -176,6 +177,16 @@
return window.open(URL, id, params);
}
+function getLoginCookie(){
+ return getCookie(loginCookieName);
+}
+
+function setLoginCookie(cookie){
+ var expire = new Date();
+ expire.setTime(expire.getTime() + 3600000*24*3);
+ document.cookie = loginCookieName + "=" + escape(cookie) + ";expires=" + expire.toGMTString() + ";path=/";
+}
+
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
Modified: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js 2007-09-07 00:27:11 UTC (rev 378)
+++ maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js 2007-09-07 00:27:17 UTC (rev 379)
@@ -20,6 +20,10 @@
var allowsGuests = parseInt(xml.getAttribute("maxguests")) > 0;
if(authedUsername == null){
if(allowsGuests && typeof autoGuest != "undefined" && autoGuest){
+ if(getLoginCookie() != null && getLoginCookie().indexOf("guest_") == 0){
+ enterTheSpace();
+ return;
+ }
enterAsGuest();
} else if(allowsGuests){
spaceDiv.innerHTML = "<div style='width: 100%; text-align: center; margin-top: 20px; font-weight: bold; color: #000;'>Would you like to <a href='signin.html'>sign in</a> or <a href='space.html' onclick='enterAsGuest(); return false;'>enter as a guest</a>?";
@@ -62,7 +66,7 @@
}
function writeApplet(){
- var loginCookie = getCookie("loginCookie");
+ var loginCookie = getLoginCookie();
if(loginCookie == null){
spaceDiv.innerHTML = "No cookie. Please sign in or register as a guest.";
return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-07 00:27:09
|
Revision: 378
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=378&view=rev
Author: trevorolio
Date: 2007-09-06 17:27:11 -0700 (Thu, 06 Sep 2007)
Log Message:
-----------
Fixed a bug in SpaceScriptEngine which caused a silent ECMA script failue.
Consolidated some of the login cookie script functionality.
Changed the REST api permissions on a thing's service resource.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/Log.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/Log.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/Log.java 2007-09-06 19:05:00 UTC (rev 377)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/Log.java 2007-09-07 00:27:11 UTC (rev 378)
@@ -23,6 +23,14 @@
public void warn(Object msg) {
System.err.println(msg);
}
+
+ public void info(Object msg, Throwable t) {
+ System.err.println(msg + ": " + t);
+ }
+
+ public void error(Object msg, Throwable t) {
+ System.err.println(msg + ": " + t);
+ }
}
static Logger log = new Logger();
@@ -36,7 +44,7 @@
}
public static void info(Object msg, Throwable t) {
- log.info(msg);
+ log.info(msg, t);
}
public static void warn(Object msg) {
@@ -48,7 +56,7 @@
}
public static void error(Object msg, Throwable t) {
- log.error(msg);
+ log.error(msg, t);
}
public static void trace(Object msg) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-06 19:05:00
|
Revision: 377
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=377&view=rev
Author: trevorolio
Date: 2007-09-06 12:05:00 -0700 (Thu, 06 Sep 2007)
Log Message:
-----------
Added door and setting handlers to populate and reverse mojos.
Modified Paths:
--------------
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/OgServiceMojoBase.java
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/ReverseMojo.java
Modified: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/OgServiceMojoBase.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/OgServiceMojoBase.java 2007-09-06 13:16:32 UTC (rev 376)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/OgServiceMojoBase.java 2007-09-06 19:05:00 UTC (rev 377)
@@ -78,7 +78,18 @@
}
protected String fileToTemplateName(File tempFile) {
- return tempFile.getName().substring(0, tempFile.getName().length() - 4);
+ String trimmed = tempFile.getName().substring(0, tempFile.getName().length() - 4);
+ trimmed = trimmed.replace('_', ' ');
+ trimmed = trimmed.replace('-', ' ');
+ StringBuffer result = new StringBuffer();
+ result.append(Character.toUpperCase(trimmed.charAt(0)));
+ for (int i = 1; i < trimmed.length(); i++) {
+ if(Character.isUpperCase(trimmed.charAt(i)) && !Character.isUpperCase(trimmed.charAt(i - 1))){
+ result.append(" ");
+ }
+ result.append(trimmed.charAt(i));
+ }
+ return result.toString();
}
protected int dirNameToTemplateNumber(File candidate) throws MojoExecutionException {
Modified: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java 2007-09-06 13:16:32 UTC (rev 376)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java 2007-09-06 19:05:00 UTC (rev 377)
@@ -15,7 +15,9 @@
import com.ogoglio.client.WebAPIClient;
import com.ogoglio.util.StreamUtils;
+import com.ogoglio.xml.DoorDocument;
import com.ogoglio.xml.PossessionDocument;
+import com.ogoglio.xml.SettingDocument;
import com.ogoglio.xml.SpaceDocument;
import com.ogoglio.xml.TemplateDocument;
import com.ogoglio.xml.ThingDocument;
@@ -30,7 +32,7 @@
public void execute() throws MojoExecutionException {
WebAPIClient client = validateArgsAndConnect();
- if(client == null){
+ if (client == null) {
return;
}
File[] templates = populateDir.listFiles();
@@ -58,6 +60,15 @@
fakeSpaceDoc = spaces.get(i);
try {
realSpaceDoc = client.createSpace(fakeSpaceDoc.getDisplayName());
+ if (realSpaceDoc == null) {
+ throw new MojoExecutionException("Could not create a space for population: " + fakeSpaceDoc.getDisplayName());
+ }
+ long realSpaceID = realSpaceDoc.getSpaceID();
+ client.setSpaceMaxGuests(realSpaceID, fakeSpaceDoc.getMaxGuests());
+ client.setSpacePublished(realSpaceID, fakeSpaceDoc.isPublished());
+ client.setSpaceSeaLevel(realSpaceID, fakeSpaceDoc.getSeaLevel());
+ client.setSpaceDisplaySea(realSpaceID, fakeSpaceDoc.getDisplaySea());
+
ThingDocument things[] = fakeSpaceDoc.getThingDocuments();
for (int j = 0; j < things.length; ++j) {
ThingDocument thing = things[j];
@@ -71,13 +82,17 @@
client.updateThing(realSpaceDoc.getSpaceID(), newThingDoc);
}
- long realSpaceID = realSpaceDoc.getSpaceID();
- client.setSpaceSeaLevel(realSpaceID, fakeSpaceDoc.getSeaLevel());
- client.setSpaceMaxGuests(realSpaceID, fakeSpaceDoc.getMaxGuests());
- client.setSpaceDisplayName(realSpaceID, fakeSpaceDoc.getDisplayName());
- client.setSpaceSeaLevel(realSpaceID, fakeSpaceDoc.getSeaLevel());
- getLog().info("Patched up space "+realSpaceDoc.getDisplayName());
+ SettingDocument[] settingDocs = fakeSpaceDoc.getSettingDocuments();
+ for (int j = 0; j < settingDocs.length; j++) {
+ client.putSpaceSetting(realSpaceID, settingDocs[j].getKey(), settingDocs[j].getValue());
+ }
+ DoorDocument[] doorDocs = fakeSpaceDoc.getDoorDocuments();
+ for (int j = 0; j < doorDocs.length; j++) {
+ client.createDoor(realSpaceID, doorDocs[j].getTemplateID(), doorDocs[j].getTemplateOwner(), doorDocs[j].getDisplayName(), doorDocs[j].getLink(), doorDocs[j].getTransform());
+ }
+
+ getLog().info("Patched up space " + realSpaceDoc.getDisplayName());
} catch (IOException e) {
throw new MojoExecutionException("IOException patching space (" + fakeSpaceDoc.getDisplayName() + ":" + fakeSpaceDoc.getSpaceID() + ")", e);
}
Modified: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/ReverseMojo.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/ReverseMojo.java 2007-09-06 13:16:32 UTC (rev 376)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/ReverseMojo.java 2007-09-06 19:05:00 UTC (rev 377)
@@ -1,6 +1,5 @@
package com.ogoglio.plugin;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -16,6 +15,8 @@
import com.ogoglio.client.WebAPIClient;
import com.ogoglio.util.StreamUtils;
+import com.ogoglio.xml.DoorDocument;
+import com.ogoglio.xml.SettingDocument;
import com.ogoglio.xml.SpaceDocument;
import com.ogoglio.xml.TemplateDocument;
import com.ogoglio.xml.ThingDocument;
@@ -24,135 +25,139 @@
* @goal reverse
*/
public class ReverseMojo extends OgServiceMojoBase {
- /**
- * @parameter
- */
- private File reverseFile;
+ /**
+ * @parameter
+ */
+ private File reverseFile;
- public void execute() throws MojoExecutionException, MojoFailureException {
- WebAPIClient client = validateArgsAndConnect();
- HashMap<String,Long> displayNameToLocalId = new HashMap<String, Long>();
- HashMap<Long,Long> remoteIdTolocalId = new HashMap<Long, Long>();
-
- long localThingId=1,localPossId=1;
-
- if (client==null) {
- return;
- }
-
- if (reverseFile==null) {
- getLog().info("No reverse file configured. Mojo ignored.");
- return;
- }
-
- if ((!reverseFile.isFile()) || (!reverseFile.canRead())) {
- throw new MojoExecutionException("Can't read reverse file "+reverseFile.getAbsolutePath());
- }
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ WebAPIClient client = validateArgsAndConnect();
+ HashMap<String, Long> displayNameToLocalId = new HashMap<String, Long>();
+ HashMap<Long, Long> remoteIdTolocalId = new HashMap<Long, Long>();
- SpaceDocument origSpaceDoc = buildTemplateMaps(displayNameToLocalId,
- remoteIdTolocalId);
-
- int localSpaceId=getNextLocalSpaceId();
-
- SpaceDocument result = rewhackSpaceDocument(remoteIdTolocalId,
- localThingId, localPossId, origSpaceDoc, localSpaceId);
-
- try {
- writeSpaceDoc(result,localSpaceId);
- } catch (IOException e) {
- throw new MojoExecutionException(e,"IOException","can't write output file");
- }
- }
+ if (client == null) {
+ return;
+ }
- private SpaceDocument rewhackSpaceDocument(
- HashMap<Long, Long> remoteIdTolocalId, long localThingId,
- long localPossId, SpaceDocument origSpaceDoc, int localSpaceId) {
- SpaceDocument result = new SpaceDocument(localSpaceId,origSpaceDoc.getDisplayName(),origSpaceDoc.getOwnerUsername(),
- true /*origSpaceDoc.getPublished()*/,origSpaceDoc.getMaxGuests(),origSpaceDoc.getDisplaySea(),
- origSpaceDoc.getSeaLevel(),origSpaceDoc.getSimID());
-
- ThingDocument[] things=origSpaceDoc.getThingDocuments();
- for (int i=0; i<things.length;++i) {
- ThingDocument remoteThing=things[i];
- ThingDocument localThing=new ThingDocument(localThingId++,remoteThing.getDisplayName(),
- remoteIdTolocalId.get(new Long(remoteThing.getTemplateID())).longValue(),
- remoteThing.getTemplateOwner(),remoteThing.getOwnerUsername(),
- localPossId++, remoteThing.getTransform(),remoteThing.getSplinePath());
- result.addThingDocument(localThing);
- getLog().info("Fixed thing "+localThing.getDisplayName());
- }
- return result;
- }
+ if (reverseFile == null) {
+ getLog().info("No reverse file configured. Mojo ignored.");
+ return;
+ }
- private SpaceDocument buildTemplateMaps(
- HashMap<String, Long> displayNameToLocalId,
- HashMap<Long, Long> remoteIdTolocalId)
- throws MojoExecutionException, MojoFailureException {
- SpaceDocument origSpaceDoc=null;
- try {
- String revContent = StreamUtils.readInput(new FileInputStream(reverseFile));
- origSpaceDoc = new SpaceDocument(XMLElement.parseElementFromString(revContent));
- } catch (IOException e) {
- throw new MojoExecutionException(e,"IOException","Can't read space document "+reverseFile.getAbsolutePath());
- }
- File[] templateDirs= populateDir.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.startsWith(TEMPLATE_PREFIX);
- }
- });
- File[] objectFiles=new File[templateDirs.length];
- for (int i=0; i< templateDirs.length;++i) {
- File[] objs = templateDirs[i].listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".obj");
- }
- });
- if (objs.length!=1) {
- throw new MojoExecutionException("Directory "+templateDirs[i].getName()+" has wrong number of object files:"+objs.length);
- }
- objectFiles[i]=objs[0];
- }
- for (int i=0; i<objectFiles.length;++i) {
- String tName = fileToTemplateName(objectFiles[i]);
- int num = dirNameToTemplateNumber(objectFiles[i].getParentFile());
- displayNameToLocalId.put(tName,new Long(num));
- }
- TemplateDocument[] mentioned = origSpaceDoc.getTemplateDocuments();
- for (int i=0; i<mentioned.length;++i) {
- TemplateDocument candidate = mentioned[i];
- String remoteDisplayName = candidate.getDisplayName();
- if (!displayNameToLocalId.containsKey(remoteDisplayName)) {
- throw new MojoFailureException("Can't find a local template with display name "+remoteDisplayName);
- }
- Long local=displayNameToLocalId.get(remoteDisplayName);
- remoteIdTolocalId.put(new Long(candidate.getTemplateID()), local);
- getLog().info("Mapped "+remoteDisplayName+" ["+candidate.getTemplateID()+" ->"+local+"]");
- }
- return origSpaceDoc;
- }
+ if ((!reverseFile.isFile()) || (!reverseFile.canRead())) {
+ throw new MojoExecutionException("Can't read reverse file " + reverseFile.getAbsolutePath());
+ }
- private void writeSpaceDoc(SpaceDocument result, int localSpaceId) throws IOException {
- FileWriter wr=new FileWriter(new File(populateDir,SPACE_PREFIX+localSpaceId));
- wr.write(result.toString());
- wr.close();
- getLog().info("Wrote new space document:"+(SPACE_PREFIX+localSpaceId));
- }
+ SpaceDocument origSpaceDoc = buildTemplateMaps(displayNameToLocalId, remoteIdTolocalId);
- private int getNextLocalSpaceId() throws MojoExecutionException {
- int attempt=1,TOO_BIG=500;
- File f;
- do {
- attempt++;
- f=new File(populateDir,SPACE_PREFIX+(attempt));
- //sanity
- if (attempt==TOO_BIG) {
- break;
- }
- } while (f.exists());
- if (attempt==TOO_BIG) {
- throw new MojoExecutionException("Don't know why but there are way too many space documents...aborting at "+attempt);
- }
- return attempt-1;
- }
+ int localSpaceId = getNextLocalSpaceId();
+ SpaceDocument result = rewhackSpaceDocument(remoteIdTolocalId, origSpaceDoc, localSpaceId);
+
+ try {
+ writeSpaceDoc(result, localSpaceId);
+ } catch (IOException e) {
+ throw new MojoExecutionException(e, "IOException", "can't write output file");
+ }
+ }
+
+ private SpaceDocument rewhackSpaceDocument(HashMap<Long, Long> remoteIdTolocalId, SpaceDocument origSpaceDoc, int localSpaceId) {
+ long localThingId = 1;
+ long localPossId = 1;
+
+ SpaceDocument result = new SpaceDocument(localSpaceId, origSpaceDoc.getDisplayName(), origSpaceDoc.getOwnerUsername(), true /*origSpaceDoc.getPublished()*/, origSpaceDoc.getMaxGuests(), origSpaceDoc.getDisplaySea(), origSpaceDoc.getSeaLevel(), origSpaceDoc.getSimID());
+
+ ThingDocument[] thingDocs = origSpaceDoc.getThingDocuments();
+ for (int i = 0; i < thingDocs.length; ++i) {
+ ThingDocument remoteThing = thingDocs[i];
+ ThingDocument localThing = new ThingDocument(localThingId++, remoteThing.getDisplayName(), remoteIdTolocalId.get(new Long(remoteThing.getTemplateID())), remoteThing.getTemplateOwner(), remoteThing.getOwnerUsername(), localPossId++, remoteThing.getTransform(), remoteThing.getSplinePath());
+ result.addThingDocument(localThing);
+ getLog().info("Fixed thing " + localThing.getDisplayName());
+ }
+
+ DoorDocument[] doorDocs = origSpaceDoc.getDoorDocuments();
+ for (int i = 0; i < doorDocs.length; i++) {
+ DoorDocument remoteDoor = doorDocs[i];
+ DoorDocument localDoorDoc = new DoorDocument(localThingId++, remoteDoor.getDisplayName(), remoteIdTolocalId.get(new Long(remoteDoor.getTemplateID())), remoteDoor.getTemplateOwner(), remoteDoor.getLink(), remoteDoor.getTransform());
+ result.addDoorDocument(localDoorDoc);
+ getLog().info("Fixed door " + localDoorDoc.getDisplayName());
+ }
+
+ SettingDocument[] settingDocs = origSpaceDoc.getSettingDocuments();
+ for (int i = 0; i < settingDocs.length; i++) {
+ result.addSetting(settingDocs[i].getKey(), settingDocs[i].getValue());
+ }
+
+ return result;
+ }
+
+ private SpaceDocument buildTemplateMaps(HashMap<String, Long> displayNameToLocalId, HashMap<Long, Long> remoteIdTolocalId) throws MojoExecutionException, MojoFailureException {
+ SpaceDocument origSpaceDoc = null;
+ try {
+ String revContent = StreamUtils.readInput(new FileInputStream(reverseFile));
+ origSpaceDoc = new SpaceDocument(XMLElement.parseElementFromString(revContent));
+ } catch (IOException e) {
+ throw new MojoExecutionException(e, "IOException", "Can't read space document " + reverseFile.getAbsolutePath());
+ }
+ File[] templateDirs = populateDir.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.startsWith(TEMPLATE_PREFIX);
+ }
+ });
+ File[] objectFiles = new File[templateDirs.length];
+ for (int i = 0; i < templateDirs.length; ++i) {
+ File[] objs = templateDirs[i].listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".obj");
+ }
+ });
+ if (objs.length != 1) {
+ throw new MojoExecutionException("Directory " + templateDirs[i].getName() + " has wrong number of object files:" + objs.length);
+ }
+ objectFiles[i] = objs[0];
+ }
+ for (int i = 0; i < objectFiles.length; ++i) {
+ String tName = fileToTemplateName(objectFiles[i]);
+ int num = dirNameToTemplateNumber(objectFiles[i].getParentFile());
+ displayNameToLocalId.put(tName, new Long(num));
+ }
+ TemplateDocument[] mentioned = origSpaceDoc.getTemplateDocuments();
+ for (int i = 0; i < mentioned.length; ++i) {
+ TemplateDocument candidate = mentioned[i];
+ String remoteDisplayName = candidate.getDisplayName();
+ if (!displayNameToLocalId.containsKey(remoteDisplayName)) {
+ throw new MojoFailureException("Can't find a local template with display name " + remoteDisplayName);
+ }
+ Long local = displayNameToLocalId.get(remoteDisplayName);
+ remoteIdTolocalId.put(new Long(candidate.getTemplateID()), local);
+ getLog().info("Mapped " + remoteDisplayName + " [" + candidate.getTemplateID() + " ->" + local + "]");
+ }
+
+ return origSpaceDoc;
+ }
+
+ private void writeSpaceDoc(SpaceDocument result, int localSpaceId) throws IOException {
+ FileWriter wr = new FileWriter(new File(populateDir, SPACE_PREFIX + localSpaceId));
+ wr.write(result.toString());
+ wr.close();
+ getLog().info("Wrote new space document:" + (SPACE_PREFIX + localSpaceId));
+ }
+
+ private int getNextLocalSpaceId() throws MojoExecutionException {
+ int attempt = 1, TOO_BIG = 500;
+ File f;
+ do {
+ attempt++;
+ f = new File(populateDir, SPACE_PREFIX + (attempt));
+ //sanity
+ if (attempt == TOO_BIG) {
+ break;
+ }
+ } while (f.exists());
+ if (attempt == TOO_BIG) {
+ throw new MojoExecutionException("Don't know why but there are way too many space documents...aborting at " + attempt);
+ }
+ return attempt - 1;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-06 13:16:29
|
Revision: 376
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=376&view=rev
Author: trevorolio
Date: 2007-09-06 06:16:32 -0700 (Thu, 06 Sep 2007)
Log Message:
-----------
Improved the account checks when accepting or denying space modifications via web api.
Avoided a null pointer exception in populate mojo when the populate dir was not configured.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceMemberDocument.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2007-09-06 13:16:29 UTC (rev 375)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2007-09-06 13:16:32 UTC (rev 376)
@@ -67,10 +67,13 @@
}
}
- public SpaceDocument createSpace(String spaceName) throws IOException {
+ public SpaceDocument createSpace(String spaceName) {
SpaceDocument spaceDoc = new SpaceDocument(-1, spaceName, authenticator.getUsername(), false, 0, false, 0, -1);
- XMLElement result = wire.sendAuthenticatedXML(descriptor.getSpacesURI(), spaceDoc.toString(), "POST", authenticator.getAuthCookie());
- return new SpaceDocument(result);
+ try {
+ return new SpaceDocument(wire.sendAuthenticatedXML(descriptor.getSpacesURI(), spaceDoc.toString(), "POST", authenticator.getAuthCookie()));
+ } catch (IOException e) {
+ return null;
+ }
}
public boolean deleteSpace(long spaceID) throws IOException {
@@ -210,6 +213,14 @@
wire.postAuthenticatedXML(descriptor.getSpaceURI(spaceID), spaceDoc.toString(), authenticator.getAuthCookie());
}
+ public SpaceMemberDocument updateSpaceMember(long spaceID, SpaceMemberDocument spaceMemberDocument) {
+ try {
+ return new SpaceMemberDocument(wire.sendAuthenticatedXML(descriptor.getSpaceMemberURI(spaceID, spaceMemberDocument.getMemberUsername()), spaceMemberDocument.toString(), "POST", authenticator.getAuthCookie()));
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
public SpaceMemberDocument addSpaceMember(long spaceID, String memberUsername, String role) throws IOException {
SpaceDocument spaceDoc = new SpaceDocument(wire.fetchAuthenticatedXML(descriptor.getSpaceURI(spaceID), authenticator.getAuthCookie()));
SpaceMemberDocument memberDoc = new SpaceMemberDocument(spaceDoc.getSpaceID(), memberUsername, false, role);
@@ -259,8 +270,12 @@
return new SpaceDocument(wire.fetchAuthenticatedXML(descriptor.getSpaceURI(spaceID, includeChildren), authenticator.getAuthCookie()));
}
- public ThingDocument updateThing(long spaceID, ThingDocument thingDoc) throws IOException {
- return new ThingDocument(wire.postAuthenticatedXML(descriptor.getThingURI(spaceID, thingDoc.getThingID()), thingDoc.toString(), authenticator.getAuthCookie()));
+ public ThingDocument updateThing(long spaceID, ThingDocument thingDoc) {
+ try {
+ return new ThingDocument(wire.postAuthenticatedXML(descriptor.getThingURI(spaceID, thingDoc.getThingID()), thingDoc.toString(), authenticator.getAuthCookie()));
+ } catch (Exception e) {
+ return null;
+ }
}
public TemplateDocument updateTemplate(TemplateDocument templateDoc) throws IOException {
@@ -373,7 +388,7 @@
public String getThingService(long spaceID, long thingID) throws IOException {
InputStream stream = wire.fetchAuthenticatedStream(descriptor.getThingServiceURI(spaceID, thingID), authenticator.getAuthCookie());
- if(stream == null){
+ if (stream == null) {
return null;
}
return StreamUtils.readInput(stream);
@@ -520,5 +535,5 @@
public WebAPIClientWire getWire() {
return wire;
}
+
}
-
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java 2007-09-06 13:16:29 UTC (rev 375)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java 2007-09-06 13:16:32 UTC (rev 376)
@@ -26,7 +26,6 @@
import com.ogoglio.client.model.SplinePath;
import com.ogoglio.client.model.Thing;
import com.ogoglio.util.ArgumentUtils;
-import com.ogoglio.util.Log;
import com.ogoglio.viewer.render.ClickTarget;
import com.ogoglio.viewer.render.DoorRenderable;
import com.ogoglio.viewer.render.PageRenderable;
@@ -37,8 +36,7 @@
import com.ogoglio.viewer.render.UserRenderable;
public class MotionInputHandler implements MouseMotionListener, MouseListener {
- // right now we only support arrow key based walking and turning
- // TODO add a full motion set: walk, fun, strafe, jump
+ //TODO right now we only support arrow key based walking, strafing and turning
public double maxRadiansPerSecond = Math.PI / 60;
@@ -111,7 +109,6 @@
// called from within PhysicsBehavior
public void keyPressed(KeyEvent e) {
- Log.info("Key down "+e.toString());
if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_W) {
if (moveForward == false || run == true) {
dirty = true;
@@ -156,7 +153,6 @@
// called from within PhysicsBehavior
public void keyReleased(KeyEvent e) {
- Log.info("Key up:"+e.toString());
if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_W) {
if (moveForward == true) {
dirty = true;
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceMemberDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceMemberDocument.java 2007-09-06 13:16:29 UTC (rev 375)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceMemberDocument.java 2007-09-06 13:16:32 UTC (rev 376)
@@ -109,4 +109,11 @@
public int getRoleAsInt() {
return parseRole(getRole());
}
+
+ public void setRole(String role) {
+ if(parseRole(role) == -1){
+ throw new IllegalArgumentException("Bad space member role: " + role);
+ }
+ data.setAttribute(ROLE, role);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-06 13:16:25
|
Revision: 375
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=375&view=rev
Author: trevorolio
Date: 2007-09-06 06:16:29 -0700 (Thu, 06 Sep 2007)
Log Message:
-----------
Improved the account checks when accepting or denying space modifications via web api.
Avoided a null pointer exception in populate mojo when the populate dir was not configured.
Modified Paths:
--------------
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/OgServiceMojoBase.java
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
Modified: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/OgServiceMojoBase.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/OgServiceMojoBase.java 2007-09-06 13:16:24 UTC (rev 374)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/OgServiceMojoBase.java 2007-09-06 13:16:29 UTC (rev 375)
@@ -17,82 +17,80 @@
public abstract class OgServiceMojoBase extends AbstractMojo {
protected static final String SPACE_PREFIX = "space-";
- protected static final String TEMPLATE_PREFIX = "template-";
- /**
- * @parameter
- */
- protected File populateDir;
- /**
- * @parameter
- */
- protected String serviceURI;
- /**
- * @parameter
- */
- protected String username;
- /**
- * @parameter
- */
- private String password;
- protected WebAPIClient validateArgsAndConnect() {
- if (populateDir == null) {
- getLog().info("No populate baseDir given. Mojo ignored.");
- return null;
- }
-
- if ((!populateDir.exists()) || (!populateDir.isDirectory())
- || (!populateDir.canRead())) {
- getLog().error(
- "Unable to access base dir:" + populateDir.getAbsolutePath());
- return null;
- }
-
- if (serviceURI == null) {
- getLog().info("No populate serviceURI given. Mojo ignored.");
- return null;
- }
- try {
- WebAPIClientWire wire = new WebAPIClientWire();
- WebAPIDescriptor descriptor = new WebAPIDescriptor(new URI(
- serviceURI));
- WebAPIAuthenticator auth = new WebAPIAuthenticator(wire,
- descriptor, username, password);
- WebAPIClient client = new WebAPIClient(descriptor, auth, wire);
- return client;
-
- } catch (URISyntaxException e) {
- getLog().error("Bad URI (" + serviceURI + ")", e);
- } catch (IOException e) {
- getLog().error("Unable to connect to service (" + serviceURI + ")",
- e);
- }
- // some kind of exception
- return null;
- }
+ protected static final String TEMPLATE_PREFIX = "template-";
- protected TemplateDocument fileNameToTemplateDocument(WebAPIClient client, File tempFile)
- throws IOException {
- String templateName = fileToTemplateName(tempFile);//.obj
- TemplateDocument doc = client.createTemplate(templateName);
- return doc;
- }
+ /**
+ * @parameter
+ */
+ protected File populateDir;
- protected String fileToTemplateName(File tempFile) {
- return tempFile.getName().substring(0, tempFile.getName().length() - 4);
- }
+ /**
+ * @parameter
+ */
+ protected String serviceURI;
- protected int dirNameToTemplateNumber(File candidate)
- throws MojoExecutionException {
- int n = -188;
- String num = candidate.getName().substring(TEMPLATE_PREFIX.length());
- try {
- n = Integer.parseInt(num);
- } catch (NumberFormatException e) {
- throw new MojoExecutionException("Badly formed template name in populate directory:"+candidate.getName());
- }
- return n;
-
- }
+ /**
+ * @parameter
+ */
+ protected String username;
+ /**
+ * @parameter
+ */
+ private String password;
+
+ protected WebAPIClient validateArgsAndConnect() {
+ if (populateDir == null) {
+ getLog().info("No populate baseDir given. Mojo ignored.");
+ return null;
+ }
+
+ if ((!populateDir.exists()) || (!populateDir.isDirectory()) || (!populateDir.canRead())) {
+ getLog().error("Unable to access base dir:" + populateDir.getAbsolutePath());
+ return null;
+ }
+
+ if (serviceURI == null) {
+ getLog().info("No populate serviceURI given. Mojo ignored.");
+ return null;
+ }
+ try {
+ WebAPIClientWire wire = new WebAPIClientWire();
+ WebAPIDescriptor descriptor = new WebAPIDescriptor(new URI(serviceURI));
+ WebAPIAuthenticator auth = new WebAPIAuthenticator(wire, descriptor, username, password);
+ WebAPIClient client = new WebAPIClient(descriptor, auth, wire);
+ return client;
+
+ } catch (URISyntaxException e) {
+ getLog().error("Bad URI (" + serviceURI + ")", e);
+ } catch (IOException e) {
+ getLog().error("Unable to connect to service (" + serviceURI + ")", e);
+ }
+ // some kind of exception
+ return null;
+ }
+
+ protected TemplateDocument fileNameToTemplateDocument(WebAPIClient client, File tempFile) throws IOException {
+ String templateName = fileToTemplateName(tempFile);//.obj
+ TemplateDocument doc = client.createTemplate(templateName);
+ return doc;
+ }
+
+ protected String fileToTemplateName(File tempFile) {
+ return tempFile.getName().substring(0, tempFile.getName().length() - 4);
+ }
+
+ protected int dirNameToTemplateNumber(File candidate) throws MojoExecutionException {
+ int n = -188;
+ String num = candidate.getName().substring(TEMPLATE_PREFIX.length());
+ try {
+ n = Integer.parseInt(num);
+ } catch (NumberFormatException e) {
+ throw new MojoExecutionException("Badly formed template name in populate directory:" + candidate.getName());
+ }
+ return n;
+
+ }
+
}
Modified: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java 2007-09-06 13:16:24 UTC (rev 374)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java 2007-09-06 13:16:29 UTC (rev 375)
@@ -30,7 +30,9 @@
public void execute() throws MojoExecutionException {
WebAPIClient client = validateArgsAndConnect();
-
+ if(client == null){
+ return;
+ }
File[] templates = populateDir.listFiles();
for (int i = 0; i < templates.length; ++i) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-06 13:16:24
|
Revision: 374
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=374&view=rev
Author: trevorolio
Date: 2007-09-06 06:16:24 -0700 (Thu, 06 Sep 2007)
Log Message:
-----------
Improved the account checks when accepting or denying space modifications via web api.
Avoided a null pointer exception in populate mojo when the populate dir was not configured.
Modified Paths:
--------------
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-09-06 13:16:21 UTC (rev 373)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-09-06 13:16:24 UTC (rev 374)
@@ -25,6 +25,7 @@
import java.util.Vector;
import javax.media.j3d.Transform3D;
+import javax.vecmath.Vector3d;
import junit.framework.TestCase;
import nanoxml.XMLElement;
@@ -111,8 +112,8 @@
assertNotNull("got null auth cookie", adminAuthenticator.getAuthCookie());
WebAPIClient adminWebClient = new WebAPIClient(descriptor1, adminAuthenticator, wire1);
- adminWebClient.createAccount(USERNAME1, AccountDocument.ACCOUNT_LEVEL_ADVANCED, "Susan", "Examplar", "http://example.com/susan/", "su...@ex...", PASSWORD1);
- adminWebClient.createAccount(USERNAME2, AccountDocument.ACCOUNT_LEVEL_ADVANCED, "Tina", "Examplar", "http://example.com/tina/", "ti...@ex...", PASSWORD1);
+ adminWebClient.createAccount(USERNAME1, AccountDocument.ACCOUNT_LEVEL_ADVANCED, "Susan", "Advanced", "http://example.com/susan/", "su...@ex...", PASSWORD1);
+ adminWebClient.createAccount(USERNAME2, AccountDocument.ACCOUNT_LEVEL_BASIC, "Tina", "Basic", "http://example.com/tina/", "ti...@ex...", PASSWORD1);
assertNotNull(adminWebClient.getAccountDocument(USERNAME1));
assertNotNull(adminWebClient.getAccountDocument(USERNAME2));
@@ -182,55 +183,56 @@
try {
//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");
+ WebAPIAuthenticator advancedAuth = new WebAPIAuthenticator(wire1, descriptor1, USERNAME1, PASSWORD1);
+ WebAPIClient advancedClient = new WebAPIClient(descriptor1, advancedAuth, wire1);
+ SpaceDocument spaceDocument = advancedClient.createSpace("Susan's Space");
assertNotNull(spaceDocument);
-
- WebAPIAuthenticator auth2 = new WebAPIAuthenticator(wire1, descriptor1, USERNAME2, PASSWORD1);
- WebAPIClient webClient2 = new WebAPIClient(descriptor1, auth2, wire1);
-
+ advancedClient.setSpacePublished(spaceDocument.getSpaceID(), true);
+
+ WebAPIAuthenticator basicAuth = new WebAPIAuthenticator(wire1, descriptor1, USERNAME2, PASSWORD1);
+ WebAPIClient basicClient = new WebAPIClient(descriptor1, basicAuth, wire1);
+ assertNull(basicClient.createSpace("Tina's Illegal Space Which She Should Not Be Able To Create"));
+
checkNoConnectionToSpaceWithoutAuth(spaceDocument.getSpaceID());
- checkAuthDoc(auth1, auth2);
+ checkAuthDoc(advancedAuth, basicAuth);
- spaceDocument = checkSpaceSeaLevel(webClient1, spaceDocument);
+ spaceDocument = checkSpaceSeaLevel(advancedClient, spaceDocument);
- checkSettings(spaceDocument.getSpaceID(), webClient1);
+ checkSettings(spaceDocument.getSpaceID(), advancedClient);
- checkBody(webClient1, auth1);
+ checkBody(advancedClient, advancedAuth);
- checkSpaceMembership(spaceDocument.getSpaceID(), webClient1);
+ TemplateDocument newTemplateDoc = checkTemplateScriptAPI(advancedClient);
+ ThingDocument[] thingDocs = checkTemplateGeomMaterialsAndPossessions(advancedClient, newTemplateDoc, spaceDocument);
- checkSpaceAuthWithMembership(auth2, webClient2, webClient1, spaceDocument);
+ checkSpaceMembership(spaceDocument.getSpaceID(), advancedClient, basicClient);
- TemplateDocument newTemplateDoc = checkTemplateScriptAPI(webClient1);
- ThingDocument[] thingDocs = checkTemplateGeomMaterialsAndPossessions(webClient1, newTemplateDoc, spaceDocument);
+ checkSpaceAuthWithMembership(basicAuth, basicClient, advancedClient, spaceDocument);
- //IES CHECK: after messing around above, verify we are are ok
- thingDocs = webClient1.getThingDocuments(spaceDocument.getSpaceID());
+ thingDocs = advancedClient.getThingDocuments(spaceDocument.getSpaceID());
assertEquals(1, thingDocs.length);
- checkThingScripting(webClient1, thingDocs[0], spaceDocument);
+ checkThingScripting(advancedClient, thingDocs[0], spaceDocument);
- checkPageManipulation(webClient1, thingDocs[0], spaceDocument);
+ checkPageManipulation(advancedClient, thingDocs[0], spaceDocument);
//figure out the last template added
- TemplateDocument[] templateDocs = webClient1.getTemplateDocuments(USERNAME1);
+ TemplateDocument[] templateDocs = advancedClient.getTemplateDocuments(USERNAME1);
long lastTemplateID = templateDocs[templateDocs.length - 1].getTemplateID();
- checkDoors(webClient1, spaceDocument, lastTemplateID);
+ checkDoors(advancedClient, spaceDocument, lastTemplateID);
- spaceClient1 = checkConnectedUsersToSpace(auth1, webClient1, spaceDocument);
+ spaceClient1 = checkConnectedUsersToSpace(advancedAuth, advancedClient, spaceDocument);
- checkGeomAndResourceStreamsOfTemplate(webClient1, auth1.getUsername(), lastTemplateID);
+ checkGeomAndResourceStreamsOfTemplate(advancedClient, advancedAuth.getUsername(), lastTemplateID);
- authThenBuildSpaceClient(spaceDocument.getSpaceID(), auth1);
+ authThenBuildSpaceClient(spaceDocument.getSpaceID(), advancedAuth);
- checkGeometryAvailableForSpace(webClient1, thingDocs, spaceClient1.getSpace());
+ checkGeometryAvailableForSpace(advancedClient, thingDocs, spaceClient1.getSpace());
- guestSpaceClient1 = checkGuestCookieOperation(spaceDocument.getSpaceID(), webClient1, WebConstants.GUEST_COOKIE_PREFIX + "Test_Suite_Guest");
- checkDeletingSpaceDestroysThings(spaceDocument.getSpaceID(), webClient1, USERNAME1);
+ guestSpaceClient1 = checkGuestCookieOperation(spaceDocument.getSpaceID(), advancedClient, WebConstants.GUEST_COOKIE_PREFIX + "Test_Suite_Guest");
+ checkDeletingSpaceDestroysThings(spaceDocument.getSpaceID(), advancedClient, USERNAME1);
} finally {
if (spaceClient1 != null) {
spaceClient1.cleanup();
@@ -317,7 +319,6 @@
private UserDocument[] verifyUserDocsBySize(WebAPIClient webClient1, long spaceID, int expectedLen, String expectedUsername) throws IOException {
try {
- Log.warn("Sleeping in client test to try prevent timing errors from ruining test!");
Thread.sleep(2500);
} catch (Exception e) {}
@@ -370,14 +371,38 @@
assertEquals(numMemberships, membershipDocs.length);
}
- private void checkSpaceMembership(long spaceID, WebAPIClient webClient1) throws IOException {
- webClient1.addSpaceMember(spaceID, USERNAME2, SpaceMemberDocument.MEMBER);
- SpaceMemberDocument[] membershipDocs = webClient1.getSpaceMemberDocuments(spaceID);
+ private ThingDocument tryToUpdateThing(long spaceID, ThingDocument thingDocument, WebAPIClient client) throws IOException{
+ Vector3d scale = thingDocument.getScale();
+ scale.x += 0.5;
+ thingDocument.setScale(scale);
+ return client.updateThing(spaceID, thingDocument);
+ }
+
+ private void checkSpaceMembership(long spaceID, WebAPIClient advancedClient, WebAPIClient basicClient) throws IOException {
+ advancedClient.addSpaceMember(spaceID, basicClient.getAuthenticator().getUsername(), SpaceMemberDocument.MEMBER);
+
+ ThingDocument[] thingDocuments = basicClient.getThingDocuments(spaceID);
+ assertTrue(thingDocuments.length > 0);
+ assertNotNull(tryToUpdateThing(spaceID, thingDocuments[0], advancedClient));
+ thingDocuments = basicClient.getThingDocuments(spaceID);
+
+ SpaceMemberDocument[] membershipDocs = advancedClient.getSpaceMemberDocuments(spaceID);
assertEquals(1, membershipDocs.length);
assertEquals(USERNAME2, membershipDocs[0].getMemberUsername());
assertEquals(SpaceMemberDocument.MEMBER, membershipDocs[0].getRole());
- webClient1.removeSpaceMember(spaceID, USERNAME2);
- membershipDocs = webClient1.getSpaceMemberDocuments(spaceID);
+ assertNull(tryToUpdateThing(spaceID, thingDocuments[0], basicClient));
+
+ membershipDocs[0].setRole(SpaceMemberDocument.EDITOR);
+ assertNotNull(advancedClient.updateSpaceMember(spaceID, membershipDocs[0]));
+ membershipDocs = advancedClient.getSpaceMemberDocuments(spaceID);
+ assertEquals(1, membershipDocs.length);
+ assertEquals(USERNAME2, membershipDocs[0].getMemberUsername());
+ assertEquals(SpaceMemberDocument.EDITOR, membershipDocs[0].getRole());
+ assertNotNull(tryToUpdateThing(spaceID, thingDocuments[0], basicClient));
+ thingDocuments = basicClient.getThingDocuments(spaceID);
+
+ advancedClient.removeSpaceMember(spaceID, USERNAME2);
+ membershipDocs = advancedClient.getSpaceMemberDocuments(spaceID);
assertEquals(0, membershipDocs.length);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-06 13:16:20
|
Revision: 373
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=373&view=rev
Author: trevorolio
Date: 2007-09-06 06:16:21 -0700 (Thu, 06 Sep 2007)
Log Message:
-----------
Improved the account checks when accepting or denying space modifications via web api.
Avoided a null pointer exception in populate mojo when the populate dir was not configured.
Modified Paths:
--------------
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpacePersistTasks.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
Property Changed:
----------------
maven/trunk/ogoglio-server/
Property changes on: maven/trunk/ogoglio-server
___________________________________________________________________
Name: svn:ignore
-
target
mailTestFiles
tomcat5x.*
+
target
mailTestFiles
tomcat5x.*
velocity.log
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpacePersistTasks.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpacePersistTasks.java 2007-09-06 13:16:17 UTC (rev 372)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/SpacePersistTasks.java 2007-09-06 13:16:21 UTC (rev 373)
@@ -23,6 +23,7 @@
import com.ogoglio.appdev.persist.PersistException;
import com.ogoglio.xml.PossessionDocument;
import com.ogoglio.xml.SpaceDocument;
+import com.ogoglio.xml.SpaceMemberDocument;
public class SpacePersistTasks {
@@ -77,6 +78,7 @@
task.setSessionFactory(sessionFactory);
return (SpaceRecord) task.execute();
}
+
public static SpaceRecord[] findAllSpaces(SessionFactory sessionFactory) throws PersistException {
HibernateTask task = new HibernateTask() {
public Object run(Session hibernateSession) {
@@ -86,7 +88,7 @@
};
task.setSessionFactory(sessionFactory);
return (SpaceRecord[]) task.execute();
- }
+ }
public static SpaceRecord[] findSpacesByOwnerUsername(final String ownerUsername, final SessionFactory sessionFactory) throws PersistException {
HibernateTask task = new HibernateTask() {
@@ -182,7 +184,7 @@
Query possQuery = session.getNamedQuery(PossessionPersistTasks.POSSESSIONS_BY_SPACE_ID);
possQuery.setLong("spaceID", record.getSpaceID());
//??? Should this been done here?
- PossessionRecord[] possessionRecords = (PossessionRecord[])possQuery.list().toArray(new PossessionRecord[0]);
+ PossessionRecord[] possessionRecords = (PossessionRecord[]) possQuery.list().toArray(new PossessionRecord[0]);
for (int i = 0; i < possessionRecords.length; i++) {
possessionRecords[i].setSpaceID(PossessionDocument.NO_SPACE);
possessionRecords[i].setThingID(PossessionDocument.NO_THING);
@@ -192,7 +194,7 @@
return Boolean.TRUE;
}
};
-
+
task.setSessionFactory(sessionFactory);
return Boolean.TRUE == task.execute();
}
@@ -219,8 +221,7 @@
}
if (account != null) {
- if (account.isFrozen()) {
- //if (account.getFrozenUntil() != null && account.getFrozenUntil().getTime() > System.currentTimeMillis()) {
+ if (account.isFrozen()) {
return Boolean.FALSE;
}
@@ -249,4 +250,49 @@
task.setSessionFactory(sessionFactory);
return ((Boolean) task.execute()) == Boolean.TRUE;
}
+
+ public static boolean canWriteSpace(final AccountRecord account, final long spaceID, SessionFactory sessionFactory) throws PersistException {
+ if (account == null) { //happens for guests, who can never write
+ return false;
+ }
+ if(account.isFrozen()){ //tsk tsk
+ return false;
+ }
+
+ HibernateTask task = new HibernateTask() {
+ public Object run(Session hibernateSession) {
+ Query query = hibernateSession.getNamedQuery(SPACE_BY_SPACE_ID);
+ query.setLong("spaceID", spaceID);
+ SpaceRecord space = (SpaceRecord) query.uniqueResult();
+ if (space == null) {
+ return Boolean.FALSE;
+ }
+
+ if (account.getUsername().equals(space.getOwnerUsername())) {
+ return Boolean.TRUE;
+ }
+
+ if (!space.isPublished()) {
+ return Boolean.FALSE;
+ }
+
+ Query membersQuery = hibernateSession.getNamedQuery(SpaceMemberPersistTasks.SPACE_MEMBERS_BY_SPACE_ID);
+ membersQuery.setLong("spaceID", spaceID);
+ SpaceMemberRecord[] members = (SpaceMemberRecord[]) membersQuery.list().toArray(new SpaceMemberRecord[0]);
+
+ for (int i = 0; i < members.length; i++) {
+ if (account.getUsername().equals(members[i].getMemberUsername())) {
+ if(members[i].getRole() == SpaceMemberDocument.BUILDER_ROLE || members[i].getRole() == SpaceMemberDocument.EDITOR_ROLE){
+ return Boolean.TRUE;
+ }
+ return Boolean.FALSE;
+ }
+ }
+
+ return Boolean.FALSE;
+ }
+ };
+ task.setSessionFactory(sessionFactory);
+ return ((Boolean) task.execute()) == Boolean.TRUE;
+ }
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-09-06 13:16:17 UTC (rev 372)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-09-06 13:16:21 UTC (rev 373)
@@ -43,6 +43,7 @@
import com.ogoglio.sim.script.ScriptHTTPRequest;
import com.ogoglio.sim.script.ScriptHTTPResponse;
import com.ogoglio.site.AuthServlet;
+import com.ogoglio.site.AuthenticatedSiteResource;
import com.ogoglio.site.OgoglioServletBase;
import com.ogoglio.site.SpaceServlet;
import com.ogoglio.util.Log;
@@ -90,7 +91,7 @@
public void destroy() {
super.destroy();
sim.cleanup();
- Log.info("Destroy called on SimServlet. Cleaning up sim...");
+ Log.info("Destroy called on SimServlet. Cleaning up sim...");
}
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
@@ -209,15 +210,15 @@
}
public void doDelete(HttpServletRequest request, HttpServletResponse response, String[] pathElementsauthedAccount) throws ServletException, IOException {
- long spaceID = Long.parseLong(pathElementsauthedAccount[pathElementsauthedAccount.length-1]);
-
- SpaceSimulator spaceSim = sim.getOrCreateSpaceSimulator(spaceID);
- spaceSim.setDeleted();
- sim.shutdownSpaceSim(spaceID);
- response.setStatus(HttpServletResponse.SC_OK);
- response.setContentLength(0);
- return;
- }
+ long spaceID = Long.parseLong(pathElementsauthedAccount[pathElementsauthedAccount.length - 1]);
+
+ SpaceSimulator spaceSim = sim.getOrCreateSpaceSimulator(spaceID);
+ spaceSim.setDeleted();
+ sim.shutdownSpaceSim(spaceID);
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.setContentLength(0);
+ return;
+ }
}
private class SettingsResource extends SiteResource {
@@ -760,9 +761,19 @@
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
doScriptService(request, response, pathElements);
}
-
+
public void doPost(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
- doScriptService(request, response, pathElements);
+ try {
+ AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
+ if (authedAccount == null) {
+ response.setStatus(HttpServletResponse.SC_FORBIDDEN);
+ return;
+ }
+ doScriptService(request, response, pathElements);
+ } catch (PersistException e) {
+ e.printStackTrace();
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
}
public void doScriptService(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
@@ -774,39 +785,33 @@
return;
}
- AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (authedAccount == null) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return;
- }
-
SpaceSimulator simulator = sim.getOrCreateSpaceSimulator(spaceRecord);
long thingID = Long.parseLong(pathElements[4]);
ThingDocument thingDoc = simulator.getThingDocument(thingID);
- if(thingDoc == null){
+ if (thingDoc == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
-
+
Map parameterMap = request.getParameterMap();
//Tomcat is f'ing broken in that if there are no parameters it actually adds one with the key String "null" and a "" value: TFS
- if(parameterMap.size() == 1 && (parameterMap.containsKey("null"))){
+ if (parameterMap.size() == 1 && (parameterMap.containsKey("null"))) {
parameterMap = new HashMap();
}
ScriptHTTPResponse scriptResponse = simulator.callThingHTTPService(thingID, request.getMethod(), parameterMap);
response.setStatus(scriptResponse.getStatus());
- if(scriptResponse.getStatus() != 200){
+ if (scriptResponse.getStatus() != 200) {
return;
}
sendStringResponse(scriptResponse.getMessage(), scriptResponse.getMIMEType(), response);
- } catch (PersistException e){
+ } catch (PersistException e) {
e.printStackTrace();
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
- }
+ }
}
-
+
private class ThingResource extends SiteResource {
public ThingResource() {
@@ -825,7 +830,7 @@
}
AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (authedAccount != null && !authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
+ if (authedAccount != null && !SpacePersistTasks.canWriteSpace(authedAccount, requestedSpaceID, getSessionFactory())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -877,18 +882,18 @@
public void doPost(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
try {
- AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (authedAccount == null) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return;
- }
-
long requestedSpaceID = Long.parseLong(pathElements[pathElements.length - 3]);
SpaceRecord spaceRecord = SpacePersistTasks.findSpaceBySpaceID(requestedSpaceID, getSessionFactory());
if (spaceRecord == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
+
+ AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
+ if (authedAccount != null && !SpacePersistTasks.canWriteSpace(authedAccount, requestedSpaceID, getSessionFactory())) {
+ response.setStatus(HttpServletResponse.SC_FORBIDDEN);
+ return;
+ }
SpaceSimulator simulator = sim.getOrCreateSpaceSimulator(spaceRecord);
ThingDocument proposedDoc = new ThingDocument(parseXML(request.getInputStream()));
@@ -930,7 +935,7 @@
}
AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (authedAccount != null && !authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
+ if (authedAccount != null && !SpacePersistTasks.canWriteSpace(authedAccount, requestedSpaceID, getSessionFactory())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -980,15 +985,14 @@
public void doDelete(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
try {
- AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
-
long requestedSpaceID = Long.parseLong(pathElements[2]);
SpaceRecord spaceRecord = SpacePersistTasks.findSpaceBySpaceID(requestedSpaceID, getSessionFactory());
if (spaceRecord == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
- if (authedAccount != null && !authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
+ AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
+ if (authedAccount != null && !SpacePersistTasks.canWriteSpace(authedAccount, requestedSpaceID, getSessionFactory())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -1036,18 +1040,19 @@
public void doPost(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
try {
- AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (authedAccount == null) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return;
- }
-
long requestedSpaceID = Long.parseLong(pathElements[2]);
SpaceRecord spaceRecord = SpacePersistTasks.findSpaceBySpaceID(requestedSpaceID, getSessionFactory());
if (spaceRecord == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
+
+ AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
+ if (authedAccount != null && !SpacePersistTasks.canWriteSpace(authedAccount, requestedSpaceID, getSessionFactory())) {
+ response.setStatus(HttpServletResponse.SC_FORBIDDEN);
+ return;
+ }
+
SpaceSimulator simulator = sim.getOrCreateSpaceSimulator(spaceRecord);
DoorDocument proposedDoc = new DoorDocument(parseXML(request.getInputStream()));
@@ -1148,7 +1153,7 @@
}
AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (!authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
+ if (authedAccount != null && !authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2007-09-06 13:16:17 UTC (rev 372)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2007-09-06 13:16:21 UTC (rev 373)
@@ -58,6 +58,7 @@
public static final String INCLUDE_CHILDREN_PARAM = "children";
private MessageProxy messageProxy = null;
+
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
@@ -102,7 +103,12 @@
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
-
+ String accountLevel = authedAccount.getAccountlevel();
+ if(!AccountDocument.ACCOUNT_LEVEL_ADMIN.equals(accountLevel) && !AccountDocument.ACCOUNT_LEVEL_ADVANCED.equals(accountLevel) && !AccountDocument.ACCOUNT_LEVEL_PRO.equals(accountLevel)){
+ response.setStatus(HttpServletResponse.SC_FORBIDDEN);
+ return;
+ }
+
XMLElement spaceElement = parseXML(request.getInputStream());
if (!SpaceDocument.NAME.equals(spaceElement.getName())) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
@@ -133,21 +139,20 @@
sendStringResponse(DocumentFactory.documentFromRecord(record).toElement().toString(), "text/xml", response);
}
-
public void doPost(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, IOException {
- if(authedAccount == null || !AccountDocument.ACCOUNT_LEVEL_ADMIN.equals(authedAccount.getAccountlevel())) {
+ if (authedAccount == null || !AccountDocument.ACCOUNT_LEVEL_ADMIN.equals(authedAccount.getAccountlevel())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
ServiceStateDocument proposedDoc = new ServiceStateDocument(parseXML(request.getInputStream()));
ServiceStateRecord record = ServiceStateTasks.updateServiceState(proposedDoc, getSessionFactory());
- if(record == null) {
+ if (record == null) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return;
}
sendStringResponse(DocumentFactory.documentFromRecord(record).toElement().toString(), "text/xml", response);
}
-}
+ }
private class SpaceResource extends AuthenticatedSiteResource {
public SpaceResource() {
@@ -191,7 +196,7 @@
return;
}
- if (!canRead(authedAccount, spaceRecord)) {
+ if (!canUseMethodOnSpace(request.getMethod(), authedAccount, spaceRecord)) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -235,7 +240,7 @@
return;
}
- if (authedAccount == null || !authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
+ if (authedAccount == null || !spaceRecord.getOwnerUsername().equals(authedAccount.getUsername())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -261,6 +266,15 @@
}
}
+ private boolean canUseMethodOnSpace(String method, AccountRecord authedAccount, SpaceRecord spaceRecord) throws PersistException {
+ if(("HEAD".equals(method) || "GET".equals(method))){
+ return SpacePersistTasks.canReadSpace(authedAccount, spaceRecord.getSpaceID(), getSessionFactory());
+ } else if("POST".equals(method) || "DELETE".equals(method) || "PUT".equals(method)){
+ return SpacePersistTasks.canWriteSpace(authedAccount, spaceRecord.getSpaceID(), getSessionFactory());
+ }
+ return false;
+ }
+
private class DoorsResource extends DescendingSiteResource { //NOTE this will proxy eveything below "door" in the URL space
public DoorsResource() {
@@ -289,11 +303,10 @@
}
AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (!canRead(authedAccount, spaceRecord)) {
+ if(!canUseMethodOnSpace(method, authedAccount, spaceRecord)){
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
-
SimRecord simRecord = SpacePersistTasks.findOrAssignSim(spaceRecord, getSessionFactory());
if (simRecord == null) {
Log.error("Could not assign a sim to space " + spaceRecord.getSpaceID());
@@ -349,7 +362,7 @@
}
AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (!canRead(authedAccount, spaceRecord)) {
+ if(!canUseMethodOnSpace(method, authedAccount, spaceRecord)){
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -385,10 +398,6 @@
}
}
- private boolean canRead(AccountRecord authedAccount, SpaceRecord spaceRecord) throws PersistException {
- return SpacePersistTasks.canReadSpace(authedAccount, spaceRecord.getSpaceID(), getSessionFactory());
- }
-
private class LogResource extends DescendingSiteResource { //NOTE this will proxy eveything below "log" in the URL space
public LogResource() {
@@ -397,12 +406,6 @@
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws IOException {
try {
- AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (authedAccount == null) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return;
- }
-
long spaceID = Long.parseLong(pathElements[1]);
SpaceRecord spaceRecord = SpacePersistTasks.findSpaceBySpaceID(spaceID, getSessionFactory());
if (spaceRecord == null) {
@@ -410,7 +413,8 @@
return;
}
- if (!canRead(authedAccount, spaceRecord)) {
+ AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
+ if(!canUseMethodOnSpace(request.getMethod(), authedAccount, spaceRecord)){
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -466,11 +470,6 @@
private void doProxy(HttpServletRequest request, String method, HttpServletResponse response, String[] pathElements) throws IOException {
try {
- AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (authedAccount == null) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return;
- }
long spaceID = Long.parseLong(pathElements[1]);
SpaceRecord spaceRecord = SpacePersistTasks.findSpaceBySpaceID(spaceID, getSessionFactory());
if (spaceRecord == null) {
@@ -478,7 +477,8 @@
return;
}
- if (!authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
+ AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
+ if(authedAccount == null || !spaceRecord.getOwnerUsername().equals(authedAccount.getUsername())){
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -538,7 +538,7 @@
}
AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
- if (!canRead(authedAccount, spaceRecord)) {
+ if(!canUseMethodOnSpace(request.getMethod(), authedAccount, spaceRecord)){
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -592,7 +592,7 @@
return;
}
- if (!authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
+ if (authedAccount == null || !authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -614,16 +614,11 @@
return;
}
- if (!authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
+ if (authedAccount == null || !authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
- if (!canRead(authedAccount, spaceRecord)) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return;
- }
-
String memberUsername = pathElements[pathElements.length - 1];
SpaceMemberRecord memberRec = SpaceMemberPersistTasks.findSpaceMemberByUsername(spaceID, memberUsername, sessionFactory);
if (memberRec == null) {
@@ -646,16 +641,11 @@
return;
}
- if (!authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
+ if (authedAccount == null || !authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
- if (!canRead(authedAccount, spaceRecord)) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return;
- }
-
String memberUsername = pathElements[pathElements.length - 1];
SpaceMemberRecord memberRec = SpaceMemberPersistTasks.findSpaceMemberByUsername(spaceID, memberUsername, getSessionFactory());
if (memberRec == null) {
@@ -687,16 +677,11 @@
return;
}
- if (!authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
+ if (authedAccount == null || !authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
- if (!canRead(authedAccount, spaceRecord)) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return;
- }
-
SpaceMemberDocument newMemberDoc = new SpaceMemberDocument(parseXML(request.getInputStream()));
SpaceMemberRecord rec = SpaceMemberPersistTasks.createSpaceMember(spaceID, newMemberDoc.getMemberUsername(), newMemberDoc.isBanned(), getSessionFactory());
@@ -716,16 +701,11 @@
return;
}
- if (!authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
+ if (authedAccount == null || !authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
- if (!canRead(authedAccount, spaceRecord)) {
- response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- return;
- }
-
XMLElement result = new XMLElement("list");
SpaceMemberRecord[] memberRecords = SpaceMemberPersistTasks.findSpaceMembersBySpaceID(spaceRecord.getSpaceID(), getSessionFactory());
for (int i = 0; i < memberRecords.length; i++) {
@@ -743,7 +723,7 @@
}
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, ServletException, IOException {
- if (!AccountDocument.ACCOUNT_LEVEL_ADMIN.equals(authedAccount.getAccountlevel())) {
+ if (authedAccount == null || !AccountDocument.ACCOUNT_LEVEL_ADMIN.equals(authedAccount.getAccountlevel())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-06 13:16:14
|
Revision: 372
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=372&view=rev
Author: trevorolio
Date: 2007-09-06 06:16:17 -0700 (Thu, 06 Sep 2007)
Log Message:
-----------
Improved the account checks when accepting or denying space modifications via web api.
Avoided a null pointer exception in populate mojo when the populate dir was not configured.
Property Changed:
----------------
maven/trunk/ogoglio/
Property changes on: maven/trunk/ogoglio
___________________________________________________________________
Name: svn:ignore
- target
tomcat5x.out
velocity.log
+ target
tomcat5x.*
velocity.log
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2007-09-05 23:18:47
|
Revision: 371
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=371&view=rev
Author: iansmith
Date: 2007-09-05 16:18:49 -0700 (Wed, 05 Sep 2007)
Log Message:
-----------
New Mojos for populate and reverse populate.
Modified Paths:
--------------
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
maven/trunk/ogoglio-server/pom.xml
maven/trunk/ogoglio-server/src/main/resources/populate/space-1
Added Paths:
-----------
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/OgServiceMojoBase.java
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/ReverseMojo.java
Added: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/OgServiceMojoBase.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/OgServiceMojoBase.java (rev 0)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/OgServiceMojoBase.java 2007-09-05 23:18:49 UTC (rev 371)
@@ -0,0 +1,98 @@
+package com.ogoglio.plugin;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import com.ogoglio.client.WebAPIAuthenticator;
+import com.ogoglio.client.WebAPIClient;
+import com.ogoglio.client.WebAPIClientWire;
+import com.ogoglio.client.WebAPIDescriptor;
+import com.ogoglio.xml.TemplateDocument;
+
+public abstract class OgServiceMojoBase extends AbstractMojo {
+
+ protected static final String SPACE_PREFIX = "space-";
+ protected static final String TEMPLATE_PREFIX = "template-";
+ /**
+ * @parameter
+ */
+ protected File populateDir;
+ /**
+ * @parameter
+ */
+ protected String serviceURI;
+ /**
+ * @parameter
+ */
+ protected String username;
+ /**
+ * @parameter
+ */
+ private String password;
+
+ protected WebAPIClient validateArgsAndConnect() {
+ if (populateDir == null) {
+ getLog().info("No populate baseDir given. Mojo ignored.");
+ return null;
+ }
+
+ if ((!populateDir.exists()) || (!populateDir.isDirectory())
+ || (!populateDir.canRead())) {
+ getLog().error(
+ "Unable to access base dir:" + populateDir.getAbsolutePath());
+ return null;
+ }
+
+ if (serviceURI == null) {
+ getLog().info("No populate serviceURI given. Mojo ignored.");
+ return null;
+ }
+ try {
+ WebAPIClientWire wire = new WebAPIClientWire();
+ WebAPIDescriptor descriptor = new WebAPIDescriptor(new URI(
+ serviceURI));
+ WebAPIAuthenticator auth = new WebAPIAuthenticator(wire,
+ descriptor, username, password);
+ WebAPIClient client = new WebAPIClient(descriptor, auth, wire);
+ return client;
+
+ } catch (URISyntaxException e) {
+ getLog().error("Bad URI (" + serviceURI + ")", e);
+ } catch (IOException e) {
+ getLog().error("Unable to connect to service (" + serviceURI + ")",
+ e);
+ }
+ // some kind of exception
+ return null;
+ }
+
+ protected TemplateDocument fileNameToTemplateDocument(WebAPIClient client, File tempFile)
+ throws IOException {
+ String templateName = fileToTemplateName(tempFile);//.obj
+ TemplateDocument doc = client.createTemplate(templateName);
+ return doc;
+ }
+
+ protected String fileToTemplateName(File tempFile) {
+ return tempFile.getName().substring(0, tempFile.getName().length() - 4);
+ }
+
+ protected int dirNameToTemplateNumber(File candidate)
+ throws MojoExecutionException {
+ int n = -188;
+ String num = candidate.getName().substring(TEMPLATE_PREFIX.length());
+ try {
+ n = Integer.parseInt(num);
+ } catch (NumberFormatException e) {
+ throw new MojoExecutionException("Badly formed template name in populate directory:"+candidate.getName());
+ }
+ return n;
+
+ }
+
+}
Modified: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java 2007-09-05 22:32:42 UTC (rev 370)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java 2007-09-05 23:18:49 UTC (rev 371)
@@ -1,223 +1,163 @@
package com.ogoglio.plugin;
-import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileReader;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import nanoxml.XMLElement;
-import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
-import com.agical.rmock.core.util.StringUtils;
-import com.ogoglio.client.WebAPIAuthenticator;
import com.ogoglio.client.WebAPIClient;
-import com.ogoglio.client.WebAPIClientWire;
-import com.ogoglio.client.WebAPIDescriptor;
import com.ogoglio.util.StreamUtils;
import com.ogoglio.xml.PossessionDocument;
import com.ogoglio.xml.SpaceDocument;
import com.ogoglio.xml.TemplateDocument;
+import com.ogoglio.xml.ThingDocument;
/**
* @goal populate
*/
-public class PopulateMojo extends AbstractMojo {
- /**
- * @parameter
- */
- private File baseDir;
- /**
- * @parameter
- */
- private String serviceURI;
- /**
- * @parameter
- */
- private String username;
- /**
- * @parameter
- */
- private String password;
+public class PopulateMojo extends OgServiceMojoBase {
+ private HashMap<Long, Long> templateIdMap = new HashMap<Long, Long>();
- private HashMap<Long,Long> templateIdMap = new HashMap<Long,Long>();
- private List<SpaceDocument> spaces=new ArrayList<SpaceDocument>();
-
- private static final String TEMPLATE_PREFIX="template-";
- private static final String SPACE_PREFIX="space-";
+ private List<SpaceDocument> spaces = new ArrayList<SpaceDocument>();
- public void execute() throws MojoExecutionException {
- if (baseDir==null) {
- getLog().info("No populate baseDir given. No population done.");
- return;
- }
-
- if ((!baseDir.exists()) || (!baseDir.isDirectory()) || (!baseDir.canRead())) {
- getLog().error("Unable to access base dir:"+baseDir.getAbsolutePath());
- return;
- }
-
- if (serviceURI==null) {
- getLog().info("No populate serviceURI given. No population done.");
- return;
- }
-
- try {
- WebAPIClientWire wire=new WebAPIClientWire();
- WebAPIDescriptor descriptor=new WebAPIDescriptor(new URI(serviceURI));
- WebAPIAuthenticator auth=new WebAPIAuthenticator(wire,descriptor,username,password);
- WebAPIClient client=new WebAPIClient(descriptor,auth,wire);
- //we are now ready to upload
-
- File[] templates = baseDir.listFiles();
-
- for (int i=0; i<templates.length;++i) {
- File candidate=templates[i];
- if (candidate.getName().startsWith(TEMPLATE_PREFIX)) {
- uploadTemplate(client,candidate);
- } else if (candidate.getName().startsWith(SPACE_PREFIX)) {
- readSpace(client,candidate);
- } else {
- if (!candidate.getName().equals(".svn")) {
- getLog().warn("Unable to process in populate:"+candidate.getAbsolutePath());
- }
- }
- }
-
- patchSpaces(client);
-
- } catch (URISyntaxException e) {
- throw new MojoExecutionException("Bad URI syntax("+serviceURI+")",e);
- } catch (IOException e) {
- throw new MojoExecutionException("IO Exception (possibly auth?"+username+","+password+")",e);
- }
- }
+ public void execute() throws MojoExecutionException {
+ WebAPIClient client = validateArgsAndConnect();
- private void patchSpaces(WebAPIClient client) throws MojoExecutionException {
- SpaceDocument fakeSpaceDoc,realSpaceDoc;
-
- for (int i=0; i<spaces.size();++i) {
- fakeSpaceDoc=spaces.get(i);
- try {
- realSpaceDoc = client.createSpace(fakeSpaceDoc.getDisplayName());
- TemplateDocument templates[] = fakeSpaceDoc.getTemplateDocuments();
- for (int j=0; j<templates.length;++j) {
- long trueId = templateIdMap.get(new Long(templates[j].getTemplateID())).longValue();
- PossessionDocument possDoc = client.createPossession(trueId);
- client.addPossessionToSpace(possDoc.getPossessionID(), fakeSpaceDoc.getSpaceID());
- TemplateDocument realTemplateDoc=client.getTemplateDocument(username, trueId);
- getLog().info("Added Template "+realTemplateDoc.getDisplayName()+" to space "+realSpaceDoc.getDisplayName());
- }
- //client.setSpacePublished(realSpaceDoc.getSpaceID(), fakeSpaceDoc.getSpacePublished());
- long realSpaceID = realSpaceDoc.getSpaceID();
- client.setSpaceSeaLevel(realSpaceID, fakeSpaceDoc.getSeaLevel());
- client.setSpaceMaxGuests(realSpaceID, fakeSpaceDoc.getMaxGuests());
- client.setSpaceDisplayName(realSpaceID, fakeSpaceDoc.getDisplayName());
- client.setSpaceSeaLevel(realSpaceID, fakeSpaceDoc.getSeaLevel());
- } catch (IOException e) {
- throw new MojoExecutionException("IOException patching space ("+fakeSpaceDoc.getDisplayName()+":"+fakeSpaceDoc.getSpaceID()+")",e);
- }
- }
-
- }
+ File[] templates = populateDir.listFiles();
- private void readSpace(WebAPIClient client, File candidate) throws MojoExecutionException{
- String name = candidate.getName();
- String num= name.substring(SPACE_PREFIX.length());
- int spaceFakeId=-189;
- try {
- spaceFakeId = Integer.parseInt(num);
- } catch (NumberFormatException e) {
- getLog().error("Badly formed space name:"+name+". Ignoring.");
- }
- if (spaceFakeId==-189) {
- return;
- }
- try {
- FileInputStream inputStream = new FileInputStream(candidate);
- String docContent = StreamUtils.readInput(inputStream);
- SpaceDocument doc=new SpaceDocument(XMLElement.parseElementFromString(docContent));
- spaces.add(doc);
- inputStream.close();
- } catch (IOException e) {
- throw new MojoExecutionException("IO Error reading space",e);
- }
-
-
- }
+ for (int i = 0; i < templates.length; ++i) {
+ File candidate = templates[i];
+ if (candidate.getName().startsWith(TEMPLATE_PREFIX)) {
+ uploadTemplate(client, candidate);
+ } else if (candidate.getName().startsWith(SPACE_PREFIX)) {
+ readSpace(client, candidate);
+ } else {
+ if (!candidate.getName().equals(".svn")) {
+ getLog().warn("Unable to process in populate:" + candidate.getAbsolutePath());
+ }
+ }
+ }
- private void uploadTemplate(WebAPIClient client, File candidate) throws MojoExecutionException{
- String name = candidate.getName();
- String num= name.substring(TEMPLATE_PREFIX.length());
+ patchSpaces(client);
+ }
- int templateFakeId=-188;
- try {
- templateFakeId = Integer.parseInt(num);
- } catch (NumberFormatException e) {
- getLog().error("Badly formed template name:"+name+". Ignoring.");
- }
- if (templateFakeId==-188) {
- return;
- }
- getLog().info("Uploading template #"+templateFakeId+" to "+serviceURI);
- File[] objs=candidate.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".obj");
- }
- });
- if (objs.length!=1) {
- throw new MojoExecutionException("Badly formed directory "+name+". Should have 1 obj file but has "+objs.length);
- }
- try {
- String templateName=objs[0].getName();
- InputStream objStream=new FileInputStream(objs[0]);
- TemplateDocument doc = client.createTemplate(templateName.substring(0,templateName.length()-4));//.obj
- client.uploadTemplateGeometryStream(username,doc.getTemplateID(),0,objStream);
+ private void patchSpaces(WebAPIClient client) throws MojoExecutionException {
+ SpaceDocument fakeSpaceDoc, realSpaceDoc;
- templateIdMap.put(new Long(templateFakeId), new Long(doc.getTemplateID()));
- getLog().info("Created template from "+objs[0].getName()+
- " ["+templateFakeId+" -> "+doc.getTemplateID()+"]");
-
- File[] notObjs=candidate.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return !name.endsWith(".obj");
- }
- });
- for (int i=0; i<notObjs.length; ++i) {
- File supportFile = notObjs[i];
- String supportName = supportFile.getName();
- if (supportFile.getName().endsWith(".js")) {
- String script = StreamUtils.readInput(new FileInputStream(supportFile));
- client.updateTemplateScript(username, doc.getTemplateID(), script);
- getLog().info("Uploaded script file:"+supportName);
- } else {
- if ((!(supportName.endsWith(".gif"))) && (!(supportName.endsWith(".jpg"))) &&
- (!(supportName.endsWith(".png"))) && (!(supportName.endsWith(".mtl")))) {
-
- if ((!(supportName.endsWith(".blend"))) && (!(supportName.endsWith(".3DS"))) &&
- (!(supportName.endsWith(".txt"))) && (!(supportName.equals(".svn")))) {
- getLog().warn("Don't know what to do with file "+supportName+". Ignoring.");
- }
- continue;
- }
- FileInputStream supportStream = new FileInputStream(supportFile);
- client.uploadTemplateResourceStream(username, doc.getTemplateID(), supportName, supportStream);
- getLog().info("Uploaded support file:"+supportName);
- }
- }
-
- } catch (IOException e) {
- throw new MojoExecutionException("IO Error in upload",e);
- }
- }
+ for (int i = 0; i < spaces.size(); ++i) {
+ fakeSpaceDoc = spaces.get(i);
+ try {
+ realSpaceDoc = client.createSpace(fakeSpaceDoc.getDisplayName());
+ ThingDocument things[] = fakeSpaceDoc.getThingDocuments();
+ for (int j = 0; j < things.length; ++j) {
+ ThingDocument thing = things[j];
+ PossessionDocument possDoc = client.createPossession(templateIdMap.get(thing.getTemplateID()));
+ possDoc = client.addPossessionToSpace(possDoc.getPossessionID(), realSpaceDoc.getSpaceID());
+ ThingDocument newThingDoc = client.getThingDocument(realSpaceDoc.getSpaceID(), possDoc.getThingID());
+ newThingDoc.setOrientation(thing.getOrientation());
+ newThingDoc.setTranslation(thing.getTranslation());
+ newThingDoc.setSplinePath(thing.getSplinePath());
+ newThingDoc.setScale(thing.getScale());
+ client.updateThing(realSpaceDoc.getSpaceID(), newThingDoc);
+ }
+ long realSpaceID = realSpaceDoc.getSpaceID();
+ client.setSpaceSeaLevel(realSpaceID, fakeSpaceDoc.getSeaLevel());
+ client.setSpaceMaxGuests(realSpaceID, fakeSpaceDoc.getMaxGuests());
+ client.setSpaceDisplayName(realSpaceID, fakeSpaceDoc.getDisplayName());
+ client.setSpaceSeaLevel(realSpaceID, fakeSpaceDoc.getSeaLevel());
+ getLog().info("Patched up space "+realSpaceDoc.getDisplayName());
+
+ } catch (IOException e) {
+ throw new MojoExecutionException("IOException patching space (" + fakeSpaceDoc.getDisplayName() + ":" + fakeSpaceDoc.getSpaceID() + ")", e);
+ }
+ }
+
+ }
+
+ private void readSpace(WebAPIClient client, File candidate) throws MojoExecutionException {
+ String name = candidate.getName();
+ String num = name.substring(SPACE_PREFIX.length());
+ int spaceFakeId = -189;
+ try {
+ spaceFakeId = Integer.parseInt(num);
+ } catch (NumberFormatException e) {
+ getLog().error("Badly formed space name:" + name + ". Ignoring.");
+ }
+ if (spaceFakeId == -189) {
+ return;
+ }
+ try {
+ FileInputStream inputStream = new FileInputStream(candidate);
+ String docContent = StreamUtils.readInput(inputStream);
+ SpaceDocument doc = new SpaceDocument(XMLElement.parseElementFromString(docContent));
+ spaces.add(doc);
+ inputStream.close();
+ } catch (IOException e) {
+ throw new MojoExecutionException("IO Error reading space", e);
+ }
+
+ }
+
+ private void uploadTemplate(WebAPIClient client, File candidate) throws MojoExecutionException {
+ String name = candidate.getName();
+ int templateFakeId = dirNameToTemplateNumber(candidate);
+
+ getLog().info("Uploading template #" + templateFakeId + " to " + serviceURI);
+ File[] objs = candidate.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".obj");
+ }
+ });
+ if (objs.length != 1) {
+ throw new MojoExecutionException("Badly formed directory " + name + ". Should have 1 obj file but has " + objs.length);
+ }
+ try {
+ TemplateDocument doc = fileNameToTemplateDocument(client, objs[0]);
+
+ InputStream objStream = new FileInputStream(objs[0]);
+ client.uploadTemplateGeometryStream(username, doc.getTemplateID(), 0, objStream);
+
+ templateIdMap.put(new Long(templateFakeId), new Long(doc.getTemplateID()));
+ getLog().info("Created template from " + objs[0].getName() + " [" + templateFakeId + " -> " + doc.getTemplateID() + "]");
+
+ File[] notObjs = candidate.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return !name.endsWith(".obj");
+ }
+ });
+ for (int i = 0; i < notObjs.length; ++i) {
+ File supportFile = notObjs[i];
+ String supportName = supportFile.getName();
+ if (supportFile.getName().endsWith(".js")) {
+ String script = StreamUtils.readInput(new FileInputStream(supportFile));
+ client.updateTemplateScript(username, doc.getTemplateID(), script);
+ getLog().info("Uploaded script file:" + supportName);
+ } else {
+ if ((!(supportName.endsWith(".gif"))) && (!(supportName.endsWith(".jpg"))) && (!(supportName.endsWith(".png"))) && (!(supportName.endsWith(".mtl")))) {
+
+ if ((!(supportName.endsWith(".blend"))) && (!(supportName.endsWith(".3DS"))) && (!(supportName.endsWith(".txt"))) && (!(supportName.equals(".svn")))) {
+ getLog().warn("Don't know what to do with file " + supportName + ". Ignoring.");
+ }
+ continue;
+ }
+ FileInputStream supportStream = new FileInputStream(supportFile);
+ client.uploadTemplateResourceStream(username, doc.getTemplateID(), supportName, supportStream);
+ getLog().info("Uploaded support file:" + supportName);
+ }
+ }
+
+ } catch (IOException e) {
+ throw new MojoExecutionException("IO Error in upload", e);
+ }
+ }
+
}
\ No newline at end of file
Added: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/ReverseMojo.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/ReverseMojo.java (rev 0)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/ReverseMojo.java 2007-09-05 23:18:49 UTC (rev 371)
@@ -0,0 +1,158 @@
+package com.ogoglio.plugin;
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.HashMap;
+
+import nanoxml.XMLElement;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+import com.ogoglio.client.WebAPIClient;
+import com.ogoglio.util.StreamUtils;
+import com.ogoglio.xml.SpaceDocument;
+import com.ogoglio.xml.TemplateDocument;
+import com.ogoglio.xml.ThingDocument;
+
+/**
+ * @goal reverse
+ */
+public class ReverseMojo extends OgServiceMojoBase {
+ /**
+ * @parameter
+ */
+ private File reverseFile;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ WebAPIClient client = validateArgsAndConnect();
+ HashMap<String,Long> displayNameToLocalId = new HashMap<String, Long>();
+ HashMap<Long,Long> remoteIdTolocalId = new HashMap<Long, Long>();
+
+ long localThingId=1,localPossId=1;
+
+ if (client==null) {
+ return;
+ }
+
+ if (reverseFile==null) {
+ getLog().info("No reverse file configured. Mojo ignored.");
+ return;
+ }
+
+ if ((!reverseFile.isFile()) || (!reverseFile.canRead())) {
+ throw new MojoExecutionException("Can't read reverse file "+reverseFile.getAbsolutePath());
+ }
+
+ SpaceDocument origSpaceDoc = buildTemplateMaps(displayNameToLocalId,
+ remoteIdTolocalId);
+
+ int localSpaceId=getNextLocalSpaceId();
+
+ SpaceDocument result = rewhackSpaceDocument(remoteIdTolocalId,
+ localThingId, localPossId, origSpaceDoc, localSpaceId);
+
+ try {
+ writeSpaceDoc(result,localSpaceId);
+ } catch (IOException e) {
+ throw new MojoExecutionException(e,"IOException","can't write output file");
+ }
+ }
+
+ private SpaceDocument rewhackSpaceDocument(
+ HashMap<Long, Long> remoteIdTolocalId, long localThingId,
+ long localPossId, SpaceDocument origSpaceDoc, int localSpaceId) {
+ SpaceDocument result = new SpaceDocument(localSpaceId,origSpaceDoc.getDisplayName(),origSpaceDoc.getOwnerUsername(),
+ true /*origSpaceDoc.getPublished()*/,origSpaceDoc.getMaxGuests(),origSpaceDoc.getDisplaySea(),
+ origSpaceDoc.getSeaLevel(),origSpaceDoc.getSimID());
+
+ ThingDocument[] things=origSpaceDoc.getThingDocuments();
+ for (int i=0; i<things.length;++i) {
+ ThingDocument remoteThing=things[i];
+ ThingDocument localThing=new ThingDocument(localThingId++,remoteThing.getDisplayName(),
+ remoteIdTolocalId.get(new Long(remoteThing.getTemplateID())).longValue(),
+ remoteThing.getTemplateOwner(),remoteThing.getOwnerUsername(),
+ localPossId++, remoteThing.getTransform(),remoteThing.getSplinePath());
+ result.addThingDocument(localThing);
+ getLog().info("Fixed thing "+localThing.getDisplayName());
+ }
+ return result;
+ }
+
+ private SpaceDocument buildTemplateMaps(
+ HashMap<String, Long> displayNameToLocalId,
+ HashMap<Long, Long> remoteIdTolocalId)
+ throws MojoExecutionException, MojoFailureException {
+ SpaceDocument origSpaceDoc=null;
+ try {
+ String revContent = StreamUtils.readInput(new FileInputStream(reverseFile));
+ origSpaceDoc = new SpaceDocument(XMLElement.parseElementFromString(revContent));
+ } catch (IOException e) {
+ throw new MojoExecutionException(e,"IOException","Can't read space document "+reverseFile.getAbsolutePath());
+ }
+ File[] templateDirs= populateDir.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.startsWith(TEMPLATE_PREFIX);
+ }
+ });
+ File[] objectFiles=new File[templateDirs.length];
+ for (int i=0; i< templateDirs.length;++i) {
+ File[] objs = templateDirs[i].listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".obj");
+ }
+ });
+ if (objs.length!=1) {
+ throw new MojoExecutionException("Directory "+templateDirs[i].getName()+" has wrong number of object files:"+objs.length);
+ }
+ objectFiles[i]=objs[0];
+ }
+ for (int i=0; i<objectFiles.length;++i) {
+ String tName = fileToTemplateName(objectFiles[i]);
+ int num = dirNameToTemplateNumber(objectFiles[i].getParentFile());
+ displayNameToLocalId.put(tName,new Long(num));
+ }
+ TemplateDocument[] mentioned = origSpaceDoc.getTemplateDocuments();
+ for (int i=0; i<mentioned.length;++i) {
+ TemplateDocument candidate = mentioned[i];
+ String remoteDisplayName = candidate.getDisplayName();
+ if (!displayNameToLocalId.containsKey(remoteDisplayName)) {
+ throw new MojoFailureException("Can't find a local template with display name "+remoteDisplayName);
+ }
+ Long local=displayNameToLocalId.get(remoteDisplayName);
+ remoteIdTolocalId.put(new Long(candidate.getTemplateID()), local);
+ getLog().info("Mapped "+remoteDisplayName+" ["+candidate.getTemplateID()+" ->"+local+"]");
+ }
+ return origSpaceDoc;
+ }
+
+ private void writeSpaceDoc(SpaceDocument result, int localSpaceId) throws IOException {
+ FileWriter wr=new FileWriter(new File(populateDir,SPACE_PREFIX+localSpaceId));
+ wr.write(result.toString());
+ wr.close();
+ getLog().info("Wrote new space document:"+(SPACE_PREFIX+localSpaceId));
+ }
+
+ private int getNextLocalSpaceId() throws MojoExecutionException {
+ int attempt=1,TOO_BIG=500;
+ File f;
+ do {
+ attempt++;
+ f=new File(populateDir,SPACE_PREFIX+(attempt));
+ //sanity
+ if (attempt==TOO_BIG) {
+ break;
+ }
+ } while (f.exists());
+ if (attempt==TOO_BIG) {
+ throw new MojoExecutionException("Don't know why but there are way too many space documents...aborting at "+attempt);
+ }
+ return attempt-1;
+ }
+
+}
Modified: maven/trunk/ogoglio-server/pom.xml
===================================================================
--- maven/trunk/ogoglio-server/pom.xml 2007-09-05 22:32:42 UTC (rev 370)
+++ maven/trunk/ogoglio-server/pom.xml 2007-09-05 23:18:49 UTC (rev 371)
@@ -190,7 +190,7 @@
</webResources>
</configuration>
</plugin>
- <!-- Our plugin config for building templates -->
+ <!-- Our plugin config for building templates and doing stuffing of data -->
<plugin>
<groupId>com.ogoglio</groupId>
<artifactId>og-plugin</artifactId>
@@ -201,7 +201,8 @@
<serviceURI>${ogoglio.baseURL}</serviceURI>
<username>${ogoglio.bootstrapUser}</username>
<password>${ogoglio.bootstrapUserPW}</password>
- <baseDir>src/main/resources/populate</baseDir>
+ <populateDir>src/main/resources/populate</populateDir>
+ <reverseFile>/tmp/reverse.xml</reverseFile>
<goalPrefix>og</goalPrefix>
</configuration>
Modified: maven/trunk/ogoglio-server/src/main/resources/populate/space-1
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/populate/space-1 2007-09-05 22:32:42 UTC (rev 370)
+++ maven/trunk/ogoglio-server/src/main/resources/populate/space-1 2007-09-05 23:18:49 UTC (rev 371)
@@ -1,201 +1,52 @@
<space ownerusername="library" sealevel="0.0" simid="1"
- displayname="Tech Office Space" maxguests="0" displaysea="false"
- spaceid="1" published="false">
- <thing templateid="42" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
- scalez="1.0" displayname="TV" scaley="1.0" templateowner="library"
- scalex="1.0" possessionid="2" thingid="2" z="10.0" y="0.0" x="0.0"
- ownerusername="library">
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder.005" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Tube.001_Tube.002" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder.001" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.002_Mesh" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder.003" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Tube_Tube.001" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Sphere_Sphere.001" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder.002" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder.004" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- </thing>
- <thing templateid="28" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
- scalez="1.0" displayname="WhiteBoard" scaley="1.0"
- templateowner="library" scalex="1.0" possessionid="3" thingid="4"
- z="-10.0" y="0.0" x="0.0" ownerusername="library">
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.003" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube" scaley="1.0" scalex="1.0" z="0.0" y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.002" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.004" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.001" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <page rz="-0.0" ry="1.0" width="4.0" pageid="1" rx="0.0"
- rw="0.0" scalez="1.0" scaley="1.0" scalex="1.0"
- contenttype="text/plain" z="0.1" y="2.0" x="0.0" height="2.0" />
- </thing>
- <thing templateid="21" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
- scalez="1.0" displayname="memex" scaley="1.0" templateowner="library"
- scalex="1.0" possessionid="1" thingid="1" z="0.0" y="0.0" x="-10.0"
- ownerusername="library">
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.008_Black" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.001_Cube.002" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder.003" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder.010" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.005_Cube.001" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder.008" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube" scaley="1.0" scalex="1.0" z="0.0" y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder.004" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder.009" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.004_Cube.005" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder.007" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder.005" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.003_Cube.004" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder.001" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.012_Cube.010" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.002_Cube.003" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.011_Cube.006" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder.006" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.010_Black.002" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.009_Black.001" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cylinder.002" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.007_Metal" scaley="1.0" scalex="1.0" z="0.0" y="0.0"
- x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Cube.006_Cube.007" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- </thing>
- <thing templateid="25" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
- scalez="1.0" displayname="OfficeDesk" scaley="1.0"
- templateowner="library" scalex="1.0" possessionid="4" thingid="3"
- z="0.0" y="0.0" x="10.0" ownerusername="library">
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="drawer2_07_-_Default" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="ChamferBox_02_-_Defau" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="feet_02_-_Default" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="drawer3_02_-_Default" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Object07_02_-_Default" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="long_drawe_01_-_Defau" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="drawer4_02_-_Default" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="Object07_03_-_Default" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- <shape rz="0.0" ry="0.0" rx="0.0" rw="1.0" scalez="1.0"
- shapename="large_draw_02_-_Defau" scaley="1.0" scalex="1.0" z="0.0"
- y="0.0" x="0.0" />
- </thing>
- <template ownerusername="library" templateid="28"
- displayname="WhiteBoard">
- <scriptfile
- lastmodifiedUTC="Tuesday, September 4, 2007 7:01:24 PM PDT" />
- <geometry levelofdetail="0"
- lastmodifiedUTC="Tuesday, September 4, 2007 7:01:24 PM PDT" />
- <supportfile filename="WhiteBoard.mtl"
- lastmodifiedUTC="Tuesday, September 4, 2007 7:01:24 PM PDT" />
- </template>
- <template ownerusername="library" templateid="42"
- displayname="TV">
- <scriptfile
- lastmodifiedUTC="Tuesday, September 4, 2007 7:01:23 PM PDT" />
- <geometry levelofdetail="0"
- lastmodifiedUTC="Tuesday, September 4, 2007 7:01:23 PM PDT" />
- <supportfile filename="TV.mtl"
- lastmodifiedUTC="Tuesday, September 4, 2007 7:01:24 PM PDT" />
- </template>
- <template ownerusername="library" templateid="25"
- displayname="OfficeDesk">
- <supportfile filename="OfficeDesk.mtl"
- lastmodifiedUTC="Tuesday, September 4, 2007 7:01:24 PM PDT" />
- <geometry levelofdetail="0"
- lastmodifiedUTC="Tuesday, September 4, 2007 7:01:24 PM PDT" />
- </template>
- <template ownerusername="library" templateid="21"
- displayname="memex">
- <geometry levelofdetail="0"
- lastmodifiedUTC="Tuesday, September 4, 2007 7:01:23 PM PDT" />
- <supportfile filename="memex.mtl"
- lastmodifiedUTC="Tuesday, September 4, 2007 7:01:23 PM PDT" />
- </template>
-</space>
\ No newline at end of file
+ displayname="Sitting" maxguests="0" displaysea="false" spaceid="1"
+ published="true">
+ <thing templateid="9" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
+ scalez="1.0" displayname="EamesLoungeChair" scaley="1.0"
+ templateowner="library" scalex="1.0" possessionid="1" thingid="1"
+ z="-5.0" y="0.0" x="-18.0" ownerusername="library" />
+ <thing templateid="24" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
+ scalez="1.0" displayname="OfficeChair" scaley="1.0"
+ templateowner="library" scalex="1.0" possessionid="2" thingid="2"
+ z="-5.0" y="0.0" x="-15.0" ownerusername="library" />
+ <thing templateid="18" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
+ scalez="1.0" displayname="LeCorbusierRecliner" scaley="1.0"
+ templateowner="library" scalex="1.0" possessionid="3" thingid="3"
+ z="-5.0" y="0.0" x="-9.0" ownerusername="library" />
+ <thing templateid="19" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
+ scalez="1.0" displayname="LeCorbusierSofa" scaley="1.0"
+ templateowner="library" scalex="1.0" possessionid="4" thingid="4"
+ z="-5.0" y="0.0" x="-12.0" ownerusername="library" />
+ <thing templateid="16" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
+ scalez="1.0" displayname="JacobsenChair3107" scaley="1.0"
+ templateowner="library" scalex="1.0" possessionid="5" thingid="5"
+ z="-5.0" y="0.0" x="-3.0" ownerusername="library" />
+ <thing templateid="5" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
+ scalez="1.0" displayname="CescaArmChair" scaley="1.0"
+ templateowner="library" scalex="1.0" possessionid="6" thingid="6"
+ z="-5.0" y="0.0" x="-6.0" ownerusername="library" />
+ <thing templateid="8" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
+ scalez="1.0" displayname="AluminumChair" scaley="1.0"
+ templateowner="library" scalex="1.0" possessionid="7" thingid="7"
+ z="-5.0" y="0.0" x="0.0" ownerusername="library" />
+ <thing templateid="20" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
+ scalez="1.0" displayname="MarshmallowSofa" scaley="1.0"
+ templateowner="library" scalex="1.0" possessionid="8" thingid="8"
+ z="-5.0" y="0.0" x="3.0" ownerusername="library" />
+ <thing templateid="17" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
+ scalez="1.0" displayname="LeCorbusierArmChair" scaley="1.0"
+ templateowner="library" scalex="1.0" possessionid="9" thingid="9"
+ z="-5.0" y="0.0" x="9.0" ownerusername="library" />
+ <thing templateid="3" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
+ scalez="1.0" displayname="BarcelonaChair" scaley="1.0"
+ templateowner="library" scalex="1.0" possessionid="10" thingid="10"
+ z="-5.0" y="0.0" x="6.0" ownerusername="library" />
+ <thing templateid="31" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
+ scalez="1.0" displayname="OfficeChairNoArms" scaley="1.0"
+ templateowner="library" scalex="1.0" possessionid="11" thingid="11"
+ z="-5.0" y="0.0" x="12.0" ownerusername="library" />
+ <thing templateid="6" rz="0.0" ry="0.0" rx="0.0" rw="1.0"
+ scalez="1.0" displayname="CornerSofa" scaley="1.0"
+ templateowner="library" scalex="1.0" possessionid="12" thingid="12"
+ z="-5.0" y="0.0" x="12.0" ownerusername="library" />
+</space>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-05 22:32:44
|
Revision: 370
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=370&view=rev
Author: trevorolio
Date: 2007-09-05 15:32:42 -0700 (Wed, 05 Sep 2007)
Log Message:
-----------
hot-deploy
Modified Paths:
--------------
maven/trunk/ogoglio-server/pom.xml
Modified: maven/trunk/ogoglio-server/pom.xml
===================================================================
--- maven/trunk/ogoglio-server/pom.xml 2007-09-05 20:41:18 UTC (rev 369)
+++ maven/trunk/ogoglio-server/pom.xml 2007-09-05 22:32:42 UTC (rev 370)
@@ -14,7 +14,6 @@
<artifactId>ogoglio-server</artifactId>
<packaging>war</packaging>
-
<profiles>
<profile>
<id>hot-deploy</id>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-05 20:41:16
|
Revision: 369
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=369&view=rev
Author: trevorolio
Date: 2007-09-05 13:41:18 -0700 (Wed, 05 Sep 2007)
Log Message:
-----------
We won't be shipping log4j with the client.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/Log.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/Log.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/Log.java 2007-09-05 17:44:02 UTC (rev 368)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/Log.java 2007-09-05 20:41:18 UTC (rev 369)
@@ -1,11 +1,32 @@
package com.ogoglio.util;
-import org.apache.log4j.Logger;
-
public class Log {
- static Logger log = Logger.getLogger("com.ogoglio");
+ private static class Logger {
+ public void debug(Object msg) {
+ System.out.println(msg);
+ }
+
+ public void info(Object msg) {
+ System.out.println(msg);
+ }
+
+ public void error(Object msg) {
+ System.err.println(msg);
+ }
+
+ public void trace(Object msg) {
+ System.out.println(msg);
+ }
+
+ public void warn(Object msg) {
+ System.err.println(msg);
+ }
+ }
+
+ static Logger log = new Logger();
+
public static void debug(Object msg) {
log.debug(msg);
}
@@ -15,7 +36,7 @@
}
public static void info(Object msg, Throwable t) {
- log.info(msg, t);
+ log.info(msg);
}
public static void warn(Object msg) {
@@ -27,7 +48,7 @@
}
public static void error(Object msg, Throwable t) {
- log.error(msg, t);
+ log.error(msg);
}
public static void trace(Object msg) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-05 17:44:01
|
Revision: 368
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=368&view=rev
Author: trevorolio
Date: 2007-09-05 10:44:02 -0700 (Wed, 05 Sep 2007)
Log Message:
-----------
Fixed up the poms so that mvn clean install might actually clean install.
Modified Paths:
--------------
maven/trunk/ogoglio/pom.xml
Property Changed:
----------------
maven/trunk/ogoglio/
Property changes on: maven/trunk/ogoglio
___________________________________________________________________
Name: svn:ignore
- target
tomcat5x.out
+ target
tomcat5x.out
velocity.log
Modified: maven/trunk/ogoglio/pom.xml
===================================================================
--- maven/trunk/ogoglio/pom.xml 2007-09-05 17:43:58 UTC (rev 367)
+++ maven/trunk/ogoglio/pom.xml 2007-09-05 17:44:02 UTC (rev 368)
@@ -100,8 +100,7 @@
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.12</version>
- <scope>runtime</scope>
- <optional>true</optional>
+ <scope>compile</scope>
</dependency>
</dependencies>
</dependencyManagement>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-05 17:43:55
|
Revision: 367
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=367&view=rev
Author: trevorolio
Date: 2007-09-05 10:43:58 -0700 (Wed, 05 Sep 2007)
Log Message:
-----------
Fixed up the poms so that mvn clean install might actually clean install.
Modified Paths:
--------------
maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/test/DBZapTest.java
Modified: maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/test/DBZapTest.java
===================================================================
--- maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/test/DBZapTest.java 2007-09-05 17:43:54 UTC (rev 366)
+++ maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/test/DBZapTest.java 2007-09-05 17:43:58 UTC (rev 367)
@@ -13,15 +13,15 @@
protected SessionFactory sessionFactory;
public abstract MigrationSupport getMigrationSupport();
-
+
public void setUp() {
try {
MigrationSupport support = getMigrationSupport();
- PropStorage ps=new PropStorage();
- if (ps.loadPropertySet(PropStorage.TEST_CONFIG_PROPS)==false) {
- fail("Can't load test configuration for hibernate properties!");
+ PropStorage ps = new PropStorage();
+ if (ps.loadPropertySet(PropStorage.TEST_CONFIG_PROPS) == false) {
+ fail("Can't load test configuration for hibernate properties!");
}
- if (!("true".equals(ps.getKeyFromSet(PropStorage.TEST_CONFIG_PROPS,"ogoglio.okToZapDB")))) {
+ if (!("true".equals(ps.getKeyFromSet(PropStorage.TEST_CONFIG_PROPS, "ogoglio.okToZapDB")))) {
fail("Whoa! Shouldn't be running tests without setting the ogoglio.okToZapDB property!");
}
if (support.destroyAllData() == false) {
@@ -31,7 +31,7 @@
//if we are here, db stuff worked, but we still need to avoid all the jndi stuff
sessionFactory = support.createConfigurationForHibernate(getMigrationSupport().getVersionNumber(), null, false, ps).buildSessionFactory();
} catch (Exception e) {
- Log.error("Trying to setUp DBZapTest",e);
+ Log.error("Trying to setUp DBZapTest", e);
fail("Could not setup:" + e.getMessage());
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-05 17:43:51
|
Revision: 366
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=366&view=rev
Author: trevorolio
Date: 2007-09-05 10:43:54 -0700 (Wed, 05 Sep 2007)
Log Message:
-----------
Fixed up the poms so that mvn clean install might actually clean install.
Modified Paths:
--------------
maven/trunk/ogoglio-common/pom.xml
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIAuthenticator.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/Log.java
Modified: maven/trunk/ogoglio-common/pom.xml
===================================================================
--- maven/trunk/ogoglio-common/pom.xml 2007-09-05 17:43:47 UTC (rev 365)
+++ maven/trunk/ogoglio-common/pom.xml 2007-09-05 17:43:54 UTC (rev 366)
@@ -12,7 +12,6 @@
<relativePath>../ogoglio</relativePath>
</parent>
<artifactId>ogoglio-common</artifactId>
-
<build>
<resources>
<!-- FILTER RESOURCES FOR SOME CONSTANTS-->
@@ -31,8 +30,12 @@
<!-- things we need to build/run -->
<dependencies>
- <!-- used by some code in the project -->
- <dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIAuthenticator.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIAuthenticator.java 2007-09-05 17:43:47 UTC (rev 365)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIAuthenticator.java 2007-09-05 17:43:54 UTC (rev 366)
@@ -31,7 +31,6 @@
ArgumentUtils.assertNotEmpty(username);
this.username = username;
ArgumentUtils.assertNotEmpty(password);
-
String body = WebConstants.AUTH_USERNAME_PARAM + "=" + username + "&" + WebConstants.AUTH_PASS_PARAM + "=" + password;
authCookie = wire.getAuthCookieViaPost(serviceDescriptor.getAuthURI(), body, "application/x-www-form-urlencoded");
if(authCookie == null) {
@@ -88,15 +87,4 @@
public String getUsername() {
return username;
}
-
- /*
- public static String requestGuestCookie(URI serviceURI) throws IOException {
- InputStream input = WebAPIClient.performPOST(getAuthGuestURI(serviceURI), "", "text/plain", null);
- if (input == null) {
- return null;
- }
- return StreamUtils.readInput(input);
- }
- */
-
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/Log.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/Log.java 2007-09-05 17:43:47 UTC (rev 365)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/Log.java 2007-09-05 17:43:54 UTC (rev 366)
@@ -3,32 +3,38 @@
import org.apache.log4j.Logger;
public class Log {
-
- static Logger log = Logger.getLogger("com.ogoglio");
-
- public static void debug(Object msg) {
- log.debug(msg);
- }
- public static void info(Object msg) {
- log.info(msg);
- }
- public static void info(Object msg,Throwable t) {
- log.info(msg,t);
- }
- public static void warn(Object msg) {
- log.warn(msg);
- }
- public static void error(Object msg) {
- log.error(msg);
- }
- public static void error(Object msg, Throwable t) {
- log.error(msg,t);
- }
- public static void trace(Object msg) {
- log.trace(msg);
- }
- public static void test(Object msg) {
- log.debug("TEST:"+msg);
- }
+ static Logger log = Logger.getLogger("com.ogoglio");
+
+ public static void debug(Object msg) {
+ log.debug(msg);
+ }
+
+ public static void info(Object msg) {
+ log.info(msg);
+ }
+
+ public static void info(Object msg, Throwable t) {
+ log.info(msg, t);
+ }
+
+ public static void warn(Object msg) {
+ log.warn(msg);
+ }
+
+ public static void error(Object msg) {
+ log.error(msg);
+ }
+
+ public static void error(Object msg, Throwable t) {
+ log.error(msg, t);
+ }
+
+ public static void trace(Object msg) {
+ log.trace(msg);
+ }
+
+ public static void test(Object msg) {
+ log.debug("TEST:" + msg);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-05 17:43:47
|
Revision: 365
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=365&view=rev
Author: trevorolio
Date: 2007-09-05 10:43:47 -0700 (Wed, 05 Sep 2007)
Log Message:
-----------
Fixed up the poms so that mvn clean install might actually clean install.
Modified Paths:
--------------
maven/trunk/dev-plugins/pom.xml
Modified: maven/trunk/dev-plugins/pom.xml
===================================================================
--- maven/trunk/dev-plugins/pom.xml 2007-09-05 17:43:44 UTC (rev 364)
+++ maven/trunk/dev-plugins/pom.xml 2007-09-05 17:43:47 UTC (rev 365)
@@ -22,6 +22,15 @@
<skip>true</skip><!-- this is critical to avoid running unit tests -->
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compiler-version>1.5</compiler-version>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
</plugins>
</build>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-05 17:43:41
|
Revision: 364
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=364&view=rev
Author: trevorolio
Date: 2007-09-05 10:43:44 -0700 (Wed, 05 Sep 2007)
Log Message:
-----------
Fixed up the poms so that mvn clean install might actually clean install.
Property Changed:
----------------
maven/trunk/ogoglio-integration-test/
Property changes on: maven/trunk/ogoglio-integration-test
___________________________________________________________________
Name: svn:ignore
- target
tomcat5x.out
+ target
tomcat5x.out
tomcat5x.log
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-05 17:43:38
|
Revision: 363
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=363&view=rev
Author: trevorolio
Date: 2007-09-05 10:43:40 -0700 (Wed, 05 Sep 2007)
Log Message:
-----------
Fixed up the poms so that mvn clean install might actually clean install.
Property Changed:
----------------
maven/trunk/ogoglio-server/
Property changes on: maven/trunk/ogoglio-server
___________________________________________________________________
Name: svn:ignore
-
target
mailTestFiles
+
target
mailTestFiles
tomcat5x.*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2007-09-05 03:21:29
|
Revision: 362
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=362&view=rev
Author: iansmith
Date: 2007-09-04 20:21:32 -0700 (Tue, 04 Sep 2007)
Log Message:
-----------
First cut at a new mojo for pushing templates/spaces to the server from the populate directory.
ogoglio-server is configured to use this plugin. It can be run from the command line with :
mvn og:populate
in a directory with a POM that has the configuration settings.
This lacks the ability to reverse the mapping, which one sorely needs for development. I'll do that soon.
Moved around the package name and a few other things to make more sense in an ogoglio world.
Modified Paths:
--------------
maven/trunk/dev-plugins/pom.xml
Added Paths:
-----------
maven/trunk/dev-plugins/src/main/java/com/ogoglio/
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/StaticVelocityMojo.java
Removed Paths:
-------------
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/StaticVelocitySitePlugin.java
maven/trunk/dev-plugins/src/main/java/com/transmutable/
Modified: maven/trunk/dev-plugins/pom.xml
===================================================================
--- maven/trunk/dev-plugins/pom.xml 2007-09-05 03:18:04 UTC (rev 361)
+++ maven/trunk/dev-plugins/pom.xml 2007-09-05 03:21:32 UTC (rev 362)
@@ -11,9 +11,8 @@
<version>0.0.1-SNAPSHOT</version>
<relativePath>../ogoglio</relativePath>
</parent>
- <artifactId>dev-plugins</artifactId>
+ <artifactId>og-plugin</artifactId>
<packaging>maven-plugin</packaging>
-
<build>
<plugins>
<plugin>
@@ -38,6 +37,12 @@
<artifactId>velocity</artifactId>
<version>1.5</version>
</dependency>
+ <!-- because we are client of the server -->
+ <dependency>
+ <groupId>com.ogoglio</groupId>
+ <artifactId>ogoglio-common</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
Copied: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin (from rev 359, maven/trunk/dev-plugins/src/main/java/com/transmutable/plugin)
Added: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java (rev 0)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java 2007-09-05 03:21:32 UTC (rev 362)
@@ -0,0 +1,223 @@
+package com.ogoglio.plugin;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import nanoxml.XMLElement;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import com.agical.rmock.core.util.StringUtils;
+import com.ogoglio.client.WebAPIAuthenticator;
+import com.ogoglio.client.WebAPIClient;
+import com.ogoglio.client.WebAPIClientWire;
+import com.ogoglio.client.WebAPIDescriptor;
+import com.ogoglio.util.StreamUtils;
+import com.ogoglio.xml.PossessionDocument;
+import com.ogoglio.xml.SpaceDocument;
+import com.ogoglio.xml.TemplateDocument;
+
+/**
+ * @goal populate
+ */
+public class PopulateMojo extends AbstractMojo {
+ /**
+ * @parameter
+ */
+ private File baseDir;
+ /**
+ * @parameter
+ */
+ private String serviceURI;
+ /**
+ * @parameter
+ */
+ private String username;
+ /**
+ * @parameter
+ */
+ private String password;
+
+ private HashMap<Long,Long> templateIdMap = new HashMap<Long,Long>();
+ private List<SpaceDocument> spaces=new ArrayList<SpaceDocument>();
+
+ private static final String TEMPLATE_PREFIX="template-";
+ private static final String SPACE_PREFIX="space-";
+
+ public void execute() throws MojoExecutionException {
+ if (baseDir==null) {
+ getLog().info("No populate baseDir given. No population done.");
+ return;
+ }
+
+ if ((!baseDir.exists()) || (!baseDir.isDirectory()) || (!baseDir.canRead())) {
+ getLog().error("Unable to access base dir:"+baseDir.getAbsolutePath());
+ return;
+ }
+
+ if (serviceURI==null) {
+ getLog().info("No populate serviceURI given. No population done.");
+ return;
+ }
+
+ try {
+ WebAPIClientWire wire=new WebAPIClientWire();
+ WebAPIDescriptor descriptor=new WebAPIDescriptor(new URI(serviceURI));
+ WebAPIAuthenticator auth=new WebAPIAuthenticator(wire,descriptor,username,password);
+ WebAPIClient client=new WebAPIClient(descriptor,auth,wire);
+ //we are now ready to upload
+
+ File[] templates = baseDir.listFiles();
+
+ for (int i=0; i<templates.length;++i) {
+ File candidate=templates[i];
+ if (candidate.getName().startsWith(TEMPLATE_PREFIX)) {
+ uploadTemplate(client,candidate);
+ } else if (candidate.getName().startsWith(SPACE_PREFIX)) {
+ readSpace(client,candidate);
+ } else {
+ if (!candidate.getName().equals(".svn")) {
+ getLog().warn("Unable to process in populate:"+candidate.getAbsolutePath());
+ }
+ }
+ }
+
+ patchSpaces(client);
+
+ } catch (URISyntaxException e) {
+ throw new MojoExecutionException("Bad URI syntax("+serviceURI+")",e);
+ } catch (IOException e) {
+ throw new MojoExecutionException("IO Exception (possibly auth?"+username+","+password+")",e);
+ }
+ }
+
+ private void patchSpaces(WebAPIClient client) throws MojoExecutionException {
+ SpaceDocument fakeSpaceDoc,realSpaceDoc;
+
+ for (int i=0; i<spaces.size();++i) {
+ fakeSpaceDoc=spaces.get(i);
+ try {
+ realSpaceDoc = client.createSpace(fakeSpaceDoc.getDisplayName());
+ TemplateDocument templates[] = fakeSpaceDoc.getTemplateDocuments();
+ for (int j=0; j<templates.length;++j) {
+ long trueId = templateIdMap.get(new Long(templates[j].getTemplateID())).longValue();
+ PossessionDocument possDoc = client.createPossession(trueId);
+ client.addPossessionToSpace(possDoc.getPossessionID(), fakeSpaceDoc.getSpaceID());
+ TemplateDocument realTemplateDoc=client.getTemplateDocument(username, trueId);
+ getLog().info("Added Template "+realTemplateDoc.getDisplayName()+" to space "+realSpaceDoc.getDisplayName());
+ }
+ //client.setSpacePublished(realSpaceDoc.getSpaceID(), fakeSpaceDoc.getSpacePublished());
+ long realSpaceID = realSpaceDoc.getSpaceID();
+ client.setSpaceSeaLevel(realSpaceID, fakeSpaceDoc.getSeaLevel());
+ client.setSpaceMaxGuests(realSpaceID, fakeSpaceDoc.getMaxGuests());
+ client.setSpaceDisplayName(realSpaceID, fakeSpaceDoc.getDisplayName());
+ client.setSpaceSeaLevel(realSpaceID, fakeSpaceDoc.getSeaLevel());
+ } catch (IOException e) {
+ throw new MojoExecutionException("IOException patching space ("+fakeSpaceDoc.getDisplayName()+":"+fakeSpaceDoc.getSpaceID()+")",e);
+ }
+ }
+
+ }
+
+ private void readSpace(WebAPIClient client, File candidate) throws MojoExecutionException{
+ String name = candidate.getName();
+ String num= name.substring(SPACE_PREFIX.length());
+ int spaceFakeId=-189;
+ try {
+ spaceFakeId = Integer.parseInt(num);
+ } catch (NumberFormatException e) {
+ getLog().error("Badly formed space name:"+name+". Ignoring.");
+ }
+ if (spaceFakeId==-189) {
+ return;
+ }
+ try {
+ FileInputStream inputStream = new FileInputStream(candidate);
+ String docContent = StreamUtils.readInput(inputStream);
+ SpaceDocument doc=new SpaceDocument(XMLElement.parseElementFromString(docContent));
+ spaces.add(doc);
+ inputStream.close();
+ } catch (IOException e) {
+ throw new MojoExecutionException("IO Error reading space",e);
+ }
+
+
+ }
+
+ private void uploadTemplate(WebAPIClient client, File candidate) throws MojoExecutionException{
+ String name = candidate.getName();
+ String num= name.substring(TEMPLATE_PREFIX.length());
+
+ int templateFakeId=-188;
+ try {
+ templateFakeId = Integer.parseInt(num);
+ } catch (NumberFormatException e) {
+ getLog().error("Badly formed template name:"+name+". Ignoring.");
+ }
+ if (templateFakeId==-188) {
+ return;
+ }
+ getLog().info("Uploading template #"+templateFakeId+" to "+serviceURI);
+ File[] objs=candidate.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".obj");
+ }
+ });
+ if (objs.length!=1) {
+ throw new MojoExecutionException("Badly formed directory "+name+". Should have 1 obj file but has "+objs.length);
+ }
+ try {
+ String templateName=objs[0].getName();
+ InputStream objStream=new FileInputStream(objs[0]);
+ TemplateDocument doc = client.createTemplate(templateName.substring(0,templateName.length()-4));//.obj
+ client.uploadTemplateGeometryStream(username,doc.getTemplateID(),0,objStream);
+
+ templateIdMap.put(new Long(templateFakeId), new Long(doc.getTemplateID()));
+ getLog().info("Created template from "+objs[0].getName()+
+ " ["+templateFakeId+" -> "+doc.getTemplateID()+"]");
+
+ File[] notObjs=candidate.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return !name.endsWith(".obj");
+ }
+ });
+ for (int i=0; i<notObjs.length; ++i) {
+ File supportFile = notObjs[i];
+ String supportName = supportFile.getName();
+ if (supportFile.getName().endsWith(".js")) {
+ String script = StreamUtils.readInput(new FileInputStream(supportFile));
+ client.updateTemplateScript(username, doc.getTemplateID(), script);
+ getLog().info("Uploaded script file:"+supportName);
+ } else {
+ if ((!(supportName.endsWith(".gif"))) && (!(supportName.endsWith(".jpg"))) &&
+ (!(supportName.endsWith(".png"))) && (!(supportName.endsWith(".mtl")))) {
+
+ if ((!(supportName.endsWith(".blend"))) && (!(supportName.endsWith(".3DS"))) &&
+ (!(supportName.endsWith(".txt"))) && (!(supportName.equals(".svn")))) {
+ getLog().warn("Don't know what to do with file "+supportName+". Ignoring.");
+ }
+ continue;
+ }
+ FileInputStream supportStream = new FileInputStream(supportFile);
+ client.uploadTemplateResourceStream(username, doc.getTemplateID(), supportName, supportStream);
+ getLog().info("Uploaded support file:"+supportName);
+ }
+ }
+
+ } catch (IOException e) {
+ throw new MojoExecutionException("IO Error in upload",e);
+ }
+ }
+
+}
\ No newline at end of file
Copied: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/StaticVelocityMojo.java (from rev 359, maven/trunk/dev-plugins/src/main/java/com/transmutable/plugin/StaticVelocitySitePlugin.java)
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/StaticVelocityMojo.java (rev 0)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/StaticVelocityMojo.java 2007-09-05 03:21:32 UTC (rev 362)
@@ -0,0 +1,110 @@
+package com.ogoglio.plugin;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+
+/**
+ * @goal buildHtml
+ */
+public class StaticVelocityMojo extends AbstractMojo {
+
+ /**
+ * @parameter
+ */
+ private File templateDirectory;
+ /**
+ * @parameter
+ */
+ private File targetDirectory;
+
+ public void execute() throws MojoExecutionException {
+ if (templateDirectory==null) {
+ getLog().warn("No velocity templates configured!");
+ return;
+ } else if ((!templateDirectory.exists()) || (!templateDirectory.canRead())) {
+ getLog().warn("Can't find any velocity templates to compile!");
+ return;
+ }
+
+ if (targetDirectory.exists()==false) {
+ if (targetDirectory.mkdir()==false) {
+ getLog().error("Unable to create target directory:"+targetDirectory.getName());
+ throw new MojoExecutionException("Bad target directory");
+ }
+ }
+
+ try {
+ VelocityEngine engine = new VelocityEngine();
+ engine.setProperty("file.resource.loader.path", templateDirectory.getCanonicalPath());
+ engine.init();
+
+ VelocityContext velocityContext = new VelocityContext();
+
+ File[] children = templateDirectory.listFiles();
+ for (int i = 0; children != null && i < children.length; i++) {
+ if (children[i].getName().endsWith(".html")) {
+ Template template = engine.getTemplate(children[i].getName());
+ File output = new File(targetDirectory, children[i].getName());
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(output)));
+ template.merge(velocityContext, writer);
+ writer.flush();
+ writer.close();
+ } else if (children[i].getName().endsWith(".vm")) { //ignore velocity fragments
+ continue;
+ } else if(children[i].getName().equals(".svn")) { //ignore svn dir
+ continue;
+ } else {
+ copy(children[i], targetDirectory);
+ }
+ }
+ } catch (ResourceNotFoundException rnfe) {
+ getLog().error(rnfe);
+ throw new MojoExecutionException("Can't find resource",rnfe);
+ } catch (ParseErrorException pee) {
+ getLog().warn("Syntax error in template:" + pee);
+ throw new MojoExecutionException("Bad syntax",pee);
+ } catch (Exception e) {
+ throw new MojoExecutionException("Unexpected exception",e);
+ }
+
+ }
+
+ private void copy(File source, File destinationDirectory) throws IOException {
+ if(source.isDirectory()){
+ File newDir = new File(destinationDirectory, source.getName());
+ newDir.mkdir();
+ File[] children = source.listFiles();
+ for (int i = 0; i < children.length; i++) {
+ copy(children[i], newDir);
+ }
+ } else {
+ File newFile = new File(destinationDirectory, source.getName());
+ if(newFile.exists() && source.lastModified() == newFile.lastModified()){
+ return;
+ }
+ FileOutputStream output = new FileOutputStream(newFile);
+ FileInputStream input = new FileInputStream(source);
+ byte[] buff = new byte[2048];
+ int read = 0;
+ while( (read = input.read(buff)) > 0){
+ output.write(buff, 0, read);
+ }
+ output.flush();
+ output.close();
+ input.close();
+ }
+ }
+}
+
Deleted: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/StaticVelocitySitePlugin.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/transmutable/plugin/StaticVelocitySitePlugin.java 2007-09-04 23:28:02 UTC (rev 359)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/StaticVelocitySitePlugin.java 2007-09-05 03:21:32 UTC (rev 362)
@@ -1,110 +0,0 @@
-package com.transmutable.plugin;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
-
-/**
- * @goal buildHtml
- */
-public class StaticVelocitySitePlugin extends AbstractMojo {
-
- /**
- * @parameter
- */
- private File templateDirectory;
- /**
- * @parameter
- */
- private File targetDirectory;
-
- public void execute() throws MojoExecutionException {
- if (templateDirectory==null) {
- getLog().warn("No velocity templates configured!");
- return;
- } else if ((!templateDirectory.exists()) || (!templateDirectory.canRead())) {
- getLog().warn("Can't find any velocity templates to compile!");
- return;
- }
-
- if (targetDirectory.exists()==false) {
- if (targetDirectory.mkdir()==false) {
- getLog().error("Unable to create target directory:"+targetDirectory.getName());
- throw new MojoExecutionException("Bad target directory");
- }
- }
-
- try {
- VelocityEngine engine = new VelocityEngine();
- engine.setProperty("file.resource.loader.path", templateDirectory.getCanonicalPath());
- engine.init();
-
- VelocityContext velocityContext = new VelocityContext();
-
- File[] children = templateDirectory.listFiles();
- for (int i = 0; children != null && i < children.length; i++) {
- if (children[i].getName().endsWith(".html")) {
- Template template = engine.getTemplate(children[i].getName());
- File output = new File(targetDirectory, children[i].getName());
- BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(output)));
- template.merge(velocityContext, writer);
- writer.flush();
- writer.close();
- } else if (children[i].getName().endsWith(".vm")) { //ignore velocity fragments
- continue;
- } else if(children[i].getName().equals(".svn")) { //ignore svn dir
- continue;
- } else {
- copy(children[i], targetDirectory);
- }
- }
- } catch (ResourceNotFoundException rnfe) {
- getLog().error(rnfe);
- throw new MojoExecutionException("Can't find resource",rnfe);
- } catch (ParseErrorException pee) {
- getLog().warn("Syntax error in template:" + pee);
- throw new MojoExecutionException("Bad syntax",pee);
- } catch (Exception e) {
- throw new MojoExecutionException("Unexpected exception",e);
- }
-
- }
-
- private void copy(File source, File destinationDirectory) throws IOException {
- if(source.isDirectory()){
- File newDir = new File(destinationDirectory, source.getName());
- newDir.mkdir();
- File[] children = source.listFiles();
- for (int i = 0; i < children.length; i++) {
- copy(children[i], newDir);
- }
- } else {
- File newFile = new File(destinationDirectory, source.getName());
- if(newFile.exists() && source.lastModified() == newFile.lastModified()){
- return;
- }
- FileOutputStream output = new FileOutputStream(newFile);
- FileInputStream input = new FileInputStream(source);
- byte[] buff = new byte[2048];
- int read = 0;
- while( (read = input.read(buff)) > 0){
- output.write(buff, 0, read);
- }
- output.flush();
- output.close();
- input.close();
- }
- }
-}
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|