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:
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.admin.patch.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.avm.locking.AVMLockingServiceImpl;
|
||||
import org.alfresco.repo.domain.patch.PatchDAO;
|
||||
import org.alfresco.service.cmr.attributes.AttributeService;
|
||||
import org.alfresco.wcm.util.WCMUtil;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
import com.ibatis.sqlmap.client.event.RowHandler;
|
||||
|
||||
/**
|
||||
* Migrate AVM lock attributes (from 'alf_*attribute*' to 'alf_prop_*')
|
||||
*
|
||||
* @author janv
|
||||
* @since 3.4
|
||||
*/
|
||||
public class MigrateAttrAVMLocksPatch extends AbstractPatch
|
||||
{
|
||||
private Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private static final String MSG_SUCCESS = "patch.migrateAttrAVMLocks.result";
|
||||
|
||||
private AttributeService attributeService;
|
||||
private PatchDAO patchDAO;
|
||||
|
||||
public void setAttributeService(AttributeService attributeService)
|
||||
{
|
||||
this.attributeService = attributeService;
|
||||
}
|
||||
|
||||
public void setPatchDAO(PatchDAO patchDAO)
|
||||
{
|
||||
this.patchDAO = patchDAO;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
AVMLockRowHandler handler = new AVMLockRowHandler();
|
||||
patchDAO.migrateOldAttrAVMLocks(handler);
|
||||
|
||||
if (handler.total > 0)
|
||||
{
|
||||
logger.info("Processed "+handler.total+" AVM Lock attrs in "+(System.currentTimeMillis()-startTime)/1000+" secs");
|
||||
}
|
||||
|
||||
// build the result message
|
||||
String msg = I18NUtil.getMessage(MSG_SUCCESS, handler.total);
|
||||
// done
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Row handler for migrating AVM Locks
|
||||
*/
|
||||
private class AVMLockRowHandler implements RowHandler
|
||||
{
|
||||
private int total = 0;
|
||||
|
||||
private AVMLockRowHandler()
|
||||
{
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public void handleRow(Object valueObject)
|
||||
{
|
||||
Map<String, Object> result = (Map<String, Object>)valueObject;
|
||||
|
||||
String wpStoreId = (String)result.get("wpStoreId");
|
||||
String relPath = (String)result.get("relPath");
|
||||
String avmStore = (String)result.get("avmStore");
|
||||
String lockOwner = (String)result.get("owner1");
|
||||
|
||||
relPath = AVMLockingServiceImpl.normalizePath(relPath);
|
||||
|
||||
HashMap<String, String> lockData = new HashMap<String, String>(2);
|
||||
lockData.put(AVMLockingServiceImpl.KEY_LOCK_OWNER, lockOwner);
|
||||
lockData.put(WCMUtil.LOCK_KEY_STORE_NAME, avmStore);
|
||||
|
||||
attributeService.createAttribute(
|
||||
lockData,
|
||||
AVMLockingServiceImpl.KEY_AVM_LOCKS, wpStoreId, relPath);
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("Set AVM Lock attr [wpStoreId="+wpStoreId+", relPath="+relPath+", lockOwner="+lockOwner+", avmStore="+avmStore+"]");
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
if (logger.isDebugEnabled() && (total == 0 || (total % 1000 == 0) ))
|
||||
{
|
||||
logger.debug(" Handled " + total + " AVM Lock attributes");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.admin.patch.impl;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.domain.patch.PatchDAO;
|
||||
import org.alfresco.repo.security.sync.ChainingUserRegistrySynchronizer;
|
||||
import org.alfresco.service.cmr.attributes.AttributeService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
import com.ibatis.sqlmap.client.event.RowHandler;
|
||||
|
||||
/**
|
||||
* Migrate Chaining User Registry Synchronizer attributes (from 'alf_*attribute*' to 'alf_prop_*')
|
||||
*
|
||||
* @author janv
|
||||
* @since 3.4
|
||||
*/
|
||||
public class MigrateAttrChainingURSPatch extends AbstractPatch
|
||||
{
|
||||
private Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private static final String MSG_SUCCESS = "patch.migrateAttrChainingURS.result";
|
||||
|
||||
private AttributeService attributeService;
|
||||
private PatchDAO patchDAO;
|
||||
|
||||
public void setAttributeService(AttributeService attributeService)
|
||||
{
|
||||
this.attributeService = attributeService;
|
||||
}
|
||||
|
||||
public void setPatchDAO(PatchDAO patchDAO)
|
||||
{
|
||||
this.patchDAO = patchDAO;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
ChainingURSRowHandler handler = new ChainingURSRowHandler();
|
||||
patchDAO.migrateOldAttrChainingURS(handler);
|
||||
|
||||
if (handler.total > 0)
|
||||
{
|
||||
logger.info("Processed "+handler.total+" Chaining URS attrs in "+(System.currentTimeMillis()-startTime)/1000+" secs");
|
||||
}
|
||||
|
||||
// build the result message
|
||||
String msg = I18NUtil.getMessage(MSG_SUCCESS, handler.total);
|
||||
// done
|
||||
return msg;
|
||||
}
|
||||
|
||||
private class ChainingURSRowHandler implements RowHandler
|
||||
{
|
||||
private int total = 0;
|
||||
|
||||
private ChainingURSRowHandler()
|
||||
{
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public void handleRow(Object valueObject)
|
||||
{
|
||||
Map<String, Object> result = (Map<String, Object>)valueObject;
|
||||
|
||||
String label = (String)result.get("label");
|
||||
String zoneId = (String)result.get("zoneId");
|
||||
Long lastModified = (Long)result.get("lastModified");
|
||||
|
||||
attributeService.setAttribute(
|
||||
lastModified,
|
||||
ChainingUserRegistrySynchronizer.ROOT_ATTRIBUTE_PATH, label, zoneId);
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("Set Chaining URS attr [label="+label+", zoneId="+zoneId+", lastModified="+lastModified+"]");
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
if (logger.isDebugEnabled() && (total == 0 || (total % 1000 == 0) ))
|
||||
{
|
||||
logger.debug(" Handled " + total + " Chaining URS attributes");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.admin.patch.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.domain.patch.PatchDAO;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Migrate attributes - check no custom attributes and then delete from 'alf_*attribute*' tables
|
||||
*
|
||||
* @author janv
|
||||
* @since 3.4
|
||||
*/
|
||||
public class MigrateAttrDeletePatch extends AbstractPatch
|
||||
{
|
||||
private Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private static final String MSG_SUCCESS = "patch.migrateAttrDelete.result";
|
||||
|
||||
private PatchDAO patchDAO;
|
||||
|
||||
public void setPatchDAO(PatchDAO patchDAO)
|
||||
{
|
||||
this.patchDAO = patchDAO;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
List<String> results = patchDAO.getOldAttrCustomNames();
|
||||
|
||||
if (results.size() > 0)
|
||||
{
|
||||
for (String custom : results)
|
||||
{
|
||||
logger.warn("Custom global attribute found: "+custom);
|
||||
}
|
||||
throw new AlfrescoRuntimeException("Custom attributes found - will require custom migration patch: "+results);
|
||||
}
|
||||
|
||||
patchDAO.deleteAllOldAttrs();
|
||||
|
||||
// build the result message
|
||||
String msg = I18NUtil.getMessage(MSG_SUCCESS);
|
||||
// done
|
||||
return msg;
|
||||
}
|
||||
}
|
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.admin.patch.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.domain.patch.PatchDAO;
|
||||
import org.alfresco.service.cmr.attributes.AttributeService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
import com.ibatis.sqlmap.client.event.RowHandler;
|
||||
|
||||
/**
|
||||
* Migrate Property-Backed Bean attributes (from 'alf_*attribute*' to 'alf_prop_*')
|
||||
*
|
||||
* @author janv
|
||||
* @since 3.4
|
||||
*/
|
||||
public class MigrateAttrPropBackedBeanPatch extends AbstractPatch
|
||||
{
|
||||
private Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private static final String ROOT_KEY_PBB = ".PropertyBackedBeans"; // see also PropertyBackBeanAdapter.ROOT_ATTRIBUTE_PATH
|
||||
|
||||
private static final String MSG_SUCCESS = "patch.migrateAttrPropBackedBeans.result";
|
||||
|
||||
private AttributeService attributeService;
|
||||
private PatchDAO patchDAO;
|
||||
|
||||
public void setAttributeService(AttributeService attributeService)
|
||||
{
|
||||
this.attributeService = attributeService;
|
||||
}
|
||||
|
||||
public void setPatchDAO(PatchDAO patchDAO)
|
||||
{
|
||||
this.patchDAO = patchDAO;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
PBBRowHandler handler = new PBBRowHandler();
|
||||
patchDAO.migrateOldAttrPropertyBackedBeans(handler);
|
||||
handler.setComponent(handler.currentComponentName, handler.attributeMap); // set last component attribute (if any)
|
||||
|
||||
if (handler.total > 0)
|
||||
{
|
||||
logger.info("Processed "+handler.total+" Property-Backed Component attrs ("+handler.totalProps+" props) in "+(System.currentTimeMillis()-startTime)/1000+" secs");
|
||||
}
|
||||
|
||||
// build the result message
|
||||
String msg = I18NUtil.getMessage(MSG_SUCCESS, handler.total, handler.totalProps);
|
||||
// done
|
||||
return msg;
|
||||
}
|
||||
|
||||
private class PBBRowHandler implements RowHandler
|
||||
{
|
||||
private int total = 0;
|
||||
private int totalProps = 0;
|
||||
|
||||
private Map<String, String> attributeMap = new HashMap<String, String>(10);
|
||||
private String currentComponentName = "";
|
||||
|
||||
private PBBRowHandler()
|
||||
{
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public void handleRow(Object valueObject)
|
||||
{
|
||||
Map<String, Object> result = (Map<String, Object>)valueObject;
|
||||
|
||||
String componentName = (String)result.get("componentName");
|
||||
String propName = (String)result.get("propName");
|
||||
String propValue = (String)result.get("propValue");
|
||||
|
||||
if (! currentComponentName.equals(componentName))
|
||||
{
|
||||
// write out previous component - note: does nothing on 1st call
|
||||
setComponent(currentComponentName, attributeMap);
|
||||
|
||||
currentComponentName = componentName;
|
||||
attributeMap.clear();
|
||||
}
|
||||
|
||||
attributeMap.put(propName, propValue);
|
||||
|
||||
totalProps++;
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("Read PBB [componentName="+componentName+", propName="+propName+", propValue="+propValue+"]");
|
||||
}
|
||||
}
|
||||
|
||||
// note: args should not be null
|
||||
public void setComponent(String componentName, Map<String, String> attributeMap)
|
||||
{
|
||||
if (componentName.equals("") || attributeMap.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
attributeService.setAttribute(
|
||||
(Serializable) attributeMap,
|
||||
ROOT_KEY_PBB, componentName);
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("Set PBB component attr [name="+componentName+", attributeMap="+attributeMap+"]");
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
if (logger.isDebugEnabled() && (total == 0 || (total % 1000 == 0) ))
|
||||
{
|
||||
logger.debug(" Handled " + total + " Chaining URS attrs");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.admin.patch.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.domain.patch.PatchDAO;
|
||||
import org.alfresco.repo.tenant.MultiTAdminServiceImpl;
|
||||
import org.alfresco.service.cmr.attributes.AttributeService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
import com.ibatis.sqlmap.client.event.RowHandler;
|
||||
|
||||
/**
|
||||
* Migrate Tenant attributes (from 'alf_*attribute*' to 'alf_prop_*')
|
||||
*
|
||||
* @author janv
|
||||
* @since 3.4
|
||||
*/
|
||||
public class MigrateAttrTenantsPatch extends AbstractPatch
|
||||
{
|
||||
private Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private static final String MSG_SUCCESS = "patch.migrateAttrTenants.result";
|
||||
|
||||
private AttributeService attributeService;
|
||||
private PatchDAO patchDAO;
|
||||
|
||||
public void setAttributeService(AttributeService attributeService)
|
||||
{
|
||||
this.attributeService = attributeService;
|
||||
}
|
||||
|
||||
public void setPatchDAO(PatchDAO patchDAO)
|
||||
{
|
||||
this.patchDAO = patchDAO;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
TenantRowHandler handler = new TenantRowHandler();
|
||||
patchDAO.migrateOldAttrTenants(handler);
|
||||
|
||||
if (handler.total > 0)
|
||||
{
|
||||
logger.info("Processed "+handler.total+" Tenant attrs in "+(System.currentTimeMillis()-startTime)/1000+" secs");
|
||||
}
|
||||
|
||||
// build the result message
|
||||
String msg = I18NUtil.getMessage(MSG_SUCCESS, handler.total);
|
||||
// done
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Row handler for migrating tenants
|
||||
*/
|
||||
private class TenantRowHandler implements RowHandler
|
||||
{
|
||||
private int total = 0;
|
||||
|
||||
private TenantRowHandler()
|
||||
{
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public void handleRow(Object valueObject)
|
||||
{
|
||||
Map<String, Object> result = (Map<String, Object>)valueObject;
|
||||
|
||||
String tenantDomain = (String)result.get("tenantDomain");
|
||||
Boolean isEnabled = (Boolean)result.get("isEnabled");
|
||||
String rootDir = (String)result.get("rootDir");
|
||||
|
||||
Map<String, Serializable> tenantAttributes = new HashMap<String, Serializable>(7);
|
||||
tenantAttributes.put(MultiTAdminServiceImpl.TENANT_ATTRIBUTE_ENABLED, isEnabled.booleanValue());
|
||||
tenantAttributes.put(MultiTAdminServiceImpl.TENANT_ATTRIBUTE_ROOT_CONTENT_STORE_DIR, rootDir);
|
||||
|
||||
attributeService.setAttribute(
|
||||
(Serializable) tenantAttributes,
|
||||
MultiTAdminServiceImpl.TENANTS_ATTRIBUTE_PATH, tenantDomain);
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("Set Tenant attr [tenantDomain="+tenantDomain+", isEnabled="+isEnabled+", rootDir="+rootDir+"]");
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
if (logger.isDebugEnabled() && (total == 0 || (total % 1000 == 0) ))
|
||||
{
|
||||
logger.debug(" Handled " + total + " tenant attributes");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -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");
|
||||
}
|
||||
}
|
||||
|
@@ -111,7 +111,7 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean impl
|
||||
private static final long LOCK_TTL = 1000 * 60 * 2;
|
||||
|
||||
/** The path in the attribute service below which we persist attributes. */
|
||||
private static final String ROOT_ATTRIBUTE_PATH = ".ChainingUserRegistrySynchronizer";
|
||||
public static final String ROOT_ATTRIBUTE_PATH = ".ChainingUserRegistrySynchronizer";
|
||||
|
||||
/** The label under which the last group modification timestamp is stored for each zone. */
|
||||
private static final String GROUP_LAST_MODIFIED_ATTRIBUTE = "GROUP";
|
||||
|
@@ -218,9 +218,9 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
||||
public static final String STORE_BASE_ID_VERSION2 = "version2Store";
|
||||
public static final String STORE_BASE_ID_SPACES = "SpacesStore";
|
||||
|
||||
private static final String TENANTS_ATTRIBUTE_PATH = "alfresco-tenants";
|
||||
private static final String TENANT_ATTRIBUTE_ENABLED = "enabled";
|
||||
private static final String TENANT_ATTRIBUTE_ROOT_CONTENT_STORE_DIR = "rootContentStoreDir";
|
||||
public static final String TENANTS_ATTRIBUTE_PATH = "alfresco-tenants";
|
||||
public static final String TENANT_ATTRIBUTE_ENABLED = "enabled";
|
||||
public static final String TENANT_ATTRIBUTE_ROOT_CONTENT_STORE_DIR = "rootContentStoreDir";
|
||||
|
||||
private List<TenantDeployer> tenantDeployers = new ArrayList<TenantDeployer>();
|
||||
|
||||
|
Reference in New Issue
Block a user