Author: thomas.heute(a)jboss.com
Date: 2008-10-21 06:07:37 -0400 (Tue, 21 Oct 2008)
New Revision: 12110
Removed:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/MaterializedBlobType.java
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/HibernateStore.java
Log:
Rollbacking 11596 for PostreSQL support
Should fix JBPORTAL-2203
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/HibernateStore.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/HibernateStore.java 2008-10-21
09:41:13 UTC (rev 12109)
+++
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/HibernateStore.java 2008-10-21
10:07:37 UTC (rev 12110)
@@ -142,18 +142,18 @@
selectFileExistStmt = "select 1 from "
+ schemaObjectPrefix + " where FSENTRY_PATH = ? "
- + "and FSENTRY_NAME = ?";
+ + "and FSENTRY_NAME = ? and FSENTRY_DATA is not null";
- selectFolderExistStmt = "select data from "
+ selectFolderExistStmt = "select 1 from "
+ schemaObjectPrefix + " where FSENTRY_PATH = ? "
- + "and FSENTRY_NAME = ?";
+ + "and FSENTRY_NAME = ? and FSENTRY_DATA is null";
selectChildCountStmt = "select count(FSENTRY_NAME) from "
+ schemaObjectPrefix + " where FSENTRY_PATH = ?";
selectDataStmt = "select data from "
+ schemaObjectPrefix + " where FSENTRY_PATH = ? "
- + "and FSENTRY_NAME = ? ";
+ + "and FSENTRY_NAME = ? and FSENTRY_DATA is not null";
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_NAME = ? and FSENTRY_DATA is not null";
initialized = true;
}
@@ -221,27 +221,27 @@
try
{
- String query = "from " + schemaObjectPrefix + " where
FSENTRY_PATH = ? and FSENTRY_NAME = ?";
+ String query = "from " + schemaObjectPrefix + " where
FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null";
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();
- if (versionEntry.getData() != null)
- {
- session.delete(versionEntry);
- deleted = true;
- }
+ session.delete(versionEntry);
}
+
}
else if (schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
@@ -249,12 +249,9 @@
while (iter.hasNext())
{
CMSEntry cmsEntry = (CMSEntry)iter.next();
- if (cmsEntry.getData() != null)
- {
- session.delete(cmsEntry);
- deleted = true;
- }
+ session.delete(cmsEntry);
}
+
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
@@ -262,19 +259,10 @@
while (iter.hasNext())
{
RepositoryEntry repoEntry = (RepositoryEntry)iter.next();
- if (repoEntry.getData() != null)
- {
- session.delete(repoEntry);
- deleted = true;
- }
+ session.delete(repoEntry);
}
- }
- if (!deleted)
- {
- throw new FileSystemException("no such file: " + filePath);
}
-
tx.commit();
}
catch (Exception e)
@@ -329,7 +317,7 @@
{
String query = "from " + schemaObjectPrefix + " where
FSENTRY_PATH = ? and FSENTRY_NAME = ? " +
- "or (FSENTRY_PATH = ?) or (FSENTRY_PATH like ?)";
+ "and FSENTRY_DATA is null or (FSENTRY_PATH = ?) or (FSENTRY_PATH like
?)";
List result = session.createQuery(query)
.setString(0, parentDir)
@@ -338,20 +326,21 @@
.setString(3, folderPath + FileSystem.SEPARATOR + "%")
.list();
- boolean deleted = false;
-
+ if (result.size() == 0)
+ {
+ throw new FileSystemException("no such folder: " + folderPath);
+ }
+
if (schemaObjectPrefix.equals(HibernateStoreConstants.versionClassName))
{
Iterator iter = result.iterator();
while (iter.hasNext())
{
VersionEntry versionEntry = (VersionEntry)iter.next();
- if (versionEntry.getData() == null)
- {
- session.delete(versionEntry);
- deleted = true;
- }
+ session.delete(versionEntry);
+
}
+
}
else if (schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
@@ -359,12 +348,10 @@
while (iter.hasNext())
{
CMSEntry cmsEntry = (CMSEntry)iter.next();
- if (cmsEntry.getData() == null)
- {
- session.delete(cmsEntry);
- deleted = true;
- }
+ session.delete(cmsEntry);
+
}
+
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
@@ -372,19 +359,11 @@
while (iter.hasNext())
{
RepositoryEntry repoEntry = (RepositoryEntry)iter.next();
- if (repoEntry.getData() == null)
- {
- session.delete(repoEntry);
- deleted = true;
- }
+ session.delete(repoEntry);
+
}
- }
- if (!deleted)
- {
- throw new FileSystemException("no such folder: " + folderPath);
}
-
tx.commit();
}
catch (Exception e)
@@ -470,11 +449,7 @@
Iterator iter = rs.iterator();
if (iter.hasNext())
{
- Object object = iter.next();
- if (object != null)
- {
- return true;
- }
+ return true;
}
return false;
}
@@ -517,11 +492,7 @@
Iterator iter = rs.iterator();
if (iter.hasNext())
{
- Object object = iter.next();
- if (object == null)
- {
- return true;
- }
+ return true;
}
return false;
}
@@ -989,11 +960,11 @@
in = IOTools.safeBufferedWrapper(new FileInputStream(f));
if
(schemaObjectPrefix.equals(HibernateStoreConstants.versionClassName))
{
- Query query = session.createQuery("from VersionEntry
where FSENTRY_PATH = ? and FSENTRY_NAME = ?");
+ Query query = session.createQuery("from VersionEntry
where FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null");
query.setString(0, parentDir);
query.setString(1, name);
VersionEntry versionEntry =
(VersionEntry)query.uniqueResult();
- if (versionEntry == null || versionEntry.getData() == null)
+ if (versionEntry == null)
{
throw new Exception("No such Entry " + name);
}
@@ -1006,11 +977,11 @@
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
- Query query = session.createQuery("from CMSEntry where
FSENTRY_PATH = ? and FSENTRY_NAME = ?");
+ Query query = session.createQuery("from CMSEntry where
FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null");
query.setString(0, parentDir);
query.setString(1, name);
CMSEntry cmsEntry = (CMSEntry)query.uniqueResult();
- if (cmsEntry == null || cmsEntry.getData() == null)
+ if (cmsEntry == null)
{
throw new Exception("No such Entry " + name);
}
@@ -1023,11 +994,11 @@
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
- Query query = session.createQuery("from RepositoryEntry
where FSENTRY_PATH = ? and FSENTRY_NAME = ?");
+ Query query = session.createQuery("from RepositoryEntry
where FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null");
query.setString(0, parentDir);
query.setString(1, name);
RepositoryEntry repoEntry =
(RepositoryEntry)query.uniqueResult();
- if (repoEntry == null || repoEntry.getData() == null)
+ if (repoEntry == null)
{
throw new Exception("No such Entry " + name);
}
@@ -1198,11 +1169,11 @@
in = IOTools.safeBufferedWrapper(new FileInputStream(f));
if
(schemaObjectPrefix.equals(HibernateStoreConstants.versionClassName))
{
- Query query = session.createQuery("from VersionEntry
where FSENTRY_PATH = ? and FSENTRY_NAME = ?");
+ Query query = session.createQuery("from VersionEntry
where FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null");
query.setString(0, parentDir);
query.setString(1, name);
VersionEntry versionEntry =
(VersionEntry)query.uniqueResult();
- if (versionEntry == null || versionEntry.getData() == null)
+ if (versionEntry == null)
{
throw new Exception("No such Entry " + name);
}
@@ -1215,11 +1186,11 @@
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
- Query query = session.createQuery("from CMSEntry where
FSENTRY_PATH = ? and FSENTRY_NAME = ?");
+ Query query = session.createQuery("from CMSEntry where
FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null");
query.setString(0, parentDir);
query.setString(1, name);
CMSEntry cmsEntry = (CMSEntry)query.uniqueResult();
- if (cmsEntry == null || cmsEntry.getData() == null)
+ if (cmsEntry == null)
{
throw new Exception("No such Entry " + name);
}
@@ -1232,11 +1203,11 @@
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
- Query query = session.createQuery("from CMSEntry where
FSENTRY_PATH = ? and FSENTRY_NAME = ?");
+ Query query = session.createQuery("from CMSEntry where
FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null");
query.setString(0, parentDir);
query.setString(1, name);
RepositoryEntry repoEntry =
(RepositoryEntry)query.uniqueResult();
- if (repoEntry == null || repoEntry.getData() == null)
+ if (repoEntry == null)
{
throw new Exception("No such Entry " + name);
}
Deleted:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/MaterializedBlobType.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/MaterializedBlobType.java 2008-10-21
09:41:13 UTC (rev 12109)
+++
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/MaterializedBlobType.java 2008-10-21
10:07:37 UTC (rev 12110)
@@ -1,59 +0,0 @@
-/******************************************************************************
- * 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;
- }
-}