|
From: <tre...@us...> - 2007-09-18 16:03:28
|
Revision: 417
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=417&view=rev
Author: trevorolio
Date: 2007-09-18 09:03:23 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
Added the ability to choose a male or female avatar.
Both avatar models still need work.
Consolidated the two UIConstants classes into one.
Modified Paths:
--------------
maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java
Modified: maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java
===================================================================
--- maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java 2007-09-18 16:03:11 UTC (rev 416)
+++ maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java 2007-09-18 16:03:23 UTC (rev 417)
@@ -12,25 +12,26 @@
import com.ogoglio.appdev.persist.PersistException;
import com.ogoglio.util.Log;
import com.ogoglio.util.PropStorage;
-import com.ogoglio.viewer.render.UIConstants;
+import com.ogoglio.util.UIConstants;
-
-
public abstract class MigrationSupport {
//check on migration okayness
public static final String MIGRATION_KEY = "ogoglio/okToMigrateDB";
- public static final boolean DDL_MODE_UPDATE=true;
- public static final boolean DDL_MODE_CREATE=false;
-
+ public static final boolean DDL_MODE_UPDATE = true;
+
+ public static final boolean DDL_MODE_CREATE = false;
+
public MigrationSupport() {
}
-
+
public abstract int getVersionNumber();
+
public abstract Migration[] getMigrationList();
+
public abstract String getResourcePath();
-
+
public boolean verifyVersion(ServletConfig servletConf, Context ctx) {
try {
SessionFactory sessionFactory = getCurrentConfiguration().buildSessionFactory();
@@ -38,8 +39,7 @@
if (version != getVersionNumber()) {
Log.error("DB Version Mismatch! Expected (" + getVersionNumber() + ") but got " + version + "!");
sessionFactory.close();
- return tryUpgrade(servletConf, ctx, version, getVersionNumber(),
- DDL_MODE_UPDATE, true, null);
+ return tryUpgrade(servletConf, ctx, version, getVersionNumber(), DDL_MODE_UPDATE, true, null);
}
sessionFactory.close();
return true; // we are at the expected version
@@ -68,12 +68,12 @@
return false;
}
}
-
+
public boolean initVersionAndUpgrade(ServletConfig conf, Context ctx) {
- if (!initVersionOnly(true,null)) {
- return false;
- }
- return tryUpgrade(conf, ctx, 0, getVersionNumber(), DDL_MODE_UPDATE, true,null);
+ if (!initVersionOnly(true, null)) {
+ return false;
+ }
+ return tryUpgrade(conf, ctx, 0, getVersionNumber(), DDL_MODE_UPDATE, true, null);
}
public Configuration getCurrentConfiguration() {
@@ -88,9 +88,9 @@
if (useJNDI) {
configuration.setProperty("hibernate.connection.datasource", "java:comp/env/jdbc/space");
} else {
- configuration.addProperties(ps.getAllProps(PropStorage.TEST_CONFIG_PROPS));
+ configuration.addProperties(ps.getAllProps(PropStorage.TEST_CONFIG_PROPS));
}
- configuration.addInputStream(UIConstants.getResource(getResourcePath()+"/migration-" + num + ".xml"));
+ configuration.addInputStream(UIConstants.getResource(getResourcePath() + "/migration-" + num + ".xml"));
return configuration.configure();
}
@@ -103,43 +103,41 @@
}
}
- public boolean tryUpgrade(ServletConfig servletConfig, Context ctx, int db_is,
- int db_wants_to_be, boolean isUpdate, boolean useJNDI, PropStorage propStore) {
+ public boolean tryUpgrade(ServletConfig servletConfig, Context ctx, int db_is, int db_wants_to_be, boolean isUpdate, boolean useJNDI, PropStorage propStore) {
if (getMigrationList().length != getVersionNumber()) {
Log.error("Internal error! Migration list length should be " + getVersionNumber() + " but is " + getMigrationList().length + "!");
return false;
}
boolean canMigrate = false;
-
+
//check the flags
try {
- String migrate;
- if (useJNDI) {
- migrate = (String) ctx.lookup(MIGRATION_KEY);
- } else {
- migrate= propStore.getKeyFromSet(PropStorage.TEST_CONFIG_PROPS, "ogoglio.okToMigrateDB");
- }
- if ("true".equals(migrate)) {
- canMigrate = true;
- }
+ String migrate;
+ if (useJNDI) {
+ migrate = (String) ctx.lookup(MIGRATION_KEY);
+ } else {
+ migrate = propStore.getKeyFromSet(PropStorage.TEST_CONFIG_PROPS, "ogoglio.okToMigrateDB");
+ }
+ if ("true".equals(migrate)) {
+ canMigrate = true;
+ }
} catch (NamingException e) {
- Log.error("Naming exception trying to access " + MIGRATION_KEY + " from naming context!");
- canMigrate=false;
+ Log.error("Naming exception trying to access " + MIGRATION_KEY + " from naming context!");
+ canMigrate = false;
}
if (!canMigrate) {
Log.error("Cannot migrate data! Property ogoglio.okToMigrateDB is false or non-existent!");
return false;
}
- String hbm_auto_flag="update";
+ String hbm_auto_flag = "update";
if (!isUpdate) {
- hbm_auto_flag="create";
+ hbm_auto_flag = "create";
}
-
for (int i = db_is; i < db_wants_to_be; ++i) {
Migration current = getMigrationList()[i];
- Log.info("DB: Attempting migration from " + i + " to " + (i + 1) + " with auto HBM:"+hbm_auto_flag);
+ Log.info("DB: Attempting migration from " + i + " to " + (i + 1) + " with auto HBM:" + hbm_auto_flag);
//try to get hibernate to do the work
Configuration config = createConfigurationForHibernate(i + 1, hbm_auto_flag, useJNDI, propStore);
@@ -153,65 +151,65 @@
setVersionNumberOfDbViaQuery(factory, i + 1, expectedRecords);
try {
- if (!current.patch(factory, servletConfig, ctx, i, i + 1)) {
- factory.close();
- return false;
- }
+ if (!current.patch(factory, servletConfig, ctx, i, i + 1)) {
+ factory.close();
+ return false;
+ }
} catch (PersistException e) {
- Log.error("Whoa! Patch failed at revision!"+(i+1)+" on class "+current.getClass().getName());
- Log.error("Whoa! Persistance layer problem was:"+e.getMessage());
+ Log.error("Whoa! Patch failed at revision!" + (i + 1) + " on class " + current.getClass().getName());
+ Log.error("Whoa! Persistance layer problem was:" + e.getMessage());
}
-
+
try {
- if (!isUpdate) {
- //we need to go ahead and create the data
- if (!current.populate(factory, i, i+1)) {
- Log.error("Whoa! Populate failed at revision!"+(i+1)+" on class "+current.getClass().getName());
- factory.close();
- return false;
- }
- }
+ if (!isUpdate) {
+ //we need to go ahead and create the data
+ if (!current.populate(factory, i, i + 1)) {
+ Log.error("Whoa! Populate failed at revision!" + (i + 1) + " on class " + current.getClass().getName());
+ factory.close();
+ return false;
+ }
+ }
} catch (PersistException e) {
- Log.error("Whoa! Populate failed at revision!"+(i+1)+" on class "+current.getClass().getName());
- Log.error("Whoa! Persistance layer problem was:"+e.getMessage());
+ Log.error("Whoa! Populate failed at revision!" + (i + 1) + " on class " + current.getClass().getName());
+ Log.error("Whoa! Persistance layer problem was:" + e.getMessage());
}
-
+
factory.close();
}
return true;
}
- public boolean destroyAllData() {
- PropStorage ps =new PropStorage();
- if (ps.loadPropertySet(PropStorage.TEST_CONFIG_PROPS)==false) {
- return false;
- }
+ public boolean destroyAllData() {
+ PropStorage ps = new PropStorage();
+ if (ps.loadPropertySet(PropStorage.TEST_CONFIG_PROPS) == false) {
+ return false;
+ }
- if (initVersionOnly(false, ps)==false) {
- return false;
- }
+ if (initVersionOnly(false, ps) == false) {
+ return false;
+ }
- if (tryUpgrade(null, null, 0, getVersionNumber(), DDL_MODE_CREATE, false, ps)==false) {
- Log.error("Aborted destroying data after failure to upgrade");
- return false;
- }
- ps.loadPropertySet(PropStorage.BASIC_PROPS);
- String dir = ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.mediaDirectory");
- if (dir==null) {
- Log.error("Can't find a property ogoglio.mediaDirectory to cleanse media store");
- return false;
- }
- File store = new File(dir);
- if ((!store.exists()) || (!store.canWrite())) {
- Log.error("Media directory doesn't exist or can't be changed:"+dir);
- return false;
- }
- File[] children= store.listFiles();
- for (int i=0; i<children.length;++i) {
- if (children[i].delete()!=true) {
- Log.error("Failed to delete media file:"+children[i].getAbsolutePath());
- }
- }
- return true;
- }
+ if (tryUpgrade(null, null, 0, getVersionNumber(), DDL_MODE_CREATE, false, ps) == false) {
+ Log.error("Aborted destroying data after failure to upgrade");
+ return false;
+ }
+ ps.loadPropertySet(PropStorage.BASIC_PROPS);
+ String dir = ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.mediaDirectory");
+ if (dir == null) {
+ Log.error("Can't find a property ogoglio.mediaDirectory to cleanse media store");
+ return false;
+ }
+ File store = new File(dir);
+ if ((!store.exists()) || (!store.canWrite())) {
+ Log.error("Media directory doesn't exist or can't be changed:" + dir);
+ return false;
+ }
+ File[] children = store.listFiles();
+ for (int i = 0; i < children.length; ++i) {
+ if (children[i].delete() != true) {
+ Log.error("Failed to delete media file:" + children[i].getAbsolutePath());
+ }
+ }
+ return true;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-12-31 23:16:09
|
Revision: 656
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=656&view=rev
Author: trevorolio
Date: 2007-12-31 15:15:54 -0800 (Mon, 31 Dec 2007)
Log Message:
-----------
Fixed the rotted verification email setup. Requires the following additions:
To TOMCAT/conf/server.xml add
<Resource name="mailSession" auth="Container" type="javax.mail.Session" mail.smtp.host="localhost" />
<Environment name="mailDirectory" value="/tmp/" type="java.lang.String"/>
To ~/.m2/settings.xml add
<ogoglio.mailDirectory>
/tmp/
</ogoglio.mailDirectory>
Modified Paths:
--------------
maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java
Modified: maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java
===================================================================
--- maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java 2007-12-31 23:15:48 UTC (rev 655)
+++ maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java 2007-12-31 23:15:54 UTC (rev 656)
@@ -195,21 +195,35 @@
Log.error("Aborted destroying data after failure to upgrade");
return false;
}
+
ps.loadPropertySet(PropStorage.BASIC_PROPS);
String dir = ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.mediaDirectory");
if (dir == null) {
Log.error("Can't find a property ogoglio.mediaDirectory to cleanse media store");
return false;
}
- File store = new File(dir);
- if ((!store.exists()) || (!store.canWrite())) {
+ if(!destroyFiles(new File(dir))){
Log.error("Media directory doesn't exist or can't be changed:" + dir);
return false;
}
+
+ dir = ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.mailDirectory");
+ if (dir != null) {
+ destroyFiles(new File(dir));
+ }
+
+ return true;
+ }
+
+ private boolean destroyFiles(File store){
+ if ((!store.exists()) || (!store.canWrite())) {
+ return false;
+ }
File[] children = store.listFiles();
for (int i = 0; i < children.length; ++i) {
if (children[i].delete() != true) {
- Log.error("Failed to delete media file:" + children[i].getAbsolutePath());
+ Log.error("Failed to delete file:" + children[i].getAbsolutePath());
+ return false;
}
}
return true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2008-01-10 19:03:45
|
Revision: 675
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=675&view=rev
Author: trevorolio
Date: 2008-01-10 11:03:50 -0800 (Thu, 10 Jan 2008)
Log Message:
-----------
removed a debug statement
Modified Paths:
--------------
maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java
Modified: maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java
===================================================================
--- maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java 2008-01-10 18:25:39 UTC (rev 674)
+++ maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java 2008-01-10 19:03:50 UTC (rev 675)
@@ -92,7 +92,6 @@
} else {
configuration.addProperties(ps.getAllProps(PropStorage.TEST_CONFIG_PROPS));
}
- Log.info("Trying read in hibernate config ["+getResourcePath() + "/migration-" + num + ".xml"+"]");
configuration.addInputStream(UIConstants.getResource(getResourcePath() + "/migration-" + num + ".xml"));
return configuration.configure();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2008-02-06 01:19:26
|
Revision: 707
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=707&view=rev
Author: trevorolio
Date: 2008-02-05 17:19:31 -0800 (Tue, 05 Feb 2008)
Log Message:
-----------
Added the back end and 3D rendering of attachment geometries and appearances, but not yet morphs or skin textures.
Also no example UI for picking attachments in the body editor, yet.
The "time to private parts" for Ogoglio starts now.
Modified Paths:
--------------
maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java
Modified: maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java
===================================================================
--- maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java 2008-02-05 04:00:23 UTC (rev 706)
+++ maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java 2008-02-06 01:19:31 UTC (rev 707)
@@ -132,12 +132,14 @@
Log.error("Cannot migrate data! Property ogoglio.okToMigrateDB is false or non-existent!");
return false;
}
- String hbm_auto_flag = "update";
- if (!isUpdate) {
- hbm_auto_flag = "create";
- }
for (int i = db_is; i < db_wants_to_be; ++i) {
+
+ String hbm_auto_flag = "update";
+ if (i == 0 && !isUpdate) {
+ hbm_auto_flag = "create";
+ }
+
Migration current = getMigrationList()[i];
Log.info("DB: Attempting migration from " + i + " to " + (i + 1) + " with auto HBM:" + hbm_auto_flag);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2008-02-15 00:13:19
|
Revision: 751
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=751&view=rev
Author: iansmith
Date: 2008-02-14 16:13:12 -0800 (Thu, 14 Feb 2008)
Log Message:
-----------
Fixed bug which was causing noisy errors about version numbers during migration. Also now that it is corrected, we complain and abort if version numbers are wrong.
Modified Paths:
--------------
maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java
Modified: maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java
===================================================================
--- maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java 2008-02-14 03:59:36 UTC (rev 750)
+++ maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java 2008-02-15 00:13:12 UTC (rev 751)
@@ -136,23 +136,23 @@
for (int i = db_is; i < db_wants_to_be; ++i) {
String hbm_auto_flag = "update";
+ int expectedRecords = 1;
if (i == 0 && !isUpdate) {
hbm_auto_flag = "create";
+ expectedRecords = 0;
}
Migration current = getMigrationList()[i];
- Log.info("DB: Attempting migration from " + i + " to " + (i + 1) + " with auto HBM:" + hbm_auto_flag);
+ Log.debug("DB: Attempting migration from " + i + " to " + (i + 1) + " with auto HBM:" + hbm_auto_flag);
//try to get hibernate to do the work
Configuration config = createConfigurationForHibernate(i + 1, hbm_auto_flag, useJNDI, propStore);
SessionFactory factory = config.buildSessionFactory();
- //subtle: if the ddlMode is create, hibernate blows away all the data (including our version number record)
- int expectedRecords = 1;
- if (!isUpdate) {
- expectedRecords = 0;
+ if (!setVersionNumberOfDbViaQuery(factory, i + 1, expectedRecords)) {
+ Log.error("Unable to set version number to "+(i+1)+"!");
+ return false;
}
- setVersionNumberOfDbViaQuery(factory, i + 1, expectedRecords);
try {
if (!current.patch(factory, servletConfig, ctx, i, i + 1)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|