Merge V1.4 to HEAD

- Ignored Enterprise-specific changes
   svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3701 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3703 .
   svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3704 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3705 .
   svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3707 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3876 .
   svn revert root\projects\web-client\source\web\jsp\admin\admin-console.jsp


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3879 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-09-21 23:35:51 +00:00
parent 89f39cd176
commit d2bce74f0b
103 changed files with 3569 additions and 1172 deletions

View File

@@ -22,10 +22,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
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.error.AlfrescoRuntimeException;
@@ -35,6 +33,7 @@ import org.alfresco.repo.domain.Node;
import org.alfresco.repo.domain.NodeAssoc;
import org.alfresco.repo.domain.NodeKey;
import org.alfresco.repo.domain.NodeStatus;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.domain.Server;
import org.alfresco.repo.domain.Store;
import org.alfresco.repo.domain.StoreKey;
@@ -48,19 +47,25 @@ import org.alfresco.repo.domain.hibernate.StoreImpl;
import org.alfresco.repo.domain.hibernate.TransactionImpl;
import org.alfresco.repo.node.db.NodeDaoService;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.TransactionAwareSingleton;
import org.alfresco.repo.transaction.TransactionalDao;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
import org.alfresco.service.cmr.repository.AssociationExistsException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.repository.datatype.TypeConverter;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.ObjectDeletedException;
import org.hibernate.Query;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataIntegrityViolationException;
@@ -83,7 +88,7 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
private static final String QUERY_GET_NODE_ASSOCS_TO_AND_FROM = "node.GetNodeAssocsToAndFrom";
private static final String QUERY_GET_TARGET_ASSOCS = "node.GetTargetAssocs";
private static final String QUERY_GET_SOURCE_ASSOCS = "node.GetSourceAssocs";
private static final String QUERY_GET_CONTENT_DATA_STRINGS = "node.GetContentDataStrings";
private static final String QUERY_GET_NODES_WITH_PROPERTY_VALUES_BY_ACTUAL_TYPE = "node.GetNodesWithPropertyValuesByActualType";
private static final String QUERY_GET_SERVER_BY_IPADDRESS = "server.getServerByIpAddress";
private static Log logger = LogFactory.getLog(HibernateNodeDaoServiceImpl.class);
@@ -91,9 +96,7 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
/** a uuid identifying this unique instance */
private final String uuid;
private final ReadLock serverReadLock;
private final WriteLock serverWriteLock;
private Server server;
private static TransactionAwareSingleton<Long> serverIdSingleton = new TransactionAwareSingleton<Long>();
/**
*
@@ -101,10 +104,6 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
public HibernateNodeDaoServiceImpl()
{
this.uuid = GUID.generate();
ReentrantReadWriteLock serverReadWriteLock = new ReentrantReadWriteLock();
serverReadLock = serverReadWriteLock.readLock();
serverWriteLock = serverReadWriteLock.writeLock();
}
/**
@@ -137,21 +136,16 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
*/
private Server getServer()
{
// get readlock
serverReadLock.lock();
try
Long serverId = serverIdSingleton.get();
Server server = null;
if (serverId != null)
{
server = (Server) getSession().get(ServerImpl.class, serverId);
if (server != null)
{
return server;
}
}
finally
{
serverReadLock.unlock();
}
// get the write lock
serverWriteLock.lock();
try
{
final String ipAddress = InetAddress.getLocalHost().getHostAddress();
@@ -185,16 +179,15 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
}
}
}
// push the value into the singleton
serverIdSingleton.put(server.getId());
return server;
}
catch (Exception e)
{
throw new AlfrescoRuntimeException("Failed to create server instance", e);
}
finally
{
serverWriteLock.unlock();
}
}
private static final String RESOURCE_KEY_TRANSACTION_ID = "hibernate.transaction.id";
@@ -307,7 +300,7 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
/**
* Fetch the node status, if it exists
*/
public NodeStatus getNodeStatus(NodeRef nodeRef, boolean create)
public NodeStatus getNodeStatus(NodeRef nodeRef, boolean update)
{
NodeKey nodeKey = new NodeKey(nodeRef);
NodeStatus status = null;
@@ -325,13 +318,18 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
throw e;
}
// create if necessary
if (status == null && create)
if (status == null && update)
{
status = new NodeStatusImpl();
status.setKey(nodeKey);
status.setTransaction(getCurrentTransaction());
getHibernateTemplate().save(status);
}
else if (status != null && update)
{
// update the transaction
status.setTransaction(getCurrentTransaction());
}
// done
return status;
}
@@ -934,18 +932,62 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
getSession().flush();
}
@SuppressWarnings("unchecked")
public List<String> getContentDataStrings()
public List<Serializable> getPropertyValuesByActualType(DataTypeDefinition actualDataTypeDefinition)
{
// get the in-database string representation of the actual type
QName typeQName = actualDataTypeDefinition.getName();
final String actualTypeString = PropertyValue.getActualTypeString(typeQName);
HibernateCallback callback = new HibernateCallback()
{
public Object doInHibernate(Session session)
{
Query query = session.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_CONTENT_DATA_STRINGS);
return query.list();
Query query = session
.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_NODES_WITH_PROPERTY_VALUES_BY_ACTUAL_TYPE)
.setString("actualTypeString", actualTypeString);
return query.scroll(ScrollMode.FORWARD_ONLY);
}
};
List<String> queryResults = (List) getHibernateTemplate().execute(callback);
return queryResults;
ScrollableResults results = (ScrollableResults) getHibernateTemplate().execute(callback);
// Loop through, extracting content URLs
List<Serializable> convertedValues = new ArrayList<Serializable>(1000);
TypeConverter converter = DefaultTypeConverter.INSTANCE;
while(results.next())
{
Node node = (Node) results.get()[0];
// loop through all the node properties
Map<QName, PropertyValue> properties = node.getProperties();
for (PropertyValue propertyValue : properties.values())
{
// ignore nulls
if (propertyValue == null)
{
continue;
}
// Get the actual value(s) as a collection
Collection<Serializable> values = propertyValue.getCollection(DataTypeDefinition.ANY);
// attempt to convert instance in the collection
for (Serializable value : values)
{
// ignore nulls (null entries in collections)
if (value == null)
{
continue;
}
try
{
Serializable convertedValue = (Serializable) converter.convert(actualDataTypeDefinition, value);
// it converted, so add it
convertedValues.add(convertedValue);
}
catch (Throwable e)
{
// The value can't be converted - forget it
}
}
}
// evict all data from the session
getSession().clear();
}
return convertedValues;
}
}