Author: thomas.heute(a)jboss.com
Date: 2008-07-28 05:49:11 -0400 (Mon, 28 Jul 2008)
New Revision: 11596
Added:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/hibernate/MaterializedBlobType.java
Modified:
branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/hibernate/HibernateStore.java
branches/JBoss_Portal_Branch_2_6/cms/src/resources/hibernate/domain.hbm.xml
Log:
Fixes for Sybase, would hopefully work with the open source JDBC connector jtds
Modified: branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml 2008-07-27 12:55:55 UTC
(rev 11595)
+++ branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml 2008-07-28 09:49:11 UTC
(rev 11596)
@@ -77,7 +77,7 @@
<componentref name="ehcache" version="1.2.2"/>
<componentref name="el" version="1.0"/>
<componentref name="facelets"
version="1.1.1-patched-jboss4.2"/>
- <componentref name="hibernate" version="3.2.0.CR2"/>
+ <componentref name="hibernate" version="3.2.4.SP1"/>
<componentref name="httpunit" version="1.6"/>
<componentref name="hsqldb" version="1.8.0.2"/>
<componentref name="ibm-wsdl4j" version="1.5.2jboss"/>
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/hibernate/HibernateStore.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/hibernate/HibernateStore.java 2008-07-27
12:55:55 UTC (rev 11595)
+++
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/hibernate/HibernateStore.java 2008-07-28
09:49:11 UTC (rev 11596)
@@ -142,18 +142,18 @@
selectFileExistStmt = "select 1 from "
+ schemaObjectPrefix + " where FSENTRY_PATH = ? "
- + "and FSENTRY_NAME = ? and FSENTRY_DATA is not null";
+ + "and FSENTRY_NAME = ?";
- selectFolderExistStmt = "select 1 from "
+ selectFolderExistStmt = "select data from "
+ schemaObjectPrefix + " where FSENTRY_PATH = ? "
- + "and FSENTRY_NAME = ? and FSENTRY_DATA is null";
+ + "and FSENTRY_NAME = ?";
selectChildCountStmt = "select count(FSENTRY_NAME) from "
+ schemaObjectPrefix + " where FSENTRY_PATH = ?";
selectDataStmt = "select data from "
+ schemaObjectPrefix + " where FSENTRY_PATH = ? "
- + "and FSENTRY_NAME = ? and FSENTRY_DATA is not null";
+ + "and FSENTRY_NAME = ? ";
selectLastModifiedStmt = "select FSENTRY_LASTMOD from "
+ schemaObjectPrefix + " where FSENTRY_PATH = ? "
@@ -161,7 +161,7 @@
selectLengthStmt = "select FSENTRY_LENGTH from "
+ schemaObjectPrefix + " where FSENTRY_PATH = ? "
- + "and FSENTRY_NAME = ? and FSENTRY_DATA is not null";
+ + "and FSENTRY_NAME = ?";
initialized = true;
}
@@ -221,27 +221,27 @@
try
{
- String query = "from " + schemaObjectPrefix + " where
FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null";
+ String query = "from " + schemaObjectPrefix + " where
FSENTRY_PATH = ? and FSENTRY_NAME = ?";
List result = session.createQuery(query)
.setString(0, parentDir)
.setString(1, name)
.list();
+
+ boolean deleted = false;
- if (result.size() == 0)
- {
- throw new FileSystemException("no such file: " + filePath);
- }
-
if (schemaObjectPrefix.equals(HibernateStoreConstants.versionClassName))
{
Iterator iter = result.iterator();
while (iter.hasNext())
{
VersionEntry versionEntry = (VersionEntry)iter.next();
- session.delete(versionEntry);
+ if (versionEntry.getData() != null)
+ {
+ session.delete(versionEntry);
+ deleted = true;
+ }
}
-
}
else if (schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
@@ -249,9 +249,12 @@
while (iter.hasNext())
{
CMSEntry cmsEntry = (CMSEntry)iter.next();
- session.delete(cmsEntry);
+ if (cmsEntry.getData() != null)
+ {
+ session.delete(cmsEntry);
+ deleted = true;
+ }
}
-
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
@@ -259,10 +262,19 @@
while (iter.hasNext())
{
RepositoryEntry repoEntry = (RepositoryEntry)iter.next();
- session.delete(repoEntry);
+ if (repoEntry.getData() != null)
+ {
+ session.delete(repoEntry);
+ deleted = true;
+ }
}
+ }
+ if (!deleted)
+ {
+ throw new FileSystemException("no such file: " + filePath);
}
+
tx.commit();
}
catch (Exception e)
@@ -317,7 +329,7 @@
{
String query = "from " + schemaObjectPrefix + " where
FSENTRY_PATH = ? and FSENTRY_NAME = ? " +
- "and FSENTRY_DATA is null or (FSENTRY_PATH = ?) or (FSENTRY_PATH like
?)";
+ "or (FSENTRY_PATH = ?) or (FSENTRY_PATH like ?)";
List result = session.createQuery(query)
.setString(0, parentDir)
@@ -326,21 +338,20 @@
.setString(3, folderPath + FileSystem.SEPARATOR + "%")
.list();
- if (result.size() == 0)
- {
- throw new FileSystemException("no such folder: " + folderPath);
- }
-
+ boolean deleted = false;
+
if (schemaObjectPrefix.equals(HibernateStoreConstants.versionClassName))
{
Iterator iter = result.iterator();
while (iter.hasNext())
{
VersionEntry versionEntry = (VersionEntry)iter.next();
- session.delete(versionEntry);
-
+ if (versionEntry.getData() == null)
+ {
+ session.delete(versionEntry);
+ deleted = true;
+ }
}
-
}
else if (schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
@@ -348,10 +359,12 @@
while (iter.hasNext())
{
CMSEntry cmsEntry = (CMSEntry)iter.next();
- session.delete(cmsEntry);
-
+ if (cmsEntry.getData() == null)
+ {
+ session.delete(cmsEntry);
+ deleted = true;
+ }
}
-
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
@@ -359,11 +372,19 @@
while (iter.hasNext())
{
RepositoryEntry repoEntry = (RepositoryEntry)iter.next();
- session.delete(repoEntry);
-
+ if (repoEntry.getData() == null)
+ {
+ session.delete(repoEntry);
+ deleted = true;
+ }
}
+ }
+ if (!deleted)
+ {
+ throw new FileSystemException("no such folder: " + folderPath);
}
+
tx.commit();
}
catch (Exception e)
@@ -449,7 +470,11 @@
Iterator iter = rs.iterator();
if (iter.hasNext())
{
- return true;
+ Object object = iter.next();
+ if (object != null)
+ {
+ return true;
+ }
}
return false;
}
@@ -492,7 +517,11 @@
Iterator iter = rs.iterator();
if (iter.hasNext())
{
- return true;
+ Object object = iter.next();
+ if (object == null)
+ {
+ return true;
+ }
}
return false;
}
@@ -960,11 +989,11 @@
in = IOTools.safeBufferedWrapper(new FileInputStream(f));
if
(schemaObjectPrefix.equals(HibernateStoreConstants.versionClassName))
{
- Query query = session.createQuery("from VersionEntry
where FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null");
+ Query query = session.createQuery("from VersionEntry
where FSENTRY_PATH = ? and FSENTRY_NAME = ?");
query.setString(0, parentDir);
query.setString(1, name);
VersionEntry versionEntry =
(VersionEntry)query.uniqueResult();
- if (versionEntry == null)
+ if (versionEntry == null || versionEntry.getData() == null)
{
throw new Exception("No such Entry " + name);
}
@@ -977,11 +1006,11 @@
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
- Query query = session.createQuery("from CMSEntry where
FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null");
+ Query query = session.createQuery("from CMSEntry where
FSENTRY_PATH = ? and FSENTRY_NAME = ?");
query.setString(0, parentDir);
query.setString(1, name);
CMSEntry cmsEntry = (CMSEntry)query.uniqueResult();
- if (cmsEntry == null)
+ if (cmsEntry == null || cmsEntry.getData() == null)
{
throw new Exception("No such Entry " + name);
}
@@ -994,11 +1023,11 @@
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
- Query query = session.createQuery("from RepositoryEntry
where FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null");
+ Query query = session.createQuery("from RepositoryEntry
where FSENTRY_PATH = ? and FSENTRY_NAME = ?");
query.setString(0, parentDir);
query.setString(1, name);
RepositoryEntry repoEntry =
(RepositoryEntry)query.uniqueResult();
- if (repoEntry == null)
+ if (repoEntry == null || repoEntry.getData() == null)
{
throw new Exception("No such Entry " + name);
}
@@ -1169,11 +1198,11 @@
in = IOTools.safeBufferedWrapper(new FileInputStream(f));
if
(schemaObjectPrefix.equals(HibernateStoreConstants.versionClassName))
{
- Query query = session.createQuery("from VersionEntry
where FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null");
+ Query query = session.createQuery("from VersionEntry
where FSENTRY_PATH = ? and FSENTRY_NAME = ?");
query.setString(0, parentDir);
query.setString(1, name);
VersionEntry versionEntry =
(VersionEntry)query.uniqueResult();
- if (versionEntry == null)
+ if (versionEntry == null || versionEntry.getData() == null)
{
throw new Exception("No such Entry " + name);
}
@@ -1186,11 +1215,11 @@
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
- Query query = session.createQuery("from CMSEntry where
FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null");
+ Query query = session.createQuery("from CMSEntry where
FSENTRY_PATH = ? and FSENTRY_NAME = ?");
query.setString(0, parentDir);
query.setString(1, name);
CMSEntry cmsEntry = (CMSEntry)query.uniqueResult();
- if (cmsEntry == null)
+ if (cmsEntry == null || cmsEntry.getData() == null)
{
throw new Exception("No such Entry " + name);
}
@@ -1203,11 +1232,11 @@
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
- Query query = session.createQuery("from CMSEntry where
FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null");
+ Query query = session.createQuery("from CMSEntry where
FSENTRY_PATH = ? and FSENTRY_NAME = ?");
query.setString(0, parentDir);
query.setString(1, name);
RepositoryEntry repoEntry =
(RepositoryEntry)query.uniqueResult();
- if (repoEntry == null)
+ if (repoEntry == null || repoEntry.getData() == null)
{
throw new Exception("No such Entry " + name);
}
Added:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/hibernate/MaterializedBlobType.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/hibernate/MaterializedBlobType.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/hibernate/MaterializedBlobType.java 2008-07-28
09:49:11 UTC (rev 11596)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.cms.hibernate;
+
+import java.sql.Types;
+
+import org.hibernate.type.AbstractBynaryType;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class MaterializedBlobType extends AbstractBynaryType
+{
+ public int sqlType()
+ {
+ return Types.BLOB;
+ }
+
+ public String getName()
+ {
+ return "materialized-blob";
+ }
+
+ public Class getReturnedClass()
+ {
+ return byte[].class;
+ }
+
+ protected Object toExternalFormat(byte[] bytes)
+ {
+ return bytes;
+ }
+
+ protected byte[] toInternalFormat(Object bytes)
+ {
+ return (byte[]) bytes;
+ }
+}
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/resources/hibernate/domain.hbm.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/resources/hibernate/domain.hbm.xml 2008-07-27
12:55:55 UTC (rev 11595)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/resources/hibernate/domain.hbm.xml 2008-07-28
09:49:11 UTC (rev 11596)
@@ -60,7 +60,7 @@
<property
name="data"
column="NODE_DATA"
- type="binary"
+ type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
length="100000000"
not-null="true"/>
</class>
@@ -79,7 +79,7 @@
<property
name="data"
column="PROP_DATA"
- type="binary"
+ type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
length="100000000"
not-null="true"/>
</class>
@@ -98,7 +98,7 @@
<property
name="data"
column="REFS_DATA"
- type="binary"
+ type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
length="100000000"
not-null="true"/>
</class>
@@ -136,7 +136,7 @@
<property
name="data"
column="NODE_DATA"
- type="binary"
+ type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
length="100000000"
not-null="true"/>
</class>
@@ -155,7 +155,7 @@
<property
name="data"
column="PROP_DATA"
- type="binary"
+ type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
length="100000000"
not-null="true"/>
</class>
@@ -174,7 +174,7 @@
<property
name="data"
column="REFS_DATA"
- type="binary"
+ type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
length="100000000"
not-null="true"/>
</class>