JBoss Portal SVN: r12513 - branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-sar/META-INF.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-01-15 04:43:39 -0500 (Thu, 15 Jan 2009)
New Revision: 12513
Modified:
branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
Log:
JBPORTAL-2258 - Create file in CMS not working for several databases
* locally passed for oracle10g, postgresql8, mysql5, hsqdlb
* contrary to earlier discussion, nothing special needed for postgresql support
Modified: branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2009-01-15 09:42:05 UTC (rev 12512)
+++ branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2009-01-15 09:43:39 UTC (rev 12513)
@@ -71,7 +71,8 @@
<attribute name="DefaultContentLocation">portal/cms/conf/default-content/default/</attribute>
<attribute name="DefaultLocale">en</attribute>
<attribute name="RepositoryName">PortalRepository</attribute>
- <attribute name="HomeDir">${jboss.server.data.dir}${/}portal${/}cms${/}conf</attribute>
+ <attribute name="HomeDir">${jboss.server.data.dir}${/}portal${/}cms${/}conf</attribute>
+ <attribute name="CmsSessionFactory">java:/portal/cms/CMSSessionFactory</attribute>
<attribute name="Config">
<Repository>
<!--
17 years, 3 months
JBoss Portal SVN: r12512 - in modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms: hibernate/state and 1 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-01-15 04:42:05 -0500 (Thu, 15 Jan 2009)
New Revision: 12512
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/state/JBossCachePersistenceManager.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JCRCMS.java
Log:
JBPORTAL-2258 - Create file in CMS not working for several databases
* locally passed for oracle10g, postgresql8, mysql5, hsqdlb
* contrary to earlier discussion, nothing special needed for postgresql support
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 2009-01-15 06:38:09 UTC (rev 12511)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/HibernateStore.java 2009-01-15 09:42:05 UTC (rev 12512)
@@ -215,8 +215,7 @@
String name = FileSystemPathUtil.getName(filePath);
Session session = hibernateSessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
-
+ session.beginTransaction();
try
{
@@ -262,13 +261,12 @@
}
}
+ session.getTransaction().commit();
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to delete file: " + filePath;
log.error(msg, e);
throw new FileSystemException(msg, e);
@@ -296,8 +294,7 @@
String name = FileSystemPathUtil.getName(folderPath);
Session session = hibernateSessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
-
+ session.beginTransaction();
try
{
@@ -349,13 +346,12 @@
}
}
+ session.getTransaction().commit();
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to delete folder: " + folderPath;
log.error(msg, e);
throw new FileSystemException(msg, e);
@@ -378,7 +374,7 @@
String name = FileSystemPathUtil.getName(path);
Session session = hibernateSessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
try
{
List rs = session.createQuery(selectExistStmt)
@@ -394,10 +390,8 @@
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to check existence of file system entry: " + path;
log.error(msg, e);
throw new FileSystemException(msg, e);
@@ -421,7 +415,7 @@
String name = FileSystemPathUtil.getName(path);
Session session = hibernateSessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
try
{
List rs = session.createQuery(selectFileExistStmt)
@@ -434,14 +428,13 @@
{
return true;
}
+
return false;
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to check existence of file: " + path;
log.error(msg, e);
throw new FileSystemException(msg, e);
@@ -464,7 +457,7 @@
String name = FileSystemPathUtil.getName(path);
Session session = hibernateSessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
try
{
List rs = session.createQuery(selectFolderExistStmt)
@@ -477,14 +470,13 @@
{
return true;
}
+
return false;
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to check existence of folder: " + path;
log.error(msg, e);
throw new FileSystemException(msg, e);
@@ -507,7 +499,7 @@
String name = FileSystemPathUtil.getName(path);
Session session = hibernateSessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
try
{
List rs = session.createQuery(selectLastModifiedStmt)
@@ -524,10 +516,8 @@
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to determine lastModified of file system entry: " + path;
log.error(msg, e);
throw new FileSystemException(msg, e);
@@ -550,7 +540,7 @@
String name = FileSystemPathUtil.getName(filePath);
Session session = hibernateSessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
try
{
List rs = session.createQuery(selectLengthStmt)
@@ -567,10 +557,8 @@
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to determine length of file: " + filePath;
log.error(msg, e);
throw new FileSystemException(msg, e);
@@ -595,7 +583,7 @@
}
Session session = hibernateSessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
try
{
List rs = session.createQuery(selectChildCountStmt)
@@ -617,10 +605,8 @@
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to determine child count of file system entry: " + path;
log.error(msg, e);
throw new FileSystemException(msg, e);
@@ -857,8 +843,7 @@
String name = FileSystemPathUtil.getName(filePath);
Session session = hibernateSessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
-
+ session.beginTransaction();
try
{
Query query = session.createQuery(selectDataStmt)
@@ -866,20 +851,18 @@
.setString(1, name);
List rs = query.list();
- //
+
Iterator iter = rs.iterator();
//byte[] blob = (byte[])iter.next();
//return new ByteArrayInputStream(blob);
- java.sql.Blob blob = (java.sql.Blob)iter.next();
- return blob.getBinaryStream();
+ java.sql.Blob blob = (java.sql.Blob)iter.next();
+ return new ByteArrayInputStream(IOTools.getBytes(blob.getBinaryStream()));
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to retrieve data of file: " + filePath;
log.error(msg, e);
throw new FileSystemException(msg, e);
@@ -932,7 +915,7 @@
{
// update
Session session = hibernateSessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
try
{
long length = f.length();
@@ -997,13 +980,12 @@
session.save(repoEntry);
session.flush();
}
+ session.getTransaction().commit();
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to update existing file: " + filePath;
log.error(msg, e);
throw new FileSystemException(msg, e);
@@ -1012,7 +994,7 @@
else // create new
{
Session session = hibernateSessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
try
{
long length = f.length();
@@ -1041,13 +1023,12 @@
session.save(repoEntry);
session.flush();
}
+ session.getTransaction().commit();
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to create new file: " + filePath;
log.error(msg, e);
throw new FileSystemException(msg, e);
@@ -1076,13 +1057,6 @@
}
}
- private Blob createBlob(InputStream in)
- throws IOException
- {
- return Hibernate.createBlob(in);
-// return new ByteArrayBlob(in);
- }
-
/**
*
*/
@@ -1153,7 +1127,7 @@
{
// update
Session session = hibernateSessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
try
{
long length = f.length();
@@ -1219,13 +1193,12 @@
session.save(repoEntry);
session.flush();
}
+ session.getTransaction().commit();
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to update existing file: " + filePath;
log.error(msg, e);
throw new FileSystemException(msg, e);
@@ -1234,7 +1207,7 @@
else
{
Session session = hibernateSessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
try
{
long length = f.length();
@@ -1263,13 +1236,12 @@
session.save(repoEntry);
session.flush();
}
+ session.getTransaction().commit();
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to create new file: " + filePath;
log.error(msg, e);
throw new FileSystemException(msg, e);
@@ -1449,7 +1421,7 @@
{
// check if root file system entry exists
Session session = hibernateSessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
try
{
List rs = session.createQuery(selectFolderExistStmt)
@@ -1465,10 +1437,7 @@
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
String msg = "failed to check existence of file system root entry";
log.error(msg, e);
throw new FileSystemException(msg, e);
@@ -1500,7 +1469,7 @@
}
Session session = hibernateSessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
try
{
if (schemaObjectPrefix.equals(HibernateStoreConstants.versionClassName))
@@ -1523,13 +1492,12 @@
session.save(repoEntry);
session.flush();
}
+ session.getTransaction().commit();
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to create folder entry: " + folderPath;
log.error(msg, e);
throw new FileSystemException(msg, e);
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java 2009-01-15 06:38:09 UTC (rev 12511)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java 2009-01-15 09:42:05 UTC (rev 12512)
@@ -530,13 +530,10 @@
// parse propertyData into propertyState
if (nodeData != null)
{
- Session session = null;
- Transaction tx = null;
+ Session session = HibernateUtil.getSessionFactory(this.jndiName).getCurrentSession();
+ session.beginTransaction();
try
{
- session = HibernateUtil.getSessionFactory(this.jndiName).getCurrentSession();
- tx = session.beginTransaction();
-
InputStream in = new ByteArrayInputStream(nodeData);
// setup the propertyState
@@ -546,10 +543,8 @@
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
if (e instanceof NoSuchItemStateException)
{
throw (NoSuchItemStateException)e;
@@ -798,13 +793,10 @@
// parse propertyData into propertyState
if (propertyData != null)
{
- Session session = null;
- Transaction tx = null;
+ Session session = HibernateUtil.getSessionFactory(this.jndiName).getCurrentSession();
+ session.beginTransaction();
try
- {
- session = HibernateUtil.getSessionFactory(this.jndiName).getCurrentSession();
- tx = session.beginTransaction();
-
+ {
InputStream in = new ByteArrayInputStream(propertyData);
// setup the propertyState
@@ -814,10 +806,8 @@
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
if (e instanceof NoSuchItemStateException)
{
throw (NoSuchItemStateException)e;
@@ -1104,13 +1094,10 @@
// parse propertyData into propertyState
if (nodeData != null)
{
- Session session = null;
- Transaction tx = null;
+ Session session = HibernateUtil.getSessionFactory(this.jndiName).getCurrentSession();
+ session.beginTransaction();
try
{
- session = HibernateUtil.getSessionFactory(this.jndiName).getCurrentSession();
- tx = session.beginTransaction();
-
InputStream in = new ByteArrayInputStream(nodeData);
// setup the propertyState
@@ -1120,10 +1107,8 @@
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
if (e instanceof NoSuchItemStateException)
{
throw (NoSuchItemStateException)e;
@@ -1291,30 +1276,19 @@
*/
public void store(ChangeLog changeLog) throws ItemStateException
{
- Session session = null;
- Transaction tx = null;
+ Session session = HibernateUtil.getSessionFactory(this.jndiName).getCurrentSession();
+ session.beginTransaction();
try
- {
- session = HibernateUtil.getSessionFactory(this.jndiName).getCurrentSession();
- tx = session.beginTransaction();
+ {
storeHB(changeLog);
}
catch (ItemStateException e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
throw e;
}
}
- private Blob createBlob(byte[] bytes)
- {
- return Hibernate.createBlob(bytes);
- // return new ByteArrayBlob(bytes);
- }
-
public void storeHB(ChangeLog changeLog) throws ItemStateException
{
Iterator iter = changeLog.deletedStates();
@@ -1394,7 +1368,7 @@
}
Session session = HibernateUtil.getSessionFactory(this.jndiName).getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
try
{
List rs = session.createQuery(query).setString(0, id).list();
@@ -1403,10 +1377,8 @@
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to check existence of node state: " + id;
log.error(msg, e);
throw new ItemStateException(msg, e);
@@ -1449,7 +1421,7 @@
public InputStream get(String blobId) throws Exception
{
Session session = HibernateUtil.getSessionFactory(jndiName).getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
try
{
List rs = session.createQuery(blobSelectData).setString(0, blobId)
@@ -1483,10 +1455,8 @@
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
if (e instanceof NoSuchItemStateException)
{
throw (NoSuchItemStateException)e;
@@ -1506,7 +1476,7 @@
boolean update = exists(blobId);
Session session = HibernateUtil.getSessionFactory(jndiName).getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
if (update)
{
try
@@ -1547,10 +1517,8 @@
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to write node state: " + blobId;
log.error(msg, e);
throw new ItemStateException(msg, e);
@@ -1585,10 +1553,8 @@
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to write node state: " + blobId;
log.error(msg, e);
throw new ItemStateException(msg, e);
@@ -1603,7 +1569,7 @@
public boolean remove(String blobId) throws Exception
{
Session session = HibernateUtil.getSessionFactory(jndiName).getCurrentSession();
- Transaction tx = session.beginTransaction();
+ session.beginTransaction();
try
{
Query query = session.createQuery(nodeBinValSelect).setString(0,
@@ -1617,10 +1583,8 @@
}
catch (Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
+ session.getTransaction().rollback();
+
String msg = "failed to delete binval: " + blobId;
log.error(msg, e);
throw new ItemStateException(msg, e);
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JCRCMS.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2009-01-15 06:38:09 UTC (rev 12511)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2009-01-15 09:42:05 UTC (rev 12512)
@@ -418,34 +418,25 @@
}
public Object execute(Command cmd) throws CMSException
- {
- org.apache.jackrabbit.core.XASession session = null;
- try
- {
- session = (org.apache.jackrabbit.core.XASession)jcr.login("anonid", "");
- }
- catch (Exception e)
- {
- throw new RuntimeException(e); // Fixme
- }
-
+ {
+ org.apache.jackrabbit.core.XASession session = null;
Object obj = null;
boolean isClusterDelegatedRequest = false; //used to indicate this request is from another cluster node instead of the master node
- boolean clusterWorkflowStatus = false;
-
- TransactionManager tm = null;
- org.hibernate.Session hibernateSession = null;
- UserTransaction tx = null;
+ boolean clusterWorkflowStatus = false;
+ TransactionManager tm = null;
+ UserTransaction tx = null;
boolean isStartedHere = false;
try
{
tm = TransactionManagerProvider.JBOSS_PROVIDER.getTransactionManager();
+ isStartedHere = false;
if(tm.getStatus() == Status.STATUS_NO_TRANSACTION)
{
tm.begin();
isStartedHere = true;
}
- hibernateSession = HibernateUtil.getSessionFactory(cmsSessionFactory).getCurrentSession();
+
+ session = (org.apache.jackrabbit.core.XASession)jcr.login("anonid", "");
tx = new JackRabbitTransaction(session);
tx.begin();
17 years, 3 months
JBoss Portal SVN: r12511 - in modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms: hibernate/state and 3 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-01-15 01:38:09 -0500 (Thu, 15 Jan 2009)
New Revision: 12511
Added:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JackRabbitTransaction.java
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/CMSEntry.java
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/RepositoryEntry.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/VersionEntry.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/PortalCMSCacheLoader.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/VersionBinVal.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/WSPBinVal.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JCRCMS.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/util/HibernateUtil.java
Log:
JBPORTAL-2258 - Create file in CMS not working for several databases
* backing up some code.
* oracle, mysql5, and hsqldb finally stable in both standalone/portal integration
* some issue still open for postgresql
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/CMSEntry.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/CMSEntry.java 2009-01-14 20:53:21 UTC (rev 12510)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/CMSEntry.java 2009-01-15 06:38:09 UTC (rev 12511)
@@ -23,8 +23,6 @@
package org.jboss.portal.cms.hibernate;
import java.io.Serializable;
-import org.hibernate.Hibernate;
-import org.jboss.portal.common.io.IOTools;
/** @author <a href="mailto:roy@jboss.org">Roy Russo</a> */
public class CMSEntry implements Serializable
@@ -35,11 +33,9 @@
private Integer key;
private String path;
private String name;
- //private java.sql.Blob data;
+ private java.sql.Blob data;
private long lastmod;
private long length;
-
- private byte[] blobData;
public CMSEntry()
{
@@ -49,11 +45,10 @@
{
this.key = null;
this.path = path;
- this.name = name;
+ this.name = name;
+ this.data = data;
this.lastmod = lastmod;
this.length = length;
-
- this.setData(data);
}
public Integer getKey()
@@ -86,6 +81,16 @@
this.name = name;
}
+ public java.sql.Blob getData()
+ {
+ return data;
+ }
+
+ public void setData(java.sql.Blob data)
+ {
+ this.data = data;
+ }
+
public long getLastmod()
{
return lastmod;
@@ -105,31 +110,4 @@
{
this.length = length;
}
-
- public java.sql.Blob getData()
- {
- java.sql.Blob blob = null;
-
- if(this.blobData != null)
- {
- blob = Hibernate.createBlob(this.blobData);
- }
-
- return blob;
- }
-
- public void setData(java.sql.Blob data)
- {
- try
- {
- if(data != null)
- {
- this.blobData = IOTools.getBytes(data.getBinaryStream());
- }
- }
- catch(Exception e)
- {
- throw new RuntimeException(e);
- }
- }
}
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 2009-01-14 20:53:21 UTC (rev 12510)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/HibernateStore.java 2009-01-15 06:38:09 UTC (rev 12511)
@@ -955,7 +955,7 @@
versionEntry.setLength(length);
session.save(versionEntry);
- //session.flush();
+ session.flush();
}
else if (schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
@@ -975,7 +975,7 @@
cmsEntry.setLength(length);
session.save(cmsEntry);
- //session.flush();
+ session.flush();
}
else if (schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
@@ -995,7 +995,7 @@
repoEntry.setLength(length);
session.save(repoEntry);
- //session.flush();
+ session.flush();
}
}
catch (Exception e)
@@ -1023,7 +1023,7 @@
VersionEntry versionEntry = new VersionEntry(parentDir, name, Hibernate.createBlob(in), System.currentTimeMillis(), length);
session.save(versionEntry);
- //session.flush();
+ session.flush();
}
else if (schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
@@ -1031,7 +1031,7 @@
CMSEntry cmsEntry = new CMSEntry(parentDir, name, Hibernate.createBlob(in), System.currentTimeMillis(), length);
session.save(cmsEntry);
- //session.flush();
+ session.flush();
}
else if (schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
@@ -1039,7 +1039,7 @@
RepositoryEntry repoEntry = new RepositoryEntry(parentDir, name, Hibernate.createBlob(in), System.currentTimeMillis(), length);
session.save(repoEntry);
- //session.flush();
+ session.flush();
}
}
catch (Exception e)
@@ -1176,7 +1176,7 @@
versionEntry.setLength(length);
session.save(versionEntry);
- //session.flush();
+ session.flush();
}
else if (schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
@@ -1196,7 +1196,7 @@
cmsEntry.setLength(length);
session.save(cmsEntry);
- //session.flush();
+ session.flush();
}
else if (schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
@@ -1217,7 +1217,7 @@
repoEntry.setLength(length);
session.save(repoEntry);
- //session.flush();
+ session.flush();
}
}
catch (Exception e)
@@ -1245,7 +1245,7 @@
VersionEntry versionEntry = new VersionEntry(parentDir, name, Hibernate.createBlob(in), System.currentTimeMillis(), length);
session.save(versionEntry);
- //session.flush();
+ session.flush();
}
else if (schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
@@ -1253,7 +1253,7 @@
CMSEntry cmsEntry = new CMSEntry(parentDir, name, Hibernate.createBlob(in), System.currentTimeMillis(), length);
session.save(cmsEntry);
- //session.flush();
+ session.flush();
}
else if (schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
@@ -1261,7 +1261,7 @@
RepositoryEntry repoEntry = new RepositoryEntry(parentDir, name, Hibernate.createBlob(in), System.currentTimeMillis(), length);
session.save(repoEntry);
- //session.flush();
+ session.flush();
}
}
catch (Exception e)
@@ -1508,21 +1508,20 @@
VersionEntry versionEntry = new VersionEntry(parentDir, name, null, System.currentTimeMillis(), 0);
session.save(versionEntry);
- //session.flush();
+ session.flush();
}
else if (schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
CMSEntry cmsEntry = new CMSEntry(parentDir, name, null, System.currentTimeMillis(), 0);
session.save(cmsEntry);
- //session.flush();
}
else if (schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
RepositoryEntry repoEntry = new RepositoryEntry(parentDir, name, null, System.currentTimeMillis(), 0);
session.save(repoEntry);
- //session.flush();
+ session.flush();
}
}
catch (Exception e)
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/RepositoryEntry.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/RepositoryEntry.java 2009-01-14 20:53:21 UTC (rev 12510)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/RepositoryEntry.java 2009-01-15 06:38:09 UTC (rev 12511)
@@ -23,8 +23,6 @@
package org.jboss.portal.cms.hibernate;
import java.io.Serializable;
-import org.hibernate.Hibernate;
-import org.jboss.portal.common.io.IOTools;
/** @author <a href="mailto:roy@jboss.org">Roy Russo</a> */
public class RepositoryEntry implements Serializable
@@ -35,11 +33,9 @@
private Integer key;
private String path;
private String name;
- //private java.sql.Blob data;
+ private java.sql.Blob data;
private long lastmod;
private long length;
-
- private byte[] blobData;
public RepositoryEntry()
{
@@ -50,10 +46,9 @@
this.key = null;
this.path = path;
this.name = name;
+ this.data = data;
this.lastmod = lastmod;
this.length = length;
-
- this.setData(data);
}
public Integer getKey()
@@ -86,6 +81,16 @@
this.name = name;
}
+ public java.sql.Blob getData()
+ {
+ return data;
+ }
+
+ public void setData(java.sql.Blob data)
+ {
+ this.data = data;
+ }
+
public long getLastmod()
{
return lastmod;
@@ -105,31 +110,4 @@
{
this.length = length;
}
-
- public java.sql.Blob getData()
- {
- java.sql.Blob blob = null;
-
- if(this.blobData != null)
- {
- blob = Hibernate.createBlob(this.blobData);
- }
-
- return blob;
- }
-
- public void setData(java.sql.Blob data)
- {
- try
- {
- if(data != null)
- {
- this.blobData = IOTools.getBytes(data.getBinaryStream());
- }
- }
- catch(Exception e)
- {
- throw new RuntimeException(e);
- }
- }
}
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/VersionEntry.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/VersionEntry.java 2009-01-14 20:53:21 UTC (rev 12510)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/VersionEntry.java 2009-01-15 06:38:09 UTC (rev 12511)
@@ -23,8 +23,6 @@
package org.jboss.portal.cms.hibernate;
import java.io.Serializable;
-import org.hibernate.Hibernate;
-import org.jboss.portal.common.io.IOTools;
/** @author <a href="mailto:roy@jboss.org">Roy Russo</a> */
public class VersionEntry implements Serializable
@@ -35,11 +33,9 @@
private Integer key;
private String path;
private String name;
- //private java.sql.Blob data;
+ private java.sql.Blob data;
private long lastmod;
private long length;
-
- private byte[] blobData;
public VersionEntry()
{
@@ -49,11 +45,10 @@
{
this.key = null;
this.path = path;
- this.name = name;
+ this.name = name;
+ this.data = data;
this.lastmod = lastmod;
this.length = length;
-
- this.setData(data);
}
public Integer getKey()
@@ -86,6 +81,16 @@
this.name = name;
}
+ public java.sql.Blob getData()
+ {
+ return data;
+ }
+
+ public void setData(java.sql.Blob data)
+ {
+ this.data = data;
+ }
+
public long getLastmod()
{
return lastmod;
@@ -105,31 +110,4 @@
{
this.length = length;
}
-
- public java.sql.Blob getData()
- {
- java.sql.Blob blob = null;
-
- if(this.blobData != null)
- {
- blob = Hibernate.createBlob(this.blobData);
- }
-
- return blob;
- }
-
- public void setData(java.sql.Blob data)
- {
- try
- {
- if(data != null)
- {
- this.blobData = IOTools.getBytes(data.getBinaryStream());
- }
- }
- catch(Exception e)
- {
- throw new RuntimeException(e);
- }
- }
}
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java 2009-01-14 20:53:21 UTC (rev 12510)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java 2009-01-15 06:38:09 UTC (rev 12511)
@@ -1527,7 +1527,7 @@
//versionNode.setData(IOTools.getBytes(in));
versionNode.setData(Hibernate.createBlob(in));
- //session.flush();
+ session.flush();
}
else if (schemaObjectPrefix
.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
@@ -1542,7 +1542,7 @@
//wspNode.setData(IOTools.getBytes(in));
wspNode.setData(Hibernate.createBlob(in));
- //session.flush();
+ session.flush();
}
}
catch (Exception e)
@@ -1571,7 +1571,7 @@
Hibernate.createBlob(in));
session.save(versionNode);
- //session.flush();
+ session.flush();
}
else if (schemaObjectPrefix
.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
@@ -1580,7 +1580,7 @@
WSPBinVal wspNode = new WSPBinVal(blobId, Hibernate.createBlob(in));
session.save(wspNode);
- //session.flush();
+ session.flush();
}
}
catch (Exception e)
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/PortalCMSCacheLoader.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/PortalCMSCacheLoader.java 2009-01-14 20:53:21 UTC (rev 12510)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/PortalCMSCacheLoader.java 2009-01-15 06:38:09 UTC (rev 12511)
@@ -691,168 +691,103 @@
return oldValue;
}
- //-----------------------------------------------------------------------------------------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
- *
- *
- */
- private Set getChildrenNames(String query) throws Exception
- {
- Set children = null;
- Session session = null;
- Transaction tx = null;
- try
- {
- session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).getCurrentSession();
- tx = session.beginTransaction();
- List rs = session.createQuery(query).list();
- for (Iterator itr = rs.iterator(); itr.hasNext();)
- {
- String id = (String)itr.next();
- if (children == null)
- {
- children = new HashSet();
- }
- children.add(PortalCMSCacheLoader.parseNodeName(id));
- }
- }
- catch(Exception e)
- {
- if(tx != null)
- {
- tx.rollback();
- }
- throw e;
- }
- return children;
- }
+ *
+ *
+ */
+ private Set getChildrenNames(String query) throws Exception
+ {
+ Set children = null;
+ Session session = null;
+ session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).getCurrentSession();
- /**
- *
- *
- */
- private Object loadNode(String query, String id) throws Exception
- {
- Object node = null;
- Session session = null;
- Transaction tx = null;
- try
- {
- session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).getCurrentSession();
- tx = session.beginTransaction();
-
- //node = session.createQuery(query).setString(0,id).uniqueResult();
- List rs = session.createQuery(query).setString(0, id).list();
- if (rs != null && !rs.isEmpty())
- {
- node = rs.iterator().next();
- }
- }
- catch(Exception e)
- {
- if(tx != null)
- {
- tx.rollback();
- }
- throw e;
- }
- return node;
- }
+ List rs = session.createQuery(query).list();
+ for (Iterator itr = rs.iterator(); itr.hasNext();)
+ {
+ String id = (String)itr.next();
+ if (children == null)
+ {
+ children = new HashSet();
+ }
+ children.add(PortalCMSCacheLoader.parseNodeName(id));
+ }
+
+ return children;
+ }
- /**
- *
- *
- */
- private Object loadManagedNode(String query, String id) throws Exception
- {
- Object node = null;
- Session session = null;
- Transaction tx = null;
- try
- {
- session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).getCurrentSession();
- tx = session.beginTransaction();
-
- //node = session.createQuery(query).setString(0,id).uniqueResult();
- List rs = session.createQuery(query).setString(0, id).list();
- if (rs != null && !rs.isEmpty())
- {
- node = rs.iterator().next();
- }
- return node;
- }
- catch(Exception e)
- {
- if(tx != null)
- {
- tx.rollback();
- }
- throw e;
- }
- }
+ /**
+ *
+ *
+ */
+ private Object loadNode(String query, String id) throws Exception
+ {
+ Object node = null;
+ Session session = null;
+ session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).getCurrentSession();
- /**
- *
- */
- private void save(Object object) throws Exception
- {
- Session session = null;
- Transaction tx = null;
- try
- {
- session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).getCurrentSession();
- tx = session.beginTransaction();
-
- if (((Base)object).getKey() != null)
- {
- session.merge(object);
- }
- else
- {
- session.save(object);
- }
- }
- catch(Exception e)
- {
- if(tx != null)
- {
- tx.rollback();
- }
- throw e;
- }
- }
+ //node = session.createQuery(query).setString(0,id).uniqueResult();
+ List rs = session.createQuery(query).setString(0, id).list();
+ if (rs != null && !rs.isEmpty())
+ {
+ node = rs.iterator().next();
+ }
+
+ return node;
+ }
- /**
- *
- *
- */
- private Object delete(String loadQuery, String id) throws Exception
- {
- Session session = null;
- Transaction tx = null;
- try
- {
- Object removedValue = null;
- removedValue = this.loadManagedNode(loadQuery, id);
- if (removedValue != null)
- {
- session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).getCurrentSession();
- tx = session.beginTransaction();
-
- session.delete(removedValue);
- }
- return removedValue;
- }
- catch(Exception e)
- {
- if(tx != null)
- {
- tx.rollback();
- }
- throw e;
- }
- }
+ /**
+ *
+ *
+ */
+ private Object loadManagedNode(String query, String id) throws Exception
+ {
+ Object node = null;
+ Session session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).getCurrentSession();
+ //node = session.createQuery(query).setString(0,id).uniqueResult();
+ List rs = session.createQuery(query).setString(0, id).list();
+ if (rs != null && !rs.isEmpty())
+ {
+ node = rs.iterator().next();
+ }
+
+ return node;
+ }
+
+ /**
+ *
+ */
+ private void save(Object object) throws Exception
+ {
+ Session session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).getCurrentSession();
+ if (((Base)object).getKey() != null)
+ {
+ session.merge(object);
+ }
+ else
+ {
+ session.save(object);
+ }
+ session.flush();
+ }
+
+ /**
+ *
+ *
+ */
+ private Object delete(String loadQuery, String id) throws Exception
+ {
+ Object removedValue = null;
+ removedValue = this.loadManagedNode(loadQuery, id);
+ if (removedValue != null)
+ {
+ Session session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).getCurrentSession();
+ session.delete(removedValue);
+ session.flush();
+ }
+ return removedValue;
+ }
//---------------nodeName related methods-------------------------------------------------------------------------------------------------------------
/**
*
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/VersionBinVal.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/VersionBinVal.java 2009-01-14 20:53:21 UTC (rev 12510)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/VersionBinVal.java 2009-01-15 06:38:09 UTC (rev 12511)
@@ -24,9 +24,6 @@
import java.io.Serializable;
-import org.hibernate.Hibernate;
-import org.jboss.portal.common.io.IOTools;
-
/** @author <a href="mailto:roy@jboss.org">Roy Russo</a> */
public class VersionBinVal implements Serializable
{
@@ -35,9 +32,7 @@
private Integer key;
private String id;
- //private java.sql.Blob data;
-
- private byte[] blobData;
+ private java.sql.Blob data;
public VersionBinVal()
{
@@ -47,8 +42,7 @@
{
this.key = null;
this.id = id;
-
- this.setData(data);
+ this.data = data;
}
public Integer getKey()
@@ -73,28 +67,11 @@
public java.sql.Blob getData()
{
- java.sql.Blob blob = null;
-
- if(this.blobData != null)
- {
- blob = Hibernate.createBlob(this.blobData);
- }
-
- return blob;
+ return data;
}
public void setData(java.sql.Blob data)
{
- try
- {
- if(data != null)
- {
- this.blobData = IOTools.getBytes(data.getBinaryStream());
- }
- }
- catch(Exception e)
- {
- throw new RuntimeException(e);
- }
+ this.data = data;
}
}
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/WSPBinVal.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/WSPBinVal.java 2009-01-14 20:53:21 UTC (rev 12510)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/WSPBinVal.java 2009-01-15 06:38:09 UTC (rev 12511)
@@ -24,9 +24,6 @@
import java.io.Serializable;
-import org.hibernate.Hibernate;
-import org.jboss.portal.common.io.IOTools;
-
/** @author <a href="mailto:roy@jboss.org">Roy Russo</a> */
public class WSPBinVal implements Serializable
{
@@ -35,8 +32,7 @@
private Integer key;
private String id;
- //private java.sql.Blob data;
- private byte[] blobData;
+ private java.sql.Blob data;
public WSPBinVal()
{
@@ -46,8 +42,7 @@
{
this.key = null;
this.id = id;
-
- this.setData(data);
+ this.data = data;
}
public Integer getKey()
@@ -72,28 +67,11 @@
public java.sql.Blob getData()
{
- java.sql.Blob blob = null;
-
- if(this.blobData != null)
- {
- blob = Hibernate.createBlob(this.blobData);
- }
-
- return blob;
+ return data;
}
public void setData(java.sql.Blob data)
{
- try
- {
- if(data != null)
- {
- this.blobData = IOTools.getBytes(data.getBinaryStream());
- }
- }
- catch(Exception e)
- {
- throw new RuntimeException(e);
- }
+ this.data = data;
}
}
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java 2009-01-14 20:53:21 UTC (rev 12510)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java 2009-01-15 06:38:09 UTC (rev 12511)
@@ -42,6 +42,7 @@
import org.jboss.portal.cms.security.PortalCMSSecurityContext;
import org.jboss.portal.cms.util.HibernateUtil;
import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.Role;
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.identity.User;
@@ -167,8 +168,68 @@
{
this.cmsSessionFactory = cmsSessionFactory;
}
- //-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
/**
+ * This turns off acl security only for a particular thread. This is used by system level operations that need to
+ * integrate with the CMS
+ * <p/>
+ * Example is: the workflow daemon that publishes a content as live when a manager approves it. Without turning this
+ * off, the daemon thread is running in Anonymous mode which obviously does not have the rights to publish the
+ * content
+ */
+ private static ThreadLocal turnOff = new ThreadLocal();
+
+ public static void turnOff()
+ {
+ ACLInterceptor.turnOff.set(new Boolean(true));
+ }
+
+ public static void turnOn()
+ {
+ ACLInterceptor.turnOff.set(null);
+ }
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ public void start() throws Exception
+ {
+ log.info("AuthorizationManager initialized=" + this.authorizationManager);
+
+ if (this.jndiName != null)
+ {
+ this.jndiBinding = new JNDI.Binding(jndiName, this);
+ this.jndiBinding.bind();
+ }
+
+ try
+ {
+ roleModule = (RoleModule)new InitialContext().lookup("java:portal/RoleModule");
+ }
+ catch (NamingException e)
+ {
+ log.error("Cannot obtain RoleModule from JNDI: ", e);
+ throw e;
+ }
+
+ //check and see if cms permissions exist...if not, boot it with the default policy
+ //specified in the configuration
+ if (!this.isBootRequired())
+ {
+ return;
+ }
+
+ //go ahead and boot the cms access policy with default policy specified in the configuration
+ this.initBootPolicy();
+ }
+
+ public void stop() throws Exception
+ {
+ if (this.jndiBinding != null)
+ {
+ this.jndiBinding.unbind();
+ this.jndiBinding = null;
+ }
+ }
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
*
*/
protected Object invoke(JCRCommand invocation) throws Exception, InvocationException
@@ -218,161 +279,8 @@
return invocation.invokeNext();
}
}
-
+ //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
- *
- */
- public void start() throws Exception
- {
- Session session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).openSession();
- Transaction tx = session.beginTransaction();
- try
- {
- log.info("AuthorizationManager initialized=" + this.authorizationManager);
-
- if (this.jndiName != null)
- {
- this.jndiBinding = new JNDI.Binding(jndiName, this);
- this.jndiBinding.bind();
- }
-
-
- this.initRoleModule();
-
- //check and see if cms permissions exist...if not, boot it with the default policy
- //specified in the configuration
- if (!this.isBootRequired())
- {
- return;
- }
-
- //go ahead and boot the cms access policy with default policy specified in the configuration
- this.storeBootPolicy();
-
- tx.commit();
- }
- catch(Exception e)
- {
- log.error(this, e);
-
- if(tx != null)
- {
- tx.rollback();
- }
-
- throw e;
- }
- finally
- {
- if(session != null && session.isOpen())
- {
- session.close();
- }
- }
- }
-
- /** @throws Exception */
- public void stop() throws Exception
- {
- if (this.jndiBinding != null)
- {
- this.jndiBinding.unbind();
- this.jndiBinding = null;
- }
- }
-
- /**
- * This turns off acl security only for a particular thread. This is used by system level operations that need to
- * integrate with the CMS
- * <p/>
- * Example is: the workflow daemon that publishes a content as live when a manager approves it. Without turning this
- * off, the daemon thread is running in Anonymous mode which obviously does not have the rights to publish the
- * content
- */
- private static ThreadLocal turnOff = new ThreadLocal();
-
- public static void turnOff()
- {
- ACLInterceptor.turnOff.set(new Boolean(true));
- }
-
- public static void turnOn()
- {
- ACLInterceptor.turnOff.set(null);
- }
- //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- private void initRoleModule() throws Exception
- {
- try
- {
- roleModule = (RoleModule)new InitialContext().lookup("java:portal/RoleModule");
- }
- catch (NamingException e)
- {
- log.error("Cannot obtain RoleModule from JNDI: ", e);
- throw e;
- }
- }
-
- private void storeBootPolicy() throws Exception
- {
- InputStream is = null;
- try
- {
- //process the specified defaultPolicy
- is = new ByteArrayInputStream(this.defaultPolicy.getBytes());
- Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is);
-
- NodeList criteria = document.getElementsByTagName("criteria");
- if (criteria != null)
- {
- for (int i = 0; i < criteria.getLength(); i++)
- {
- Element criteriaElem = (Element)criteria.item(i);
- String name = criteriaElem.getAttribute("name");
- String value = criteriaElem.getAttribute("value");
-
- //permission setup
- NodeList permissions = criteriaElem.getElementsByTagName("permission");
- if (permissions != null)
- {
- Session session = null;
- Transaction tx = null;
- Collection parsedPermissions = this.parseDefaultPermissions(permissions);
- try
- {
- session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).getCurrentSession();
- tx = session.beginTransaction();
- for (Iterator itr = parsedPermissions.iterator(); itr.hasNext();)
- {
- Permission permission = (Permission)itr.next();
- permission.addCriteria(new Criteria(name, value));
- Set securityBinding = new HashSet();
- securityBinding.add(permission);
- this.authorizationManager.getProvider().setSecurityBindings(null, securityBinding);
- }
- }
- catch (Exception e)
- {
- if(tx != null)
- {
- tx.rollback();
- }
- }
- }
- }
- }
- }
- finally
- {
- if (is != null)
- {
- is.close();
- }
- }
- }
-
- /**
* Filters any files/folders based on the user's access. The filter is applied to folders/files returned by invoking
* a CMS command
*
@@ -454,9 +362,73 @@
}
return filteredResponse;
}
-
+ private void initBootPolicy() throws Exception
+ {
+ InputStream is = null;
+ try
+ {
+ //process the specified defaultPolicy
+ is = new ByteArrayInputStream(this.defaultPolicy.getBytes());
+ Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is);
+ NodeList criteria = document.getElementsByTagName("criteria");
+ if (criteria != null)
+ {
+ for (int i = 0; i < criteria.getLength(); i++)
+ {
+ Element criteriaElem = (Element)criteria.item(i);
+ String name = criteriaElem.getAttribute("name");
+ String value = criteriaElem.getAttribute("value");
+
+ //permission setup
+ NodeList permissions = criteriaElem.getElementsByTagName("permission");
+ if (permissions != null)
+ {
+ Session session = null;
+ Transaction tx = null;
+ Collection parsedPermissions = this.parseDefaultPermissions(permissions);
+ try
+ {
+ session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).openSession();
+ tx = session.beginTransaction();
+ for (Iterator itr = parsedPermissions.iterator(); itr.hasNext();)
+ {
+ Permission permission = (Permission)itr.next();
+ permission.addCriteria(new Criteria(name, value));
+ Set securityBinding = new HashSet();
+ securityBinding.add(permission);
+ this.authorizationManager.getProvider().setSecurityBindings(null, securityBinding);
+ }
+ tx.commit();
+ }
+ catch (Exception e)
+ {
+ if(tx != null)
+ {
+ tx.rollback();
+ }
+ }
+ finally
+ {
+ if(session != null && session.isOpen())
+ {
+ session.close();
+ }
+ }
+ }
+ }
+ }
+ }
+ finally
+ {
+ if (is != null)
+ {
+ is.close();
+ }
+ }
+ }
+
/**
* Parses and produces Permission objects for the default policy
*
@@ -505,16 +477,45 @@
* @return
*/
private Role getRole(String name) throws Exception
- {
- try
- {
- return this.roleModule.findRoleByName(name);
- }
- catch(Exception e)
- {
- log.debug(this, e);
- return null;
- }
+ {
+ Role role = null;
+
+ //since this is at app start up and not on user thread...need to create a transaction context.
+ InitialContext context = new InitialContext();
+ SessionFactory sessionFactory = (SessionFactory)context.lookup(this.identitySessionFactory);
+ Session session = sessionFactory.openSession();
+ Transaction tx = session.beginTransaction();
+ try
+ {
+ role = this.roleModule.findRoleByName(name);
+ tx.commit();
+ }
+ catch(IdentityException ie)
+ {
+ if(tx != null)
+ {
+ tx.rollback();
+ }
+ return null;
+ }
+ catch (Exception e)
+ {
+ if(tx != null)
+ {
+ tx.rollback();
+ }
+ log.error(this, e);
+ throw e;
+ }
+ finally
+ {
+ if(session != null && session.isOpen())
+ {
+ session.close();
+ }
+ }
+
+ return role;
}
/**
@@ -527,7 +528,7 @@
boolean bootRequired = false;
String hsqlQuery = "select count(permission) from org.jboss.portal.cms.security.Permission as permission";
- Session session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).getCurrentSession();
+ Session session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).openSession();
Transaction tx = session.beginTransaction();
try
{
@@ -537,14 +538,22 @@
{
bootRequired = true;
}
+ tx.commit();
}
catch(Exception e)
{
- if(tx != null)
- {
- tx.rollback();
- }
- }
+ if(tx != null)
+ {
+ tx.rollback();
+ }
+ }
+ finally
+ {
+ if(session != null && session.isOpen())
+ {
+ session.close();
+ }
+ }
return bootRequired;
}
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JCRCMS.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2009-01-14 20:53:21 UTC (rev 12510)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2009-01-15 06:38:09 UTC (rev 12511)
@@ -47,6 +47,7 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.invocation.InvocationHandler;
import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.transaction.TransactionManagerProvider;
import org.jboss.portal.common.net.URLNavigator;
import org.jboss.portal.common.net.URLVisitor;
import org.jboss.portal.common.xml.XMLTools;
@@ -60,10 +61,13 @@
import org.hibernate.Transaction;
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+import javax.transaction.TransactionManager;
+import javax.naming.InitialContext;
+
import javax.jcr.Repository;
import javax.jcr.Session;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.URL;
@@ -325,10 +329,16 @@
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
public void startService() throws Exception
{
- org.hibernate.Session session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).openSession();
- Transaction tx = session.beginTransaction();
+ TransactionManager tm = null;
+ boolean isStartedHere = false;
try
- {
+ {
+ tm = TransactionManagerProvider.JBOSS_PROVIDER.getTransactionManager();
+ if(tm.getStatus() == Status.STATUS_NO_TRANSACTION)
+ {
+ tm.begin();
+ isStartedHere = true;
+ }
if (this.jndiName != null)
{
@@ -348,31 +358,35 @@
watch.stop();
log.info("Started JCR CMS in: " + watch);
- tx.commit();
+ if(isStartedHere)
+ {
+ tm.commit();
+ }
}
catch(Exception e)
{
log.error(this, e);
- if(tx != null)
+
+ if(isStartedHere)
{
- tx.rollback();
+ tm.rollback();
}
- }
- finally
- {
- if(session !=null && session.isOpen())
- {
- session.close();
- }
- }
+ }
}
public void stopService()
- {
- org.hibernate.Session session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).openSession();
- Transaction tx = session.beginTransaction();
+ {
+ TransactionManager tm = null;
+ boolean isStartedHere = false;
try
- {
+ {
+ tm = TransactionManagerProvider.JBOSS_PROVIDER.getTransactionManager();
+ if(tm.getStatus() == Status.STATUS_NO_TRANSACTION)
+ {
+ tm.begin();
+ isStartedHere = true;
+ }
+
if (jndiBinding != null)
{
jndiBinding.unbind();
@@ -381,29 +395,26 @@
log.info("Stopping JCR CMS");
stopJCR();
- tx.commit();
+ if(isStartedHere)
+ {
+ tm.commit();
+ }
}
catch(Exception e)
{
- if(tx != null)
- {
- try
- {
- tx.rollback();
- }
- catch(Exception tme)
- {
- log.error(this, tme);
- }
- }
- }
- finally
- {
- if(session !=null && session.isOpen())
- {
- session.close();
- }
- }
+ try
+ {
+ if(isStartedHere)
+ {
+ tm.rollback();
+ }
+ }
+ catch(Exception rbe)
+ {
+ throw new RuntimeException(rbe);
+ }
+ throw new RuntimeException(e);
+ }
}
public Object execute(Command cmd) throws CMSException
@@ -417,37 +428,27 @@
{
throw new RuntimeException(e); // Fixme
}
- // get XAResource
- XAResource xares = session.getXAResource();
-
- // create dummy Xid
- Xid xid = new Xid()
- {
- public byte[] getBranchQualifier()
- {
- return new byte[0];
- }
-
- public int getFormatId()
- {
- return 0;
- }
-
- public byte[] getGlobalTransactionId()
- {
- return new byte[0];
- }
- };
-
+
Object obj = null;
boolean isClusterDelegatedRequest = false; //used to indicate this request is from another cluster node instead of the master node
boolean clusterWorkflowStatus = false;
- org.hibernate.Session hibernateSession = HibernateUtil.getSessionFactory(this.cmsSessionFactory).openSession();
- Transaction tx = hibernateSession.beginTransaction();
+
+ TransactionManager tm = null;
+ org.hibernate.Session hibernateSession = null;
+ UserTransaction tx = null;
+ boolean isStartedHere = false;
try
- {
- xares.start(xid, XAResource.TMNOFLAGS);
-
+ {
+ tm = TransactionManagerProvider.JBOSS_PROVIDER.getTransactionManager();
+ if(tm.getStatus() == Status.STATUS_NO_TRANSACTION)
+ {
+ tm.begin();
+ isStartedHere = true;
+ }
+ hibernateSession = HibernateUtil.getSessionFactory(cmsSessionFactory).getCurrentSession();
+ tx = new JackRabbitTransaction(session);
+ tx.begin();
+
//Check and make sure in the case of a clustered call, the Identity propagated
//as part of the invocation is handled correctly
JCRCommandContext propagatedContext = (JCRCommandContext)((JCRCommand)cmd).getContext();
@@ -504,32 +505,35 @@
obj = jcrCmd.execute();
}
- //committ the transaction
- xares.end(xid, XAResource.TMSUCCESS);
- xares.prepare(xid);
+ //Save the changes during this session
session.save();
- xares.commit(xid, false);
-
- tx.commit();
+ tx.commit();
+ if(isStartedHere)
+ {
+ tm.commit();
+ }
}
catch (Exception e)
{
log.error(this, e);
- try
+
+ if(tx != null)
{
- xares.rollback(xid);
+ try
+ {
+ tx.rollback();
+ }
+ catch(Exception rbe)
+ {
+ log.error(this, rbe);
+ }
}
- catch (Exception ex)
- {
- //we tried to roll it back...not sure what more we can do here
- throw new CMSException(ex);
- }
- if(tx != null)
+ if(isStartedHere)
{
try
{
- tx.rollback();
+ tm.rollback();
}
catch(Exception rbe)
{
@@ -551,12 +555,13 @@
}
}
finally
- {
+ {
if (session != null)
{
//must do this otherwise, the whole cms will hang
session.logout();
}
+
if (isClusterDelegatedRequest)
{
JCRCMS.getUserInfo().set(null);
@@ -564,11 +569,7 @@
if (clusterWorkflowStatus)
{
JCRCMS.turnOnWorkflow();
- }
- if(hibernateSession !=null && hibernateSession.isOpen())
- {
- hibernateSession.close();
- }
+ }
}
return obj;
}
Added: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JackRabbitTransaction.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JackRabbitTransaction.java (rev 0)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JackRabbitTransaction.java 2009-01-15 06:38:09 UTC (rev 12511)
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.jboss.portal.cms.impl.jcr;
+
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+import javax.transaction.xa.XAException;
+import javax.transaction.UserTransaction;
+import javax.transaction.Status;
+import javax.transaction.NotSupportedException;
+import javax.transaction.SystemException;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.RollbackException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.api.XASession;
+
+/**
+ * Internal {@link javax.transaction.UserTransaction} implementation.
+ */
+public class JackRabbitTransaction implements UserTransaction
+{
+
+ /**
+ * Global transaction id counter
+ */
+ private static byte counter = 0;
+
+ /**
+ * XAResource
+ */
+ private final XAResource xares;
+
+ /**
+ * Xid
+ */
+ private Xid xid;
+
+ /**
+ * Status
+ */
+ private int status = Status.STATUS_NO_TRANSACTION;
+
+ /**
+ * Create a new instance of this class. Takes a session as parameter.
+ * @param session session. If session is not of type
+ * {@link XASession}, an <code>IllegalArgumentException</code>
+ * is thrown
+ */
+ public JackRabbitTransaction(Session session)
+ {
+ if (session instanceof XASession)
+ {
+ xares = ((XASession) session).getXAResource();
+ }
+ else
+ {
+ throw new IllegalArgumentException("Session not of type XASession");
+ }
+ }
+
+ /**
+ * @see javax.transaction.UserTransaction#begin
+ */
+ public void begin() throws NotSupportedException, SystemException
+ {
+ if (status != Status.STATUS_NO_TRANSACTION)
+ {
+ throw new IllegalStateException("Transaction already active");
+ }
+
+ try
+ {
+ xid = new XidImpl(counter++);
+ xares.start(xid, XAResource.TMNOFLAGS);
+ status = Status.STATUS_ACTIVE;
+
+ } catch (XAException e)
+ {
+ e.printStackTrace();
+ throw new SystemException("Unable to begin transaction: " +
+ "XA_ERR=" + e.errorCode);
+ }
+ }
+
+ /**
+ * @see javax.transaction.UserTransaction#commit
+ */
+ public void commit() throws HeuristicMixedException,
+ HeuristicRollbackException, IllegalStateException,
+ RollbackException, SecurityException, SystemException
+ {
+
+ if (status != Status.STATUS_ACTIVE)
+ {
+ throw new IllegalStateException("Transaction not active");
+ }
+
+ try
+ {
+ xares.end(xid, XAResource.TMSUCCESS);
+
+ status = Status.STATUS_PREPARING;
+ xares.prepare(xid);
+ status = Status.STATUS_PREPARED;
+
+ status = Status.STATUS_COMMITTING;
+ xares.commit(xid, false);
+ status = Status.STATUS_COMMITTED;
+
+ } catch (XAException e)
+ {
+
+ if (e.errorCode >= XAException.XA_RBBASE &&
+ e.errorCode <= XAException.XA_RBEND)
+ {
+ RollbackException re = new RollbackException(
+ "Transaction rolled back: XA_ERR=" + e.errorCode);
+ re.initCause(e.getCause());
+ throw re;
+ } else
+ {
+ SystemException se = new SystemException(
+ "Unable to commit transaction: XA_ERR=" + e.errorCode);
+ se.initCause(e.getCause());
+ throw se;
+ }
+ }
+ }
+
+ /**
+ * @see javax.transaction.UserTransaction#getStatus
+ */
+ public int getStatus() throws SystemException
+ {
+ return status;
+ }
+
+ /**
+ * @see javax.transaction.UserTransaction#rollback
+ */
+ public void rollback() throws IllegalStateException, SecurityException,
+ SystemException
+ {
+
+ if (status != Status.STATUS_ACTIVE &&
+ status != Status.STATUS_MARKED_ROLLBACK)
+ {
+
+ throw new IllegalStateException("Transaction not active");
+ }
+
+ try
+ {
+ xares.end(xid, XAResource.TMFAIL);
+
+ status = Status.STATUS_ROLLING_BACK;
+ xares.rollback(xid);
+ status = Status.STATUS_ROLLEDBACK;
+ }
+ catch (XAException e)
+ {
+ SystemException se = new SystemException(
+ "Unable to rollback transaction: XA_ERR=" + e.errorCode);
+ se.initCause(e.getCause());
+ throw se;
+ }
+ }
+
+ /**
+ * @see javax.transaction.UserTransaction#setRollbackOnly()
+ */
+ public void setRollbackOnly() throws IllegalStateException, SystemException
+ {
+ if (status != Status.STATUS_ACTIVE)
+ {
+ throw new IllegalStateException("Transaction not active");
+ }
+ status = Status.STATUS_MARKED_ROLLBACK;
+ }
+
+ /**
+ * @see javax.transaction.UserTransaction#setTransactionTimeout
+ */
+ public void setTransactionTimeout(int seconds) throws SystemException {}
+
+
+ /**
+ * Internal {@link Xid} implementation.
+ */
+ class XidImpl implements Xid
+ {
+
+ /** Global transaction id */
+ private final byte[] globalTxId;
+
+ /**
+ * Create a new instance of this class. Takes a global
+ * transaction number as parameter
+ * @param globalTxNumber global transaction number
+ */
+ public XidImpl(byte globalTxNumber)
+ {
+ this.globalTxId = new byte[] { globalTxNumber };
+ }
+
+ /**
+ * @see javax.transaction.xa.Xid#getFormatId()
+ */
+ public int getFormatId()
+ {
+ return 0;
+ }
+
+ /**
+ * @see javax.transaction.xa.Xid#getBranchQualifier()
+ */
+ public byte[] getBranchQualifier()
+ {
+ return new byte[0];
+ }
+
+ /**
+ * @see javax.transaction.xa.Xid#getGlobalTransactionId()
+ */
+ public byte[] getGlobalTransactionId()
+ {
+ return globalTxId;
+ }
+ }
+}
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/util/HibernateUtil.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/util/HibernateUtil.java 2009-01-14 20:53:21 UTC (rev 12510)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/util/HibernateUtil.java 2009-01-15 06:38:09 UTC (rev 12511)
@@ -48,20 +48,6 @@
}
}
- /** @return */
- /*public static Session getCurrentSession(SessionFactory sessionFactory)
- {
- Session session = sessionFactory.getCurrentSession();
- return session;
- }*/
-
- /** @return */
- /*public static Session getOpenSession(SessionFactory sessionFactory)
- {
- Session session = sessionFactory.openSession();
- return session;
- }*/
-
/** @param session */
public static void closeSession(Session session)
{
17 years, 3 months
JBoss Portal SVN: r12510 - docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2009-01-14 15:53:21 -0500 (Wed, 14 Jan 2009)
New Revision: 12510
Modified:
docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/migration.xml
Log:
Doesn't validate as-is, thank you Gregor !
Modified: docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/migration.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/migration.xml 2009-01-14 20:41:00 UTC (rev 12509)
+++ docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/migration.xml 2009-01-14 20:53:21 UTC (rev 12510)
@@ -33,6 +33,12 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
version="2.0">
+ <portlet>
+ <description>My foo portlet</description>
+ <portlet-name>MyFooPortlet</portlet-name>
+ ...
+ </portlet>
+
<filter>
<filter-name>JBoss Portlet Filter</filter-name>
<filter-class>org.jboss.portlet.filter.JBossPortletFilter</filter-class>
@@ -45,13 +51,7 @@
<portlet-name>MyFooPortlet</portlet-name>
</filter-mapping>
-
- <portlet>
- <description>My foo portlet</description>
- <portlet-name>MyFooPortlet</portlet-name>
- ...
- </portlet>
-</portlet-app>
+ </portlet-app>
]]></programlisting>
<para>By not adding this filter on a portlet using JBossActionRequest/JBossActionResponse, an error message such as:
17 years, 3 months