tdraier 2005/06/10 14:45:45 CEST
Modified files:
src/java/org/jahia/update/core PatchSlide2b.java
Log:
check different ids before inserting
Revision Changes Path
1.6 +20 -12
jahia_update/src/java/org/jahia/update/core/PatchSlide2b.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia_update/src/java/org/jahia/update/core/PatchSlide2b.java.diff?r1=1.5&r2=1.6&f=h
Index: PatchSlide2b.java
===================================================================
RCS file:
/home/cvs/repository/jahia_update/src/java/org/jahia/update/core/PatchSlide2b.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PatchSlide2b.java 10 Jun 2005 11:02:45 -0000 1.5
+++ PatchSlide2b.java 10 Jun 2005 12:45:45 -0000 1.6
@@ -32,13 +32,13 @@
ResultSet rs =
dbManager.selectFromTable("jahia_autoids_currentindex","jahia_autoids WHERE
jahia_autoids_tablename='JAHIA_SL2_URI'");
rs.next();
- int uriId = rs.getInt(1) + 1;
+ int maxId = rs.getInt(1) + 1;
rs.close();
rs =
dbManager.selectFromTable("jahia_autoids_currentindex","jahia_autoids WHERE
jahia_autoids_tablename='JAHIA_SL2_VERSION_HISTORY'");
rs.next();
int versionUriId = rs.getInt(1) + 1;
rs.close();
- uriId = Math.max(uriId, versionUriId);
+ maxId = Math.max(maxId, versionUriId);
PreparedStatement selectUri = dbManager.prepareStatement("select
uri_id from jahia_sl2_uri where uri_string=? and namespace=?");
PreparedStatement insertUri = dbManager.prepareStatement("insert
into jahia_sl2_uri values(?,?,?)");
@@ -67,7 +67,7 @@
if (rs2.next()) {
parentid = rs2.getInt(1);
} else {
- parentid = uriId++;
+ parentid = maxId++;
insertUri.setInt(1,parentid);
insertUri.setString(2,parent);
insertUri.setInt(3,ns);
@@ -106,10 +106,8 @@
insertUri.close();
insertObject.close();
- dbManager.query("update jahia_autoids set
jahia_autoids_currentindex="+uriId+" where
jahia_autoids_tablename='JAHIA_SL2_URI'");
- dbManager.query("update jahia_autoids set
jahia_autoids_currentindex="+uriId+" where
jahia_autoids_tablename='JAHIA_SL2_VERSION_HISTORY'");
-
PreparedStatement getVersion =
dbManager.prepareStatement("select * from jahia_sl2_version where uri_id=?");
+ PreparedStatement getVersionHistory =
dbManager.prepareStatement("select version_id from jahia_sl2_version_history
where uri_id=?");
PreparedStatement insertVersion =
dbManager.prepareStatement("insert into jahia_sl2_version values(?,?)");
PreparedStatement insertVersionHistory =
dbManager.prepareStatement("insert into jahia_sl2_version_history
values(?,?,?,?)");
PreparedStatement getProperty =
dbManager.prepareStatement("select
property_namespace,property_name,property_value from jahia_sl2_properties where
version_id=?");
@@ -118,7 +116,7 @@
rs = dbManager.selectFromTable("uri_id", "jahia_sl2_uri");
while (rs.next()) {
- uriId = rs.getInt(1);
+ int uriId = rs.getInt(1);
getVersion.setInt(1,uriId);
ResultSet rs2 = getVersion.executeQuery();
@@ -126,18 +124,25 @@
insertVersion.setInt(1,uriId);
insertVersion.setInt(2,0);
insertVersion.executeUpdate();
-
- insertVersionHistory.setInt(1,uriId);
+ }
+ getVersionHistory.setInt(1, uriId);
+ rs2 = getVersionHistory.executeQuery();
+ int versionId;
+ if (!rs2.next()) {
+ versionId = maxId++;
+ insertVersionHistory.setInt(1,versionId);
insertVersionHistory.setInt(2,uriId);
insertVersionHistory.setInt(3,1);
insertVersionHistory.setString(4,"1.0");
insertVersionHistory.executeUpdate();
+ } else {
+ versionId = rs2.getInt(1);
}
- getProperty.setInt(1,uriId);
+ getProperty.setInt(1,versionId);
rs2 = getProperty.executeQuery();
if (!rs2.next()) {
- insertProperty.setInt(1,uriId);
+ insertProperty.setInt(1,versionId);
insertProperty.setString(2,"DAV:");
insertProperty.setString(5,"");
insertProperty.setInt(6,1);
@@ -158,7 +163,7 @@
"getcontentlength".equals(rs2.getString(2)) &&
"-1".equals(rs2.getString(3))) {
updateProperty.setString(1,"0");
- updateProperty.setInt(2, uriId);
+ updateProperty.setInt(2, versionId);
updateProperty.setString(3, rs2.getString(1));
updateProperty.setString(4, rs2.getString(2));
updateProperty.executeUpdate();
@@ -168,6 +173,9 @@
insertProperty.close();
updateProperty.close();
+ dbManager.query("update jahia_autoids set
jahia_autoids_currentindex="+maxId+" where
jahia_autoids_tablename='JAHIA_SL2_URI'");
+ dbManager.query("update jahia_autoids set
jahia_autoids_currentindex="+maxId+" where
jahia_autoids_tablename='JAHIA_SL2_VERSION_HISTORY'");
+
dbManager.query("update jahia_autoids set
jahia_autoids_tablename='jahia_sl2_uri' WHERE
jahia_autoids_tablename='JAHIA_SL2_URI'");
dbManager.query("update jahia_autoids set
jahia_autoids_tablename='jahia_sl2_version_history' WHERE
jahia_autoids_tablename='JAHIA_SL2_VERSION_HISTORY'");
dbManager.query("update jahia_autoids set
jahia_autoids_tablename='jahia_sl2_branch' WHERE
jahia_autoids_tablename='JAHIA_SL2_BRANCH'");