MOB-629 - remove AVM issuer id

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13676 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2009-03-18 17:38:14 +00:00
parent a4e4ee8ef3
commit ef51318dbe
25 changed files with 4356 additions and 4869 deletions

View File

@@ -4,54 +4,6 @@
<beans>
<!-- ID Issuers. -->
<bean id="nodeIssuer" class="org.alfresco.repo.avm.Issuer" depends-on="avmDAOs" >
<property name="name">
<value>node</value>
</property>
<property name="issuerDAO">
<ref bean="issuerDAO"/>
</property>
<property name="issuerIDDAO">
<ref bean="issuerIDDAO"/>
</property>
<property name="transactionService">
<ref bean="transactionService"/>
</property>
</bean>
<bean id="layerIssuer" class="org.alfresco.repo.avm.Issuer" depends-on="avmDAOs" >
<property name="name">
<value>layer</value>
</property>
<property name="issuerDAO">
<ref bean="issuerDAO"/>
</property>
<property name="issuerIDDAO">
<ref bean="issuerIDDAO"/>
</property>
<property name="transactionService">
<ref bean="transactionService"/>
</property>
</bean>
<!-- DAOs for persistent data types -->
<bean id="issuerIDDAO" class="org.alfresco.repo.avm.hibernate.IssuerIDDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- Issuers are not actual entities. More like pseudo entities. -->
<bean id="issuerDAO" class="org.alfresco.repo.avm.hibernate.IssuerDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="avmNodeDAO" class="org.alfresco.repo.avm.hibernate.AVMNodeDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
@@ -113,9 +65,6 @@
</bean>
<bean id="avmDAOs" class="org.alfresco.repo.avm.AVMDAOs" factory-method="Instance">
<property name="issuerDAO">
<ref bean="issuerDAO"/>
</property>
<property name="nodeDAO">
<ref bean="avmNodeDAO"/>
</property>
@@ -186,12 +135,6 @@
<bean id="purgeVersionTxnListener" class="org.alfresco.repo.avm.PurgeVersionTxnListener"/>
<bean id="avmRepository" class="org.alfresco.repo.avm.AVMRepository">
<property name="nodeIssuer">
<ref bean="nodeIssuer"/>
</property>
<property name="layerIssuer">
<ref bean="layerIssuer"/>
</property>
<property name="lookupCache">
<ref bean="lookupCache"/>
</property>

View File

@@ -95,6 +95,7 @@
<ref bean="patch.db-V2.1-RemoveWcmSubmittedAspect" />
<ref bean="patch.db-V2.1-AuditPathIndex" />
<ref bean="patch.db-V3.0-0-CreateActivitiesExtras" />
<ref bean="patch.db-V3.2-Remove-AVM-Issuer" />
</list>
</property>
</bean>
@@ -118,12 +119,6 @@
<!-- Bootstrap the AVM -->
<bean id="avmBootstrap" class="org.alfresco.repo.avm.AvmBootstrap" >
<property name="issuers">
<list>
<ref bean="nodeIssuer" />
<ref bean="layerIssuer" />
</list>
</property>
<property name="avmLockingAwareService">
<ref bean="avmLockingAwareService"/>
</property>

View File

@@ -0,0 +1,53 @@
--
-- Title: Upgrade to V3.2 - Remove AVM Issuer
-- Database: MySQL
-- Since: V3.2 schema X
-- Author: janv
--
-- remove AVM node issuer - replace with auto-increment id
--
-- Please contact support@alfresco.com if you need assistance with the upgrade.
--
-- -----------------------------
-- Enable auto-increment --
-- -----------------------------
insert into avm_nodes
select
(select max(id)+1 from avm_nodes),
class_type, vers, version_id, guid, creator, owner, lastModifier, createDate, modDate, accessDate, is_root, store_new_id, acl_id, deletedType, layer_id, indirection, indirection_version, primary_indirection, opacity, content_url, mime_type, encoding, length
from avm_nodes where id = 0;
update avm_aspects set node_id = (select max(id) from avm_nodes) where node_id = 0;
update avm_child_entries set parent_id = (select max(id) from avm_nodes) where parent_id = 0;
update avm_child_entries set child_id = (select max(id) from avm_nodes) where child_id = 0;
update avm_history_links set ancestor = (select max(id) from avm_nodes) where ancestor = 0;
update avm_history_links set descendent = (select max(id) from avm_nodes) where descendent = 0;
update avm_merge_links set mfrom = (select max(id) from avm_nodes) where mfrom = 0;
update avm_merge_links set mto = (select max(id) from avm_nodes) where mto = 0;
update avm_node_properties set node_id = (select max(id) from avm_nodes) where node_id = 0;
update avm_stores set current_root_id = (select max(id) from avm_nodes) where current_root_id = 0;
update avm_version_roots set root_id = (select max(id) from avm_nodes) where root_id = 0;
delete from avm_nodes where id = 0;
alter table avm_nodes modify column id bigint not null auto_increment;
--
-- Record script finish
--
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.2-Remove-AVM-Issuer';
INSERT INTO alf_applied_patch
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
VALUES
(
'patch.db-V3.2-Remove-AVM-Issuer', 'Manually executed script upgrade V3.2 to remove AVM Issuer',
0, 2007, -1, 2008, null, 'UNKOWN', 1, 1, 'Script completed'
);

View File

@@ -1759,5 +1759,15 @@
</property>
</bean>
<bean id="patch.db-V3.2-Remove-AVM-Issuer" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch">
<property name="id"><value>patch.db-V3.2-Remove-AVM-Issuer</value></property>
<property name="description"><value>patch.schemaUpgradeScript.description</value></property>
<property name="fixesFromSchema"><value>0</value></property>
<property name="fixesToSchema"><value>2007</value></property>
<property name="targetSchema"><value>2008</value></property>
<property name="scriptUrl">
<value>classpath:alfresco/dbscripts/upgrade/3.2/${db.script.dialect}/remove-AVM-issuer.sql</value>
</property>
</bean>
</beans>

View File

@@ -19,4 +19,4 @@ version.build=@build-number@
# Schema number
version.schema=2007
version.schema=2008

View File

@@ -1,6 +1,26 @@
/**
/*
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
*/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" */
package org.alfresco.repo.avm;
import org.alfresco.repo.attributes.AttributeDAO;
@@ -34,11 +54,6 @@ public class AVMDAOs
return fgInstance;
}
/**
* The IssuerDAO.
*/
public IssuerDAO fIssuerDAO;
/**
* The AVMNodeDAO.
*/
@@ -142,14 +157,6 @@ public class AVMDAOs
fVersionRootDAO = versionRootDAO;
}
/**
* @param issuerDAO the fIssuerDAO to set
*/
public void setIssuerDAO(IssuerDAO issuerDAO)
{
fIssuerDAO = issuerDAO;
}
public void setAvmStorePropertyDAO(AVMStorePropertyDAO avmStorePropertyDAO)
{
fAVMStorePropertyDAO = avmStorePropertyDAO;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -106,15 +106,12 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
/**
* Constructor used when creating a new concrete subclass instance.
* @param id The object id.
* @param store The AVMStore that owns this.
*/
protected AVMNodeImpl(long id,
AVMStore store)
protected AVMNodeImpl(AVMStore store)
{
fAspects = new HashSet<Long>();
fProperties = new HashMap<Long, PropertyValue>();
fID = id;
fVersionID = -1;
fIsRoot = false;
long time = System.currentTimeMillis();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -75,7 +75,6 @@ import org.apache.commons.logging.LogFactory;
*/
public class AVMRepository
{
@SuppressWarnings("unused")
private static Log fgLogger = LogFactory.getLog(AVMRepository.class);
/**
@@ -88,16 +87,6 @@ public class AVMRepository
*/
private ThreadLocal<Integer> fLookupCount;
/**
* The node id issuer.
*/
private Issuer fNodeIssuer;
/**
* The layer id issuer.
*/
private Issuer fLayerIssuer;
/**
* Reference to the ContentStoreImpl
*/
@@ -157,28 +146,6 @@ public class AVMRepository
fgInstance = this;
}
/**
* Set the node issuer. For Spring.
*
* @param nodeIssuer
* The issuer.
*/
public void setNodeIssuer(Issuer nodeIssuer)
{
fNodeIssuer = nodeIssuer;
}
/**
* Set the layer issuer. For Spring.
*
* @param layerIssuer
* The issuer.
*/
public void setLayerIssuer(Issuer layerIssuer)
{
fLayerIssuer = layerIssuer;
}
/**
* Set the ContentService.
*/
@@ -481,7 +448,6 @@ public class AVMRepository
throw new AVMExistsException("AVMStore exists: " + name);
}
// Newing up the object causes it to be written to the db.
@SuppressWarnings("unused")
AVMStore rep = new AVMStoreImpl(this, name);
// Special handling for AVMStore creation.
rep.getRoot().setStoreNew(null);
@@ -572,7 +538,9 @@ public class AVMRepository
else if (srcNode.getType() == AVMNodeType.LAYERED_DIRECTORY)
{
dstNode = new LayeredDirectoryNodeImpl((LayeredDirectoryNode) srcNode, dstRepo, sPath, false, inheritAcl, ACLCopyMode.INHERIT);
((LayeredDirectoryNode) dstNode).setLayerID(issueLayerID());
// note: re-use generated node id as a layer id
((LayeredDirectoryNode) dstNode).setLayerID(dstNode.getId());
}
else if (srcNode.getType() == AVMNodeType.LAYERED_FILE)
{
@@ -798,7 +766,9 @@ public class AVMRepository
else
{
dstNode = new LayeredDirectoryNodeImpl((DirectoryNode) srcNode, dstRepo, sPath, srcName, parentAcl, ACLCopyMode.COPY);
((LayeredDirectoryNode) dstNode).setLayerID(issueLayerID());
// note: re-use generated node id as a layer id
((LayeredDirectoryNode) dstNode).setLayerID(dstNode.getId());
}
}
else
@@ -839,7 +809,8 @@ public class AVMRepository
}
else
{
((LayeredDirectoryNode) dstNode).setLayerID(issueLayerID());
// note: re-use generated node id as a layer id
((LayeredDirectoryNode) dstNode).setLayerID(dstNode.getId());
}
}
}
@@ -971,7 +942,6 @@ public class AVMRepository
* @param name
* The name of the AVMStore to purge.
*/
@SuppressWarnings("unchecked")
public void purgeAVMStore(String name)
{
AlfrescoTransactionSupport.bindListener(fPurgeStoreTxnListener);
@@ -1271,7 +1241,6 @@ public class AVMRepository
*
* @return A list of all descriptors.
*/
@SuppressWarnings("unchecked")
public List<AVMStoreDescriptor> getAVMStores()
{
List<AVMStore> l = fAVMStoreDAO.getAll();
@@ -1338,26 +1307,6 @@ public class AVMRepository
return store.getVersions(from, to);
}
/**
* Issue a node id.
*
* @return The new id.
*/
public long issueID()
{
return fNodeIssuer.issue();
}
/**
* Issue a new layer id.
*
* @return The new id.
*/
public long issueLayerID()
{
return fLayerIssuer.issue();
}
/**
* Get the indirection path for a layered node.
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -429,7 +429,9 @@ public class AVMStoreImpl implements AVMStore, Serializable
else
{
// Otherwise we issue a brand new layer id.
newDir.setLayerID(fAVMRepository.issueLayerID());
// note: re-use generated node id as a layer id
newDir.setLayerID(newDir.getId());
}
if (child != null)
{

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2008 Alfresco Software Limited.
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,7 +24,6 @@
*/
package org.alfresco.repo.avm;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.service.cmr.security.PermissionService;
@@ -43,8 +42,6 @@ import org.springframework.context.ApplicationEvent;
*/
public class AvmBootstrap extends AbstractLifecycleBean
{
private List<Issuer> issuers;
private AVMLockingAwareService avmLockingAwareService;
private AVMRepository avmRepository;
@@ -56,7 +53,6 @@ public class AvmBootstrap extends AbstractLifecycleBean
public AvmBootstrap()
{
issuers = new ArrayList<Issuer>(0);
}
public void setAvmLockingAwareService(AVMLockingAwareService service)
@@ -79,26 +75,12 @@ public class AvmBootstrap extends AbstractLifecycleBean
avmSyncService = service;
}
/**
* Provide a list of {@link Issuer issuers} to bootstrap on context initialization.
*
* @see #onBootstrap(ApplicationEvent)
*/
public void setIssuers(List<Issuer> issuers)
{
this.issuers = issuers;
}
/**
* Initialize the issuers.
*/
@Override
protected void onBootstrap(ApplicationEvent event)
{
for (Issuer issuer : issuers)
{
issuer.init();
}
avmLockingAwareService.init();
avmRepository.setPermissionService(permissionService);
avmSyncService.setPermissionService(permissionService);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -49,20 +49,18 @@ public class DeletedNodeImpl extends AVMNodeImpl implements DeletedNode
/**
* Create a new one from scratch.
* @param id The node id.
* @param store The store it's being created in.
*/
public DeletedNodeImpl(long id,
AVMStore store, DbAccessControlList acl)
public DeletedNodeImpl(AVMStore store, DbAccessControlList acl)
{
super(id, store);
super(store);
this.setAcl(acl);
}
public DeletedNodeImpl(DeletedNode other,
AVMStore store, Long parentAcl, ACLCopyMode mode)
{
super(store.getAVMRepository().issueID(), store);
super(store);
AVMDAOs.Instance().fAVMNodeDAO.save(this);
AVMDAOs.Instance().fAVMNodeDAO.flush();
copyProperties(other);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -44,12 +44,11 @@ abstract class DirectoryNodeImpl extends AVMNodeImpl implements DirectoryNode
/**
* A pass through constructor. Called when a new concrete subclass
* instance is created.
* @param id
* @param repo
*/
protected DirectoryNodeImpl(long id, AVMStore repo)
protected DirectoryNodeImpl(AVMStore repo)
{
super(id, repo);
super(repo);
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -23,7 +23,6 @@
package org.alfresco.repo.avm;
import org.alfresco.repo.domain.DbAccessControlList;
/**
* Base class for file objects.
@@ -40,11 +39,10 @@ abstract class FileNodeImpl extends AVMNodeImpl implements FileNode
/**
* Pass through constructor.
* @param id The newly assigned object id.
* @param store The AVMStore we belong to.
*/
public FileNodeImpl(long id, AVMStore store)
public FileNodeImpl(AVMStore store)
{
super(id, store);
super(store);
}
}

View File

@@ -1,182 +0,0 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" */
package org.alfresco.repo.avm;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.transaction.TransactionService;
/**
* This is a helper class that knows how to issue identifiers.
*
* @author britt
*/
public class Issuer
{
/**
* How large a block of ids to grab at a time.
*/
private static final int BLOCK_SIZE = 100;
/**
* The next number to issue.
*/
private long fNext;
private long fLast;
/**
* The name of this issuer.
*/
private String fName;
private IssuerIDDAO fIDDAO;
private IssuerDAO fIssuerDAO;
private TransactionService fTxnService;
/**
* Default constructor.
*/
public Issuer()
{
fNext = 0;
fLast = 0;
}
public void setIssuerIDDAO(IssuerIDDAO dao)
{
fIDDAO = dao;
}
public void setIssuerDAO(IssuerDAO dao)
{
fIssuerDAO = dao;
}
public void setTransactionService(TransactionService service)
{
fTxnService = service;
}
public void init()
{
if (!fTxnService.isReadOnly())
{
fTxnService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute()
{
IssuerID issuerID = fIDDAO.get(fName);
Long id = fIssuerDAO.getIssuerValue(fName);
if (issuerID == null || id == null || id >= issuerID.getNext())
{
if (id == null)
{
id = 0L;
}
else
{
id = id + 1L;
}
if (issuerID == null)
{
issuerID = new IssuerIDImpl(fName, id);
fIDDAO.save(issuerID);
}
else
{
issuerID.setNext(id);
}
}
return null;
}
});
}
}
/**
* Set the name of this issuer. For Spring.
*
* @param name
* The name to set.
*/
public void setName(String name)
{
fName = name;
}
/**
* Issue the next number.
*
* @return A serial number.
*/
public synchronized long issue()
{
if (fNext >= fLast)
{
BlockGetter getter = new BlockGetter();
Thread thread = new Thread(getter);
thread.start();
try
{
thread.join();
}
catch (InterruptedException e)
{
// Do nothing.
}
fNext = getter.fNext;
fLast = getter.fLast;
}
return fNext++;
}
private class BlockGetter implements Runnable
{
public long fNext;
public long fLast;
/*
* (non-Javadoc)
*
* @see java.lang.Runnable#run()
*/
public void run()
{
fTxnService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute()
{
IssuerID isID = fIDDAO.get(fName);
fNext = isID.getNext();
fLast = fNext + BLOCK_SIZE;
isID.setNext(fLast);
return null;
}
});
}
}
}

View File

@@ -1,38 +0,0 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" */
package org.alfresco.repo.avm;
/**
* DAO for Issuers.
* @author britt
*/
public interface IssuerDAO
{
/**
* Get the Issuer value.
* @param The name of the issuer.
* @return The largest id issued by the named issuer.
*/
public Long getIssuerValue(String name);
}

View File

@@ -1,29 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm;
/**
* Trivial interface for accessing issuer ids.
* @author britt
*/
public interface IssuerID
{
/**
* Get the name of the issuer.
* @return
*/
public String getIssuer();
/**
* Get the highest id.
* @return
*/
public long getNext();
/**
* Set the next id to be issued.
* @param next The next id to be issued.
*/
public void setNext(long next);
}

View File

@@ -1,24 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm;
/**
* DAO interface for IssuerIDs.
* @author britt
*/
public interface IssuerIDDAO
{
/**
* Get one by name (primary key).
* @param name
* @return
*/
public IssuerID get(String name);
/**
* Save one.
* @param issuerID
*/
public void save(IssuerID issuerID);
}

View File

@@ -1,66 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm;
/**
* Bean for issuer id tracking.
* @author britt
*/
public class IssuerIDImpl implements IssuerID
{
private String fIssuer;
private long fNext;
private long fVersion;
public IssuerIDImpl()
{
}
public IssuerIDImpl(String issuer, long next)
{
fIssuer = issuer;
fNext = next;
}
public void setVersion(long version)
{
fVersion = version;
}
public long getVersion()
{
return fVersion;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.IssuerID#getIssuer()
*/
public String getIssuer()
{
return fIssuer;
}
public void setIssuer(String issuer)
{
fIssuer = issuer;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.IssuerID#getNext()
*/
public long getNext()
{
return fNext;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.IssuerID#setNext(long)
*/
public void setNext(long next)
{
fNext = next;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -95,7 +95,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
*/
public LayeredDirectoryNodeImpl(String indirection, AVMStore store, AVMNode toCopy, Long parentAcl, ACLCopyMode mode)
{
super(store.getAVMRepository().issueID(), store);
super(store);
fLayerID = -1;
fIndirection = indirection;
fIndirectionVersion = -1;
@@ -159,7 +159,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
*/
public LayeredDirectoryNodeImpl(LayeredDirectoryNode other, AVMStore repos, Lookup lookup, boolean copyAll, Long parentAcl, ACLCopyMode mode)
{
super(repos.getAVMRepository().issueID(), repos);
super(repos);
fIndirection = other.getIndirection();
fPrimaryIndirection = other.getPrimaryIndirection();
fIndirectionVersion = -1;
@@ -201,7 +201,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
*/
public LayeredDirectoryNodeImpl(PlainDirectoryNode other, AVMStore store, Lookup lPath, boolean copyContents, Long parentAcl, ACLCopyMode mode)
{
super(store.getAVMRepository().issueID(), store);
super(store);
fIndirection = null;
fPrimaryIndirection = false;
fIndirectionVersion = -1;
@@ -240,7 +240,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
*/
public LayeredDirectoryNodeImpl(DirectoryNode dir, AVMStore store, Lookup srcLookup, String name, Long inheritedAcl, ACLCopyMode mode)
{
super(store.getAVMRepository().issueID(), store);
super(store);
fIndirection = srcLookup.getIndirectionPath() + "/" + name;
fPrimaryIndirection = true;
fIndirectionVersion = -1;
@@ -793,7 +793,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
}
if (child != null && (indirect || child.getStoreNew() == null || child.getAncestor() != null))
{
DeletedNodeImpl ghost = new DeletedNodeImpl(lPath.getAVMStore().getAVMRepository().issueID(), lPath.getAVMStore(), child.getAcl());
DeletedNodeImpl ghost = new DeletedNodeImpl(lPath.getAVMStore(), child.getAcl());
AVMDAOs.Instance().fAVMNodeDAO.save(ghost);
AVMDAOs.Instance().fAVMNodeDAO.flush();
ghost.setAncestor(child);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -66,7 +66,7 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
*/
public LayeredFileNodeImpl(LayeredFileNode other, AVMStore store, Long parentAcl, ACLCopyMode mode)
{
super(store.getAVMRepository().issueID(), store);
super(store);
fIndirection = other.getIndirection();
fIndirectionVersion = -1;
setVersionID(other.getVersionID() + 1);
@@ -88,7 +88,7 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
*/
public LayeredFileNodeImpl(String indirection, AVMStore store, DbAccessControlList acl)
{
super(store.getAVMRepository().issueID(), store);
super(store);
fIndirection = indirection;
fIndirectionVersion = -1;
setVersionID(1);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -52,7 +52,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
*/
public PlainDirectoryNodeImpl(AVMStore store)
{
super(store.getAVMRepository().issueID(), store);
super(store);
setVersionID(1);
AVMDAOs.Instance().fAVMNodeDAO.save(this);
AVMDAOs.Instance().fAVMNodeDAO.flush();
@@ -74,7 +74,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
public PlainDirectoryNodeImpl(PlainDirectoryNode other,
AVMStore store, Long parentAcl, ACLCopyMode mode)
{
super(store.getAVMRepository().issueID(), store);
super(store);
AVMDAOs.Instance().fAVMNodeDAO.save(this);
for (ChildEntry child : AVMDAOs.Instance().fChildEntryDAO.getByParent(other, null))
{
@@ -295,8 +295,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
AVMDAOs.Instance().fChildEntryDAO.delete(entry);
if (child.getStoreNew() == null || child.getAncestor() != null)
{
DeletedNodeImpl ghost = new DeletedNodeImpl(lPath.getAVMStore().getAVMRepository().issueID(),
lPath.getAVMStore(), child.getAcl());
DeletedNodeImpl ghost = new DeletedNodeImpl(lPath.getAVMStore(), child.getAcl());
AVMDAOs.Instance().fAVMNodeDAO.save(ghost);
AVMDAOs.Instance().fAVMNodeDAO.flush();
ghost.setAncestor(child);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -79,7 +79,7 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
*/
public PlainFileNodeImpl(AVMStore store)
{
super(store.getAVMRepository().issueID(), store);
super(store);
setVersionID(1);
AVMDAOs.Instance().fAVMNodeDAO.save(this);
AVMDAOs.Instance().fAVMNodeDAO.flush();
@@ -93,7 +93,7 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
public PlainFileNodeImpl(PlainFileNode other,
AVMStore store, Long parentAcl, ACLCopyMode mode)
{
super(store.getAVMRepository().issueID(), store);
super(store);
// The null is OK because the Lookup argument is only use by
// layered files.
setContentData(other.getContentData(null));
@@ -123,7 +123,7 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
DbAccessControlList acl,
int versionID, Long parentAcl, ACLCopyMode mode)
{
super(store.getAVMRepository().issueID(), store);
super(store);
setContentData(content);
setBasicAttributes(attrs);
setVersionID(versionID + 1);

View File

@@ -13,10 +13,11 @@
optimistic-lock="version"
lazy="false">
<cache usage="read-write"/>
<!-- The id is set programmatically using an Issuer. See below. -->
<id name="id"
column="id"
type="long"/>
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<!-- I suppose this would be more efficient to encode type by an int.
We'll see if using a string makes a difference. -->
<discriminator column="class_type"
@@ -220,11 +221,6 @@
<property name="path" type="string" length="512" column="path"/>
</class>
<class name="IssuerIDImpl" proxy="IssuerID" table="avm_issuer_ids" optimistic-lock="version" lazy="false">
<id name="issuer" type="string" length="32" column="issuer"/>
<version name="version" column="version" type="long"/>
<property name="next" type="long" column="next_id" not-null="true"/>
</class>
<query name="ChildEntry.DeleteByParent">
<![CDATA[
delete ChildEntryImpl ce

View File

@@ -1,70 +0,0 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" */
package org.alfresco.repo.avm.hibernate;
import org.alfresco.repo.avm.IssuerDAO;
import org.alfresco.service.cmr.avm.AVMException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* DAO for Issuers. Hibernate version.
* @author britt
*/
class IssuerDAOHibernate extends HibernateDaoSupport implements
IssuerDAO
{
/**
* Do nothing constructor.
*/
public IssuerDAOHibernate()
{
super();
}
/**
* Get the largest issued id for the named issuer.
* @param The name of the issuer.
* @return The value or null if the issuer is brand new.
* @throws AVMException on an invalid name.
*/
public Long getIssuerValue(String name)
{
if (name.equals("content"))
{
return (Long)getSession().
createQuery("select max(fc.id) from FileContentImpl fc").uniqueResult();
}
else if (name.equals("layer"))
{
return (Long)getSession().
createQuery("select max(an.layerID) from AVMNodeImpl an").uniqueResult();
}
else if (name.equals("node"))
{
return (Long)getSession().createQuery("select max(an.id) from AVMNodeImpl an").uniqueResult();
}
throw new AVMException("Unknown issuer type: " + name);
}
}

View File

@@ -1,32 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm.hibernate;
import org.alfresco.repo.avm.IssuerID;
import org.alfresco.repo.avm.IssuerIDDAO;
import org.alfresco.repo.avm.IssuerIDImpl;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* Hibernate implementation of IssuerIDDAO
* @author britt
*/
public class IssuerIDDAOHibernate extends HibernateDaoSupport implements IssuerIDDAO
{
/* (non-Javadoc)
* @see org.alfresco.repo.avm.IssuerIDDAO#get(java.lang.String)
*/
public IssuerID get(String name)
{
return (IssuerID)getSession().get(IssuerIDImpl.class, name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.IssuerIDDAO#save(org.alfresco.repo.avm.IssuerID)
*/
public void save(IssuerID issuerID)
{
getSession().save(issuerID);
}
}