mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
SAIL-239 - Attributes DAO refactor (patches to migrate in-built attributes)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20822 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -27,6 +27,8 @@ import org.alfresco.repo.domain.contentdata.ContentDataDAO;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
|
||||
import com.ibatis.sqlmap.client.event.RowHandler;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract implementation for Patch DAO.
|
||||
@@ -162,10 +164,10 @@ public abstract class AbstractPatchDAOImpl implements PatchDAO, BatchingDAO
|
||||
{
|
||||
String stringValue = (String) prop.get("stringValue");
|
||||
|
||||
ContentData contentData = ContentData.createContentProperty(stringValue);
|
||||
Long contentDataId = contentDataDAO.createContentData(contentData).getFirst();
|
||||
prop.put("contentDataId", contentDataId);
|
||||
}
|
||||
ContentData contentData = ContentData.createContentProperty(stringValue);
|
||||
Long contentDataId = contentDataDAO.createContentData(contentData).getFirst();
|
||||
prop.put("contentDataId", contentDataId);
|
||||
}
|
||||
|
||||
// Now do the updates in the context of a batch
|
||||
try
|
||||
@@ -231,4 +233,50 @@ public abstract class AbstractPatchDAOImpl implements PatchDAO, BatchingDAO
|
||||
protected abstract int deleteDanglingAceEntities();
|
||||
protected abstract int deleteAclEntities(List<Long> aclIds);
|
||||
protected abstract int deleteAclMemberEntitiesForAcls(List<Long> aclIds);
|
||||
|
||||
// note: caller's row handler is expected to migrate the attrs
|
||||
public void migrateOldAttrTenants(RowHandler rowHandler)
|
||||
{
|
||||
getOldAttrTenantsImpl(rowHandler);
|
||||
}
|
||||
|
||||
protected abstract void getOldAttrTenantsImpl(RowHandler rowHandler);
|
||||
|
||||
// note: caller's row handler is expected to migrate the attrs
|
||||
public void migrateOldAttrAVMLocks(RowHandler rowHandler)
|
||||
{
|
||||
getOldAttrAVMLocksImpl(rowHandler);
|
||||
}
|
||||
|
||||
protected abstract void getOldAttrAVMLocksImpl(RowHandler rowHandler);
|
||||
|
||||
// note: caller's row handler is expected to migrate the attrs
|
||||
public void migrateOldAttrPropertyBackedBeans(RowHandler rowHandler)
|
||||
{
|
||||
getOldAttrPropertyBackedBeansImpl(rowHandler);
|
||||
}
|
||||
|
||||
protected abstract void getOldAttrPropertyBackedBeansImpl(RowHandler rowHandler);
|
||||
|
||||
// note: caller's row handler is expected to migrate the attrs
|
||||
public void migrateOldAttrChainingURS(RowHandler rowHandler)
|
||||
{
|
||||
getOldAttrChainingURSImpl(rowHandler);
|
||||
}
|
||||
|
||||
protected abstract void getOldAttrChainingURSImpl(RowHandler rowHandler);
|
||||
|
||||
public List<String> getOldAttrCustomNames()
|
||||
{
|
||||
return getOldAttrCustomNamesImpl();
|
||||
}
|
||||
|
||||
protected abstract List<String> getOldAttrCustomNamesImpl();
|
||||
|
||||
public void deleteAllOldAttrs()
|
||||
{
|
||||
deleteAllOldAttrsImpl();
|
||||
}
|
||||
|
||||
protected abstract void deleteAllOldAttrsImpl();
|
||||
}
|
||||
|
@@ -29,6 +29,8 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
import com.ibatis.sqlmap.client.event.RowHandler;
|
||||
|
||||
/**
|
||||
* Additional DAO services for patches
|
||||
*
|
||||
@@ -176,4 +178,34 @@ public interface PatchDAO
|
||||
* @return Returns the node ID and node name
|
||||
*/
|
||||
public List<Pair<NodeRef, String>> getNodesOfTypeWithNamePattern(QName typeQName, String namePattern);
|
||||
|
||||
/**
|
||||
* Migrate old Tenant attributes (if any)
|
||||
*/
|
||||
public void migrateOldAttrTenants(RowHandler rowHandler);
|
||||
|
||||
/**
|
||||
* Migrate old AVM Lock attributes (if any)
|
||||
*/
|
||||
public void migrateOldAttrAVMLocks(RowHandler rowHandler);
|
||||
|
||||
/**
|
||||
* Migrate old Property-Backed Bean attributes (if any)
|
||||
*/
|
||||
public void migrateOldAttrPropertyBackedBeans(RowHandler rowHandler);
|
||||
|
||||
/**
|
||||
* Migrate old Chaining User Registry Synchronizer attributes (if any)
|
||||
*/
|
||||
public void migrateOldAttrChainingURS(RowHandler rowHandler);
|
||||
|
||||
/**
|
||||
* Get custom global attribute names (if any)
|
||||
*/
|
||||
public List<String> getOldAttrCustomNames();
|
||||
|
||||
/**
|
||||
* Delete all old attributes (from alf_*attribute* tables)
|
||||
*/
|
||||
public void deleteAllOldAttrs();
|
||||
}
|
||||
|
@@ -85,6 +85,16 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl
|
||||
private static final String DELETE_PERMISSIONS_ACL_LIST = "alfresco.permissions.delete_AclList";
|
||||
private static final String DELETE_PERMISSIONS_ACL_MEMBERS_FOR_ACL_LIST = "alfresco.permissions.delete_AclMembersForAclList";
|
||||
|
||||
private static final String SELECT_OLD_ATTR_TENANTS = "alfresco.patch.select_oldAttrTenants";
|
||||
private static final String SELECT_OLD_ATTR_AVM_LOCKS= "alfresco.patch.select_oldAttrAVMLocks";
|
||||
private static final String SELECT_OLD_ATTR_PBBS = "alfresco.patch.select_oldAttrPropertyBackedBeans";
|
||||
private static final String SELECT_OLD_ATTR_CHAINING_URS = "alfresco.patch.select_oldAttrChainingURS";
|
||||
private static final String SELECT_OLD_ATTR_CUSTOM_NAMES = "alfresco.patch.select_oldAttrCustomNames";
|
||||
|
||||
private static final String DELETE_OLD_ATTR_LIST = "alfresco.patch.delete_oldAttrAlfListAttributeEntries";
|
||||
private static final String DELETE_OLD_ATTR_MAP = "alfresco.patch.delete_oldAttrAlfMapAttributeEntries";
|
||||
private static final String DELETE_OLD_ATTR_GLOBAL = "alfresco.patch.delete_oldAttrAlfGlobalAttributes";
|
||||
private static final String DELETE_OLD_ATTR = "alfresco.patch.delete_oldAttrAlfAttributes";
|
||||
|
||||
private SqlMapClientTemplate template;
|
||||
private QNameDAO qnameDAO;
|
||||
@@ -446,12 +456,12 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl
|
||||
// Done
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
public int getChildAssocCount()
|
||||
{
|
||||
return (Integer) template.queryForObject(SELECT_CHILD_ASSOCS_COUNT);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Map<String, Object>> getChildAssocsForCrcFix(Long minAssocId, int maxResults)
|
||||
{
|
||||
@@ -464,7 +474,7 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl
|
||||
// Done
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
public int updateChildAssocCrc(Long assocId, Long childNodeNameCrc, Long qnameCrc)
|
||||
{
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
@@ -473,7 +483,7 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl
|
||||
params.put("qnameCrc", qnameCrc);
|
||||
return template.update(UPDATE_CHILD_ASSOC_CRC, params);
|
||||
}
|
||||
|
||||
|
||||
public List<Pair<NodeRef, String>> getNodesOfTypeWithNamePattern(QName typeQName, String namePattern)
|
||||
{
|
||||
Pair<Long, QName> typeQNamePair = qnameDAO.getQName(typeQName);
|
||||
@@ -515,4 +525,53 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl
|
||||
template.queryWithRowHandler(SELECT_NODES_BY_TYPE_AND_NAME_PATTERN, params, rowHandler);
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void getOldAttrTenantsImpl(RowHandler rowHandler)
|
||||
{
|
||||
template.queryWithRowHandler(SELECT_OLD_ATTR_TENANTS, rowHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void getOldAttrAVMLocksImpl(RowHandler rowHandler)
|
||||
{
|
||||
template.queryWithRowHandler(SELECT_OLD_ATTR_AVM_LOCKS, rowHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void getOldAttrPropertyBackedBeansImpl(RowHandler rowHandler)
|
||||
{
|
||||
template.queryWithRowHandler(SELECT_OLD_ATTR_PBBS, rowHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void getOldAttrChainingURSImpl(RowHandler rowHandler)
|
||||
{
|
||||
template.queryWithRowHandler(SELECT_OLD_ATTR_CHAINING_URS, rowHandler);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected List<String> getOldAttrCustomNamesImpl()
|
||||
{
|
||||
return (List<String>)template.queryForList(SELECT_OLD_ATTR_CUSTOM_NAMES);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteAllOldAttrsImpl()
|
||||
{
|
||||
int deleted = 0;
|
||||
|
||||
deleted = template.delete(DELETE_OLD_ATTR_LIST);
|
||||
logger.info("Deleted "+deleted+" rows from alf_list_attribute_entries");
|
||||
|
||||
deleted = template.delete(DELETE_OLD_ATTR_MAP);
|
||||
logger.info("Deleted "+deleted+" rows from alf_map_attribute_entries");
|
||||
|
||||
deleted = template.delete(DELETE_OLD_ATTR_GLOBAL);
|
||||
logger.info("Deleted "+deleted+" rows from alf_global_attributes");
|
||||
|
||||
deleted = template.delete(DELETE_OLD_ATTR);
|
||||
logger.info("Deleted "+deleted+" rows from alf_attributes");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user