-{
- /**
- * Performs the necessary work on the provided nodes to ensure that a bidirectional
- * association is properly set up.
- *
- * The association attributes still have to be set up.
- *
- * @param parentNode
- * @param childNode
- *
- * @see #setName(String)
- * @see #setIsPrimary(boolean)
- */
- public void buildAssociation(Node parentNode, Node childNode);
-
- /**
- * Performs the necessary work on the {@link #getParent() parent} and
- * {@link #getChild() child} nodes to maintain the inverse association sets
- */
- public void removeAssociation();
-
- /**
- * A convenience method to get a reference to this association.
- *
- * @param qnameDAO the DAO to resolve the qname references
- * @return Returns a reference to this association
- */
- public ChildAssociationRef getChildAssocRef(QNameDAO qnameDAO);
-
- /**
- * Convenience method to get the association's type
- *
- * @param qnameDAO the helper DAO
- * @return the association's type QName
- */
- public QName getTypeQName(QNameDAO qnameDAO);
-
- /**
- * Convenience method to set the association's type
- *
- * @param qnameDAO the helper DAO
- * @param typeQName the association's type QName
- */
- public void setTypeQName(QNameDAO qnameDAO, QName typeQName);
-
- /**
- * A convenience method to aggregate the qualified name's namespace and localname
- * into a single qualified name.
- *
- * @return Returns the qualified name of the association
- */
- public QName getQName(QNameDAO qnameDAO);
-
- /**
- * Convenience method to set the association's qname
- *
- * @param qnameDAO the helper DAO
- * @param qname the association's QName
- */
- public void setQName(QNameDAO qnameDAO, QName qname);
-
- public Long getId();
-
- /**
- * @return Return the current version number
- */
- public Long getVersion();
-
- public Node getParent();
-
- public Node getChild();
-
- /**
- * @return Returns the type of the association
- */
- public Long getTypeQNameId();
-
- /**
- * @param typeQNameId the association's dictionary type
- */
- public void setTypeQNameId(Long typeQNameId);
-
- /**
- * @return Returns the child node name. This may be truncated, in which case it
- * will end with ...
- */
- public String getChildNodeName();
-
- /**
- * @param childNodeName the name of the child node, which may be truncated and
- * terminated with ... in order to not exceed 50 characters.
- */
- public void setChildNodeName(String childNodeName);
-
- /**
- * @return Returns the crc value for the child node name.
- */
- public long getChildNodeNameCrc();
-
- /**
- * @param crc the crc value
- */
- public void setChildNodeNameCrc(long crc);
-
- /**
- * @return Returns the namespace of the association's local QName
- */
- public Long getQnameNamespaceId();
-
- /**
- * @param namespaceId the namespace of the association's local QName
- */
- public void setQnameNamespaceId(Long namespaceId);
-
- /**
- * @return Returns the localname of the association's local QName
- */
- public String getQnameLocalName();
-
- /**
- * @param localName the localname of the association's local QName
- */
- public void setQnameLocalName(String localName);
-
- /**
- * @return Returns the crc value for the association's local QName
- */
- public long getQnameCrc();
-
- /**
- * @param crc the crc value
- */
- public void setQnameCrc(long crc);
-
- public boolean getIsPrimary();
-
- public void setIsPrimary(boolean isPrimary);
-
- /**
- * @return Returns the user-assigned index
- */
- public int getIndex();
-
- /**
- * Set the index of this association
- *
- * @param index the association index
- */
- public void setIndex(int index);
-}
diff --git a/source/java/org/alfresco/repo/domain/Node.java b/source/java/org/alfresco/repo/domain/Node.java
deleted file mode 100644
index 6367f9e70f..0000000000
--- a/source/java/org/alfresco/repo/domain/Node.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco 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 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco 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 Alfresco. If not, see .
- */
-package org.alfresco.repo.domain;
-
-import java.util.Map;
-
-import org.alfresco.repo.domain.node.NodePropertyKey;
-import org.alfresco.repo.domain.node.NodePropertyValue;
-import org.alfresco.repo.domain.node.Transaction;
-import org.alfresco.repo.domain.qname.QNameDAO;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.namespace.QName;
-
-/**
- * Interface for persistent node objects.
- *
- * Specific instances of nodes are unique, but may share GUIDs across stores.
- *
- * @author Derek Hulley
- */
-public interface Node
-{
- /**
- * Convenience method to get the reference to the node
- *
- * @return Returns the reference to this node
- */
- public NodeRef getNodeRef();
-
- /**
- * Convenience method to get the node's type
- *
- * @param qnameDAO the helper DAO
- * @return the node's type QName
- */
- public QName getTypeQName(QNameDAO qnameDAO);
-
- /**
- * Convenience method to set the node's type
- *
- * @param qnameDAO the helper DAO
- * @param qname the node's type QName
- */
- public void setTypeQName(QNameDAO qnameDAO, QName qname);
-
- /**
- * @return Returns the auto-generated ID
- */
- public Long getId();
-
- /**
- * @return Returns the current version number
- */
- public Long getVersion();
-
- public Store getStore();
-
- public void setStore(Store store);
-
- public String getUuid();
-
- public void setUuid(String uuid);
-
- public Transaction getTransaction();
-
- public void setTransaction(Transaction transaction);
-
- public boolean getDeleted();
-
- public void setDeleted(boolean deleted);
-
- public Long getTypeQNameId();
-
- public void setTypeQNameId(Long typeQNameId);
-
- public Long getAclId();
-
- public void setAclId(Long aclId);
-
- public Map getProperties();
-
- public AuditableProperties getAuditableProperties();
-
- public void setAuditableProperties(AuditableProperties auditableProperties);
-}
diff --git a/source/java/org/alfresco/repo/domain/NodeAssoc.java b/source/java/org/alfresco/repo/domain/NodeAssoc.java
deleted file mode 100644
index 9aeace7492..0000000000
--- a/source/java/org/alfresco/repo/domain/NodeAssoc.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco 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 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco 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 Alfresco. If not, see .
- */
-package org.alfresco.repo.domain;
-
-import org.alfresco.repo.domain.qname.QNameDAO;
-import org.alfresco.service.cmr.repository.AssociationRef;
-import org.alfresco.service.namespace.QName;
-
-/**
- * Represents a generic association between two nodes. The association is named
- * and bidirectional by default.
- *
- * @author Derek Hulley
- */
-public interface NodeAssoc
-{
- /**
- * Wires up the necessary bits on the source and target nodes so that the association
- * is immediately bidirectional.
- *
- * The association attributes still have to be set.
- *
- * @param sourceNode
- * @param targetNode
- *
- * @see #setName(String)
- */
- public void buildAssociation(Node sourceNode, Node targetNode);
-
- /**
- * Convenience method to retrieve the association's reference
- *
- * @param qnameDAO helper DAO
- * @return the association's reference
- */
- public AssociationRef getNodeAssocRef(QNameDAO qnameDAO);
-
- /**
- * Convenience method to retrieve the association's type QName
- *
- * @param qnameDAO helper DAO
- * @return the association's type QName
- */
- public QName getTypeQName(QNameDAO qnameDAO);
-
- /**
- * Convenience method to set the association's type
- *
- * @param qnameDAO the helper DAO
- * @param typeQName the association's type QName
- */
- public void setTypeQName(QNameDAO qnameDAO, QName typeQName);
-
- public Long getId();
-
- /**
- * @return Returns the current version number
- */
- public Long getVersion();
-
- public Node getSource();
-
- public Node getTarget();
-
- /**
- * @return Returns the type of the association
- */
- public Long getTypeQNameId();
-
- /**
- * @param typeQNameId the association's dictionary type
- */
- public void setTypeQNameId(Long typeQNameId);
-}
diff --git a/source/java/org/alfresco/repo/domain/Server.java b/source/java/org/alfresco/repo/domain/Server.java
deleted file mode 100644
index bc6d6073b4..0000000000
--- a/source/java/org/alfresco/repo/domain/Server.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco 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 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco 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 Alfresco. If not, see .
- */
-package org.alfresco.repo.domain;
-
-/**
- * Interface for persistent server objects. These persist
- * details of the servers that have committed transactions to the
- * database, for instance.
- *
- * @author Derek Hulley
- */
-public interface Server
-{
- public Long getId();
-
- public Long getVersion();
-
- public String getIpAddress();
-
- public void setIpAddress(String ipAddress);
-}
diff --git a/source/java/org/alfresco/repo/domain/Store.java b/source/java/org/alfresco/repo/domain/Store.java
deleted file mode 100644
index 7a7005a14f..0000000000
--- a/source/java/org/alfresco/repo/domain/Store.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco 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 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco 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 Alfresco. If not, see .
- */
-package org.alfresco.repo.domain;
-
-import org.alfresco.service.cmr.repository.StoreRef;
-
-/**
- * Represents a store entity
- *
- * @author Derek Hulley
- */
-public interface Store
-{
- /**
- * @return Returns the current version number used for optimistic locking
- */
- public Long getVersion();
-
- /**
- * @return Returns the unique ID of the object
- */
- public Long getId();
-
- /**
- * @return the store protocol
- */
- public String getProtocol();
-
- /**
- * @param protocol the store protocol
- */
- public void setProtocol(String protocol);
-
- /**
- * @return the store identifier
- */
- public String getIdentifier();
-
- /**
- * @param identifier the store identifier
- */
- public void setIdentifier(String identifier);
-
- /**
- * @return Returns the root of the store
- */
- public Node getRootNode();
-
- /**
- * @param rootNode mandatory association to the root of the store
- */
- public void setRootNode(Node rootNode);
-
- /**
- * Convenience method to access the reference
- * @return Returns the reference to the store
- */
- public StoreRef getStoreRef();
-}
diff --git a/source/java/org/alfresco/repo/domain/hibernate/AppliedPatch.hbm.xml b/source/java/org/alfresco/repo/domain/hibernate/AppliedPatch.hbm.xml
deleted file mode 100644
index 427b826b3c..0000000000
--- a/source/java/org/alfresco/repo/domain/hibernate/AppliedPatch.hbm.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- select
- appliedPatch
- from
- org.alfresco.repo.domain.hibernate.AppliedPatchImpl as appliedPatch
-
-
-
- = :fromDate and
- appliedPatch.appliedOnDate <= :toDate
- order by appliedPatch.appliedOnDate
- ]]>
-
-
-
diff --git a/source/java/org/alfresco/repo/domain/hibernate/ChildAssocImpl.java b/source/java/org/alfresco/repo/domain/hibernate/ChildAssocImpl.java
deleted file mode 100644
index 2d6e06069d..0000000000
--- a/source/java/org/alfresco/repo/domain/hibernate/ChildAssocImpl.java
+++ /dev/null
@@ -1,548 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco 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 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco 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 Alfresco. If not, see .
- */
-package org.alfresco.repo.domain.hibernate;
-
-import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
-import java.util.zip.CRC32;
-
-import org.alfresco.repo.domain.ChildAssoc;
-import org.alfresco.repo.domain.Node;
-import org.alfresco.repo.domain.qname.QNameDAO;
-import org.alfresco.service.cmr.repository.ChildAssociationRef;
-import org.alfresco.service.namespace.QName;
-import org.alfresco.util.EqualsHelper;
-
-/**
- * @author Derek Hulley
- */
-public class ChildAssocImpl implements ChildAssoc, Serializable
-{
- private static final long serialVersionUID = -8993272236626580410L;
-
- private Long id;
- private Long version;
- private Node parent;
- private Node child;
- private Long typeQNameId;
- private Long qnameNamespaceId;
- private String qnameLocalName;
- private long qnameCrc;
- private String childNodeName;
- private long childNodeNameCrc;
- private boolean isPrimary;
- private int index;
-
- private transient ReadLock refReadLock;
- private transient WriteLock refWriteLock;
- private transient ChildAssociationRef childAssocRef;
- private transient QName typeQName;
- private transient QName qname;
-
- public ChildAssocImpl()
- {
- ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- refReadLock = lock.readLock();
- refWriteLock = lock.writeLock();
-
- index = -1; // The index is irrelevant
- }
-
- public void buildAssociation(Node parentNode, Node childNode)
- {
- // add the forward associations
- this.setParent(parentNode);
- this.setChild(childNode);
- }
-
- public void removeAssociation()
- {
- }
-
- /**
- * {@inheritDoc}
- *
- * This method is thread-safe and lazily creates the required references, if required.
- */
- public ChildAssociationRef getChildAssocRef(QNameDAO qnameDAO)
- {
- boolean trashReference = false;
- // first check if it is available
- refReadLock.lock();
- try
- {
- if (childAssocRef != null)
- {
- // double check that the parent and child node references match those of our reference
- if (childAssocRef.getParentRef() != parent.getNodeRef() ||
- childAssocRef.getChildRef() != child.getNodeRef())
- {
- trashReference = true;
- }
- else
- {
- // we are sure that the reference is correct
- return childAssocRef;
- }
- }
- }
- finally
- {
- refReadLock.unlock();
- }
- // get write lock
- refWriteLock.lock();
- try
- {
- // double check
- if (childAssocRef == null || trashReference)
- {
- if (typeQName == null)
- {
- typeQName = qnameDAO.getQName(this.typeQNameId).getSecond();
- }
- if (qname == null )
- {
- String qnameNamespace = qnameDAO.getNamespace(qnameNamespaceId).getSecond();
- qname = QName.createQName(qnameNamespace, qnameLocalName);
- }
- childAssocRef = new ChildAssociationRef(
- typeQName,
- parent.getNodeRef(),
- qname,
- child.getNodeRef(),
- this.isPrimary,
- index);
- }
- return childAssocRef;
- }
- finally
- {
- refWriteLock.unlock();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public QName getTypeQName(QNameDAO qnameDAO)
- {
- refReadLock.lock();
- try
- {
- if (typeQName != null)
- {
- return typeQName;
- }
- }
- finally
- {
- refReadLock.unlock();
- }
- refWriteLock.lock();
- try
- {
- typeQName = qnameDAO.getQName(typeQNameId).getSecond();
- return typeQName;
- }
- finally
- {
- refWriteLock.unlock();
- }
- }
-
- public void setTypeQName(QNameDAO qnameDAO, QName typeQName)
- {
- Long typeQNameId = qnameDAO.getOrCreateQName(typeQName).getFirst();
- refWriteLock.lock();
- try
- {
- setTypeQNameId(typeQNameId);
- }
- finally
- {
- refWriteLock.unlock();
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * This method is thread-safe and lazily creates the required references, if required.
- */
- public QName getQName(QNameDAO qnameDAO)
- {
- // first check if it is available
- refReadLock.lock();
- try
- {
- if (qname != null)
- {
- return qname;
- }
- }
- finally
- {
- refReadLock.unlock();
- }
- // get write lock
- refWriteLock.lock();
- try
- {
- // double check
- if (qname == null )
- {
- String qnameNamespace = qnameDAO.getNamespace(qnameNamespaceId).getSecond();
- qname = QName.createQName(qnameNamespace, qnameLocalName);
- }
- return qname;
- }
- finally
- {
- refWriteLock.unlock();
- }
- }
-
- public void setQName(QNameDAO qnameDAO, QName qname)
- {
- String assocQNameNamespace = qname.getNamespaceURI();
- String assocQNameLocalName = qname.getLocalName();
- Long assocQNameNamespaceId = qnameDAO.getOrCreateNamespace(assocQNameNamespace).getFirst();
- Long assocQNameCrc = getCrc(qname);
- // get write lock
- refWriteLock.lock();
- try
- {
- setQnameNamespaceId(assocQNameNamespaceId);
- setQnameLocalName(assocQNameLocalName);
- setQnameCrc(assocQNameCrc);
- }
- finally
- {
- refWriteLock.unlock();
- }
- }
-
- public static long getCrc(QName qname)
- {
- CRC32 crc = new CRC32();
- try
- {
- crc.update(qname.getNamespaceURI().getBytes("UTF-8"));
- crc.update(qname.getLocalName().getBytes("UTF-8"));
- }
- catch (UnsupportedEncodingException e)
- {
- throw new RuntimeException("UTF-8 encoding is not supported");
- }
- return crc.getValue();
-
- }
-
- public boolean equals(Object obj)
- {
- if (obj == null)
- {
- return false;
- }
- else if (obj == this)
- {
- return true;
- }
- else if (!(obj instanceof ChildAssoc))
- {
- return false;
- }
- ChildAssoc that = (ChildAssoc) obj;
- if (EqualsHelper.nullSafeEquals(id, that.getId()))
- {
- return true;
- }
- else
- {
- return (EqualsHelper.nullSafeEquals(this.getParent(), that.getParent())
- && EqualsHelper.nullSafeEquals(this.typeQNameId, that.getTypeQNameId())
- && EqualsHelper.nullSafeEquals(this.getChild(), that.getChild())
- && EqualsHelper.nullSafeEquals(this.qnameLocalName, that.getQnameLocalName())
- && EqualsHelper.nullSafeEquals(this.qnameNamespaceId, that.getQnameNamespaceId())
- );
- }
- }
-
- public int hashCode()
- {
- return (child == null ? 0 : child.hashCode());
- }
-
- public String toString()
- {
- StringBuffer sb = new StringBuffer(32);
- sb.append("ChildAssoc")
- .append("[ id=").append(id)
- .append(", parent=").append(parent.getId())
- .append(", child=").append(child.getId())
- .append(", child name=").append(childNodeName)
- .append(", child name crc=").append(childNodeNameCrc)
- .append(", assoc type=").append(typeQNameId)
- .append(", assoc qname ns=").append(qnameNamespaceId)
- .append(", assoc qname localname=").append(qnameLocalName)
- .append(", assoc qname crc=").append(qnameCrc)
- .append(", isPrimary=").append(isPrimary)
- .append("]");
- return sb.toString();
- }
-
- /**
- * Orders the child associations by ID. A smaller ID has a higher priority.
- * This may change once we introduce a changeable index against which to order.
- */
- public int compareTo(ChildAssoc another)
- {
- if (this == another)
- {
- return 0;
- }
-
- int thisIndex = this.getIndex();
- int anotherIndex = another.getIndex();
-
- Long thisId = this.getId();
- Long anotherId = another.getId();
-
- if (thisId == null) // this ID has not been set, make this instance greater
- {
- return -1;
- }
- else if (anotherId == null) // other ID has not been set, make this instance lesser
- {
- return 1;
- }
- else if (thisIndex == anotherIndex) // use the explicit index
- {
- return thisId.compareTo(anotherId);
- }
- else // fallback on order of creation
- {
- return (thisIndex > anotherIndex) ? 1 : -1; // a lower index, make this instance lesser
- }
- }
-
- public Long getId()
- {
- return id;
- }
-
- /**
- * For Hibernate use
- */
- @SuppressWarnings("unused")
- private void setId(Long id)
- {
- this.id = id;
- }
-
- public Long getVersion()
- {
- return version;
- }
-
- /**
- * For Hibernate use
- */
- @SuppressWarnings("unused")
- private void setVersion(Long version)
- {
- this.version = version;
- }
-
- public Node getParent()
- {
- return parent;
- }
-
- /**
- * For Hibernate use
- */
- private void setParent(Node parentNode)
- {
- refWriteLock.lock();
- try
- {
- this.parent = parentNode;
- this.childAssocRef = null;
- }
- finally
- {
- refWriteLock.unlock();
- }
- }
-
- public Node getChild()
- {
- return child;
- }
-
- /**
- * For Hibernate use
- */
- private void setChild(Node node)
- {
- refWriteLock.lock();
- try
- {
- child = node;
- this.childAssocRef = null;
- }
- finally
- {
- refWriteLock.unlock();
- }
- }
-
- public Long getTypeQNameId()
- {
- return typeQNameId;
- }
-
- public void setTypeQNameId(Long typeQNameId)
- {
- refWriteLock.lock();
- try
- {
- this.typeQNameId = typeQNameId;
- this.childAssocRef = null;
- this.typeQName = null;
- }
- finally
- {
- refWriteLock.unlock();
- }
- }
-
- public Long getQnameNamespaceId()
- {
- return qnameNamespaceId;
- }
-
- public void setQnameNamespaceId(Long qnameNamespaceId)
- {
- refWriteLock.lock();
- try
- {
- this.qnameNamespaceId = qnameNamespaceId;
- this.childAssocRef = null;
- this.qname = null;
- }
- finally
- {
- refWriteLock.unlock();
- }
- }
-
- public String getQnameLocalName()
- {
- return qnameLocalName;
- }
-
- public void setQnameLocalName(String qnameLocalName)
- {
- refWriteLock.lock();
- try
- {
- this.qnameLocalName = qnameLocalName;
- this.childAssocRef = null;
- this.qname = null;
- }
- finally
- {
- refWriteLock.unlock();
- }
- }
-
- public long getQnameCrc()
- {
- return qnameCrc;
- }
-
- public void setQnameCrc(long crc)
- {
- this.qnameCrc = crc;
- }
-
- public String getChildNodeName()
- {
- return childNodeName;
- }
-
- public void setChildNodeName(String childNodeName)
- {
- this.childNodeName = childNodeName;
- }
-
- public long getChildNodeNameCrc()
- {
- return childNodeNameCrc;
- }
-
- public void setChildNodeNameCrc(long crc)
- {
- this.childNodeNameCrc = crc;
- }
-
- public boolean getIsPrimary()
- {
- return isPrimary;
- }
-
- public void setIsPrimary(boolean isPrimary)
- {
- refWriteLock.lock();
- try
- {
- this.isPrimary = isPrimary;
- this.childAssocRef = null;
- }
- finally
- {
- refWriteLock.unlock();
- }
- }
-
- public int getIndex()
- {
- return index;
- }
-
- public void setIndex(int index)
- {
- refWriteLock.lock();
- try
- {
- this.index = index;
- this.childAssocRef = null;
- }
- finally
- {
- refWriteLock.unlock();
- }
- }
-}
diff --git a/source/java/org/alfresco/repo/domain/hibernate/DirtySessionAnnotation.java b/source/java/org/alfresco/repo/domain/hibernate/DirtySessionAnnotation.java
deleted file mode 100644
index f9fd7d9534..0000000000
--- a/source/java/org/alfresco/repo/domain/hibernate/DirtySessionAnnotation.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco 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 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco 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 Alfresco. If not, see .
- */
-package org.alfresco.repo.domain.hibernate;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation defining Hibernate session flushing and dirty marking
- *
- * @since 2.1.5
- * @author Derek Hulley
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface DirtySessionAnnotation
-{
- /**
- * The session must be flagged as dirty after execution.
- * Default: false
- */
- boolean markDirty() default false;
-}
diff --git a/source/java/org/alfresco/repo/domain/hibernate/DirtySessionMethodInterceptor.java b/source/java/org/alfresco/repo/domain/hibernate/DirtySessionMethodInterceptor.java
deleted file mode 100644
index d72b003936..0000000000
--- a/source/java/org/alfresco/repo/domain/hibernate/DirtySessionMethodInterceptor.java
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco 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 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco 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 Alfresco. If not, see .
- */
-package org.alfresco.repo.domain.hibernate;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.Stack;
-
-import org.alfresco.error.StackTraceUtil;
-import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
-import org.alfresco.util.Pair;
-import org.aopalliance.intercept.MethodInterceptor;
-import org.aopalliance.intercept.MethodInvocation;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.Criteria;
-import org.hibernate.FlushMode;
-import org.hibernate.Query;
-import org.hibernate.Session;
-
-/**
- * This method interceptor determines if a Hibernate flush is required and performs the
- * flush if necessary. The primary purpose is to avoid the Hibernate "flush if required" checks
- * that occur every time a query is made to the database - whether or not any actual modifications
- * have been made to the session.
- *
- * Write methods (methods that modify the Hibernate Session) will flag the transaction as dirty.
- * Methods that query the database can {@link #setQueryFlushMode(Session, Query) set the flush mode}
- * without knowing whether the session is dirty or not.
- *
- * The interceptor uses the {@link DirtySessionAnnotation}. If the annotation is not used, then
- * no session dirty checks will be done but a WARN message will be output.
- *
- * The flush data is kept as a transaction-local resource. For this reason, all calls must be made
- * in the context of a transaction. For the same reason, the methods on the FlushData are
- * not synchronized as access is only available by one thread.
- *
- * It is also possible to {@link #flushSession(Session) flush the session} manually. Using this method
- * allows the dirty count to be updated properly, thus avoiding unecessary flushing.
- *
- * To trace failures caused by data flushes, it is necessary to track methods called and values passed
- * that lead to the session being marked as dirty. If the flush fails or if a method call fails then
- * the stacks and method values will be dumped. Turn on trace debugging for this:
- *
- * log4j.logger.org.alfresco.repo.domain.hibernate.DirtySessionMethodInterceptor.trace=DEBUG
- *
- *
- * @see #setQueryFlushMode(Session, Query)
- * @see #flushSession(Session)
- *
- * @author Derek Hulley
- * @since 2.1.5
- */
-public class DirtySessionMethodInterceptor implements MethodInterceptor
-{
- private static final String KEY_FLUSH_DATA = "FlushIfRequiredMethodInterceptor.FlushData";
-
- private static Log logger = LogFactory.getLog(DirtySessionMethodInterceptor.class);
- private static final boolean loggerDebugEnabled;
- private static Log traceLogger = LogFactory.getLog(DirtySessionMethodInterceptor.class.getName() + ".trace");
- private static final boolean traceLoggerDebugEnabled;
- static
- {
- loggerDebugEnabled = logger.isDebugEnabled();
- traceLoggerDebugEnabled = traceLogger.isDebugEnabled();
- if (traceLoggerDebugEnabled)
- {
- traceLogger.warn("Trace logging is enabled and will affect performance");
- }
- }
-
- /**
- * Keep track of methods that have been warned about, i.e. methods that are not annotated.
- */
- private static Set unannotatedMethodNames;
- static
- {
- unannotatedMethodNames = Collections.synchronizedSet(new HashSet(0));
- }
-
- /**
- * Data on whether the session is dirty or not.
- *
- * @author Derek Hulley
- */
- private static class FlushData
- {
- private int dirtyCount;
- private Stack> methodStack;
- private List traceStacks;
- private FlushData()
- {
- dirtyCount = 0;
- methodStack = new Stack>();
- }
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder(64);
- sb.append("FlushData")
- .append("[dirtyCount=").append(dirtyCount)
- .append(", methodStack=").append(methodStack)
- .append("]");
- return sb.toString();
- }
- public void incrementDirtyCount()
- {
- dirtyCount++;
- }
- public boolean isDirty()
- {
- return dirtyCount > 0;
- }
- public void resetDirtyCount()
- {
- dirtyCount = 0;
- traceStacks = null;
- }
- public void pushMethod(String methodName, boolean isAnnotated)
- {
- methodStack.push(new Pair(methodName, Boolean.valueOf(isAnnotated)));
- }
- public Pair popMethod()
- {
- return methodStack.pop();
- }
- public Pair currentMethod()
- {
- return methodStack.peek();
- }
- /**
- * @return Returns true if all the methods in the method stack are annotated,
- * otherwise false
- */
- public boolean isStackAnnotated()
- {
- for (Pair stackElement : methodStack)
- {
- if (stackElement.getSecond().equals(Boolean.FALSE))
- {
- // Found one that was not annotated
- return false;
- }
- }
- // All were annotated
- return true;
- }
- public void addTraceStack(MethodInvocation method)
- {
- Exception e = new Exception();
- e.fillInStackTrace();
- StringBuilder sb = new StringBuilder(2048);
- sb.append(" Method: ").append(method.getMethod().getName());
- Object[] arguments = method.getArguments();
- for (int i = 0; i < arguments.length; i++)
- {
- String argumentStr;
- try
- {
- argumentStr = arguments[i] == null ? "NULL" : arguments[i].toString();
- }
- catch (Throwable ee)
- {
- argumentStr = "(10);
- }
- traceStacks.add(sb.toString());
- }
- public List getTraceStacks()
- {
- return (traceStacks == null) ? Collections.emptyList() : traceStacks;
- }
- }
-
- /**
- * @return Returns the transaction-local flush data
- */
- private static FlushData getFlushData()
- {
- FlushData flushData = (FlushData) AlfrescoTransactionSupport.getResource(KEY_FLUSH_DATA);
- if (flushData == null)
- {
- flushData = new FlushData();
- AlfrescoTransactionSupport.bindResource(KEY_FLUSH_DATA, flushData);
- }
- return flushData;
- }
-
- /**
- * Set the query flush mode according to whether the session is dirty or not.
- *
- * @param session the Hibernate session
- * @param query the Hibernate query that will be issued
- */
- public static void setQueryFlushMode(Session session, Query query)
- {
- FlushData flushData = DirtySessionMethodInterceptor.getFlushData();
-
- // If all the methods in the method stack are annotated, then we can adjust the query and
- // play with the session
- if (!flushData.isStackAnnotated())
- {
- if (loggerDebugEnabled)
- {
- logger.debug(
- "Method stack is not annotated. Not setting query flush mode: \n" +
- " Flush Data: " + flushData);
- }
- return;
- }
-
- // The stack is fully annotated, so flush if required and set the flush mode on the query
- if (loggerDebugEnabled)
- {
- logger.debug(
- "Setting query flush mode: \n" +
- " Query: " + query.getQueryString() + "\n" +
- " Dirty: " + flushData);
- }
-
- if (flushData.isDirty())
- {
- // Flush the session
- session.flush();
- // Reset the dirty state
- flushData.resetDirtyCount();
- }
- // Adjust the query flush mode
- query.setFlushMode(FlushMode.MANUAL);
- }
-
- public static void setCriteriaFlushMode(Session session, Criteria criteria)
- {
- FlushData flushData = DirtySessionMethodInterceptor.getFlushData();
-
- // If all the methods in the method stack are annotated, then we can adjust the query and
- // play with the session
- if (!flushData.isStackAnnotated())
- {
- if (loggerDebugEnabled)
- {
- logger.debug(
- "Method stack is not annotated. Not setting query flush mode: \n" +
- " Flush Data: " + flushData);
- }
- return;
- }
-
- // The stack is fully annotated, so flush if required and set the flush mode on the query
- if (loggerDebugEnabled)
- {
- logger.debug(
- "Setting query flush mode: \n" +
- " Criteria: " + criteria.toString() + "\n" +
- " Dirty: " + flushData);
- }
-
- if (flushData.isDirty())
- {
- // Flush the session
- session.flush();
- // Reset the dirty state
- flushData.resetDirtyCount();
- }
- // Adjust the query flush mode
- criteria.setFlushMode(FlushMode.MANUAL);
- }
-
- /**
- * Manually mark the session as dirty.
- */
- public static void setSessionDirty()
- {
- FlushData flushData = DirtySessionMethodInterceptor.getFlushData();
- flushData.incrementDirtyCount();
- }
-
- /**
- * Flush and reset the dirty count for the current transaction. The session is
- * only flushed if it currently dirty.
- *
- * @param session the Hibernate session
- */
- public static void flushSession(Session session)
- {
- flushSession(session, false);
- }
-
- /**
- * Flush and reset the dirty count for the current transaction.
- * Use this one if you know that the session has changeds that might not
- * have been recorded by the DAO interceptors.
- *
- * @param session the Hibernate session
- * @param force true to force a flush.
- */
- public static void flushSession(Session session, boolean force)
- {
- FlushData flushData = DirtySessionMethodInterceptor.getFlushData();
- if (force)
- {
- if (loggerDebugEnabled)
- {
- logger.debug(
- "Flushing session forcefully: \n" +
- " Dirty: " + flushData);
- }
- session.flush();
- flushData.resetDirtyCount();
- }
- else
- {
- if (flushData.isDirty())
- {
- if (loggerDebugEnabled)
- {
- logger.debug(
- "Flushing dirty session: \n" +
- " Dirty: " + flushData);
- }
- session.flush();
- flushData.resetDirtyCount();
- }
- else
- {
- if (loggerDebugEnabled)
- {
- logger.debug(
- "Session is not dirty - no flush: \n" +
- " Dirty: " + flushData);
- }
- }
- }
- }
-
- /** Default constructor */
- public DirtySessionMethodInterceptor()
- {
- }
-
- public Object invoke(MethodInvocation invocation) throws Throwable
- {
- Method method = invocation.getMethod();
- String methodName = method.getName();
-
- // Get the flush and dirty mark requirements for the call
- DirtySessionAnnotation annotation = method.getAnnotation(DirtySessionAnnotation.class);
- boolean markDirty = false;
- if (annotation != null)
- {
- markDirty = annotation.markDirty();
- }
- else if (unannotatedMethodNames.add(methodName))
- {
- logger.warn("Method has not been annotated with the DirtySessionAnnotation: " + method);
- }
-
- FlushData flushData = DirtySessionMethodInterceptor.getFlushData();
-
- // If we are to mark it dirty and we are tracing, then record the stacks
- if (markDirty && traceLoggerDebugEnabled)
- {
- flushData.addTraceStack(invocation);
- }
-
- boolean isAnnotated = (annotation != null);
- Object ret = null;
- try
- {
- // Push the method onto the stack
- flushData.pushMethod(methodName, isAnnotated);
-
- if (loggerDebugEnabled)
- {
- logger.debug(
- "Flush state and parameters for DirtySessionInterceptor: \n" +
- " Method: " + methodName + "\n" +
- " Annotated: MARK-DIRTY=" + markDirty + "\n" +
- " Session State: " + flushData);
- }
-
- // Do the call
- try
- {
- ret = invocation.proceed();
- }
- catch (Throwable e)
- {
- // If we are tracing, then dump the current dirty stack
- if (traceLoggerDebugEnabled)
- {
- traceLogger.debug("Dumping stack traces after exception: " + e.getMessage());
- for (String stackTrace : flushData.getTraceStacks())
- {
- traceLogger.debug("\n" + stackTrace);
- }
- }
- // Rethrow
- throw e;
- }
-
- if (markDirty)
- {
- flushData.incrementDirtyCount();
- }
- }
- finally
- {
- // Restore the dirty session awareness state
- flushData.popMethod();
- }
-
- // Done
- return ret;
- }
-}
diff --git a/source/java/org/alfresco/repo/domain/hibernate/HibernateSessionHelper.java b/source/java/org/alfresco/repo/domain/hibernate/HibernateSessionHelper.java
deleted file mode 100644
index d4bedef17a..0000000000
--- a/source/java/org/alfresco/repo/domain/hibernate/HibernateSessionHelper.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco 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 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco 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 Alfresco. If not, see .
- */
-package org.alfresco.repo.domain.hibernate;
-
-import java.util.List;
-
-import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-
-/**
- * Utililty support against hibernate sessions. Supported by a super event listener which is registered on the even
- * listener of the hibernate session.
- *
- * @author andyh
- */
-public class HibernateSessionHelper extends HibernateDaoSupport implements HibernateSessionSupport
-{
- /**
- *
- */
- private static final long serialVersionUID = -2532286150392812816L;
- private static final String HIBERNATE_SESSION_EVENT_LISTENER = "HibernateSessionEventListener";
-
- public void mark()
- {
- HibernateSessionHelperResourceProvider resource = getResource();
- resource.mark(getSession());
- }
-
- public void mark(String label)
- {
- HibernateSessionHelperResourceProvider resource = getResource();
- resource.mark(getSession(), label);
- }
-
- public void reset()
- {
- HibernateSessionHelperResourceProvider resource = getResource();
- resource.reset(getSession());
- }
-
- public void reset(String label)
- {
- HibernateSessionHelperResourceProvider resource = getResource();
- resource.reset(getSession(), label);
- }
-
- public void removeMark()
- {
- HibernateSessionHelperResourceProvider resource = getResource();
- resource.removeMark(getSession());
- }
-
- public void removeMark(String label)
- {
- HibernateSessionHelperResourceProvider resource = getResource();
- resource.removeMark(getSession(), label);
- }
-
- public void resetAndRemoveMark()
- {
- HibernateSessionHelperResourceProvider resource = getResource();
- resource.resetAndRemoveMark(getSession());
- }
-
- public void resetAndRemoveMark(String label)
- {
- HibernateSessionHelperResourceProvider resource = getResource();
- resource.resetAndRemoveMark(getSession(), label);
- }
-
- public List getMarks()
- {
- HibernateSessionHelperResourceProvider resource = getResource();
- return resource.getMarks(getSession());
- }
-
- public String getCurrentMark()
- {
- HibernateSessionHelperResourceProvider resource = getResource();
- return resource.getCurrentMark();
- }
-
- public static HibernateSessionHelperResourceProvider getResource()
- {
- HibernateSessionHelperResourceProvider listener = (HibernateSessionHelperResourceProvider) AlfrescoTransactionSupport.getResource(HIBERNATE_SESSION_EVENT_LISTENER);
- if (listener == null)
- {
- listener = new HibernateSessionHelperResource();
- AlfrescoTransactionSupport.bindResource(HIBERNATE_SESSION_EVENT_LISTENER, listener);
- }
- return listener;
- }
-
-
-
-
-}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/domain/hibernate/HibernateSessionHelperResource.java b/source/java/org/alfresco/repo/domain/hibernate/HibernateSessionHelperResource.java
deleted file mode 100644
index fdbf15c8a1..0000000000
--- a/source/java/org/alfresco/repo/domain/hibernate/HibernateSessionHelperResource.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco 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 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco 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 Alfresco. If not, see .
- */
-package org.alfresco.repo.domain.hibernate;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Set;
-
-import org.alfresco.util.GUID;
-import org.hibernate.Session;
-import org.hibernate.engine.EntityKey;
-
-/**
- * Support to (optionally) listen to hibernate events generated by a hibernate session. The tracking is bound to a
- * transaction resource
- *
- * @author andyh
- */
-public class HibernateSessionHelperResource implements HibernateSessionHelperResourceProvider
-{
- LinkedHashMap> marks = new LinkedHashMap>();
-
- String currentMark = null;
-
- HibernateSessionHelperResource()
- {
-
- }
-
- public String getCurrentMark()
- {
- return currentMark;
- }
-
- public List getMarks(Session session)
- {
- ArrayList answer = new ArrayList(marks.size());
- for (String key : marks.keySet())
- {
- answer.add(key);
- }
- return answer;
- }
-
- public void mark(Session session)
- {
- String guid = GUID.generate();
- mark(session, guid);
- }
-
- @SuppressWarnings("unchecked")
- public void mark(Session session, String label)
- {
- if (label == null)
- {
- throw new HibernateSessionHelperResourceException("Null key is not supported");
-
- }
- if (marks.containsKey(label))
- {
- throw new HibernateSessionHelperResourceException("Key already exists - " + label);
- }
-
- if (marks.size() == 0)
- {
- SessionSizeResourceManager.setDisableInTransaction();
- }
-
- HashSet mark = new HashSet((Set) session.getStatistics().getEntityKeys());
-
- // If the mark is too large, then the flush process will be excessive.
- if (mark.size() > 1000)
- {
- // The session is to big. Use the mark to as a basis for cleaning out the session.
- if (currentMark == null)
- {
- // The session is just too big
- SessionSizeResourceManager.clear(session);
- }
- else
- {
- reset(session);
- }
- // Get the mark list again
- mark = new HashSet((Set) session.getStatistics().getEntityKeys());
- }
-
- marks.put(label, mark);
- currentMark = label;
- }
-
- public void removeMark(Session session)
- {
- if (currentMark != null)
- {
- removeMark(session, currentMark);
- }
- else
- {
- throw new HibernateSessionHelperResourceException("No current mark");
- }
-
- }
-
- public void removeMark(Session session, String label)
- {
- if (label == null)
- {
- throw new HibernateSessionHelperResourceException("Null key is not supported");
-
- }
- if (!marks.containsKey(label))
- {
- throw new HibernateSessionHelperResourceException("Key does not exist - " + label);
- }
-
- if (marks.size() > 0)
- {
- marks.remove(label);
-
- if (label.equals(currentMark))
- {
- currentMark = getLastMarkOrNull();
- }
- }
-
- if (marks.size() == 0)
- {
- SessionSizeResourceManager.setEnableInTransaction();
- }
- }
-
- public void reset(Session session)
- {
- if (currentMark != null)
- {
- doResetAndRemove(session, currentMark, false);
- }
- else
- {
- throw new HibernateSessionHelperResourceException("No current mark");
- }
- }
-
- public void reset(Session session, String label)
- {
- doResetAndRemove(session, label, false);
- }
-
- public void resetAndRemoveMark(Session session)
- {
- if (currentMark != null)
- {
- doResetAndRemove(session, currentMark, true);
- }
- else
- {
- throw new HibernateSessionHelperResourceException("No current mark");
- }
- }
-
- public void resetAndRemoveMark(Session session, String label)
- {
- doResetAndRemove(session, label, true);
- }
-
- @SuppressWarnings("unchecked")
- private void doResetAndRemove(Session session, String label, boolean remove)
- {
- if (label == null)
- {
- throw new HibernateSessionHelperResourceException("Null key is not supported");
-
- }
- if (!marks.containsKey(label))
- {
- throw new HibernateSessionHelperResourceException("Key does not exist - " + label);
- }
- if (marks.size() > 0)
- {
- session.flush();
-
- Set check = marks.get(label);
- Set current = new HashSet((Set) session.getStatistics().getEntityKeys());
-
- Set