Merged V2.0 to HEAD

5450: (from V1.4)
      5423 (V1.4): CIFS authentication
   5451: (from V1.4)
      5432 (V1.4): 'No root node' fix
      5437 (V1.4): EHCache upgrade
      5440 (V1.4): AR-1355 - Ticket cache config fix
      5442 (V1.4): Bootstrap reorganization
      5446 (V1.4): AR-1353
   5452: (from V1.4)
      5391: AR-1310 (script rename fix)
   5453: Win32NetBIOS LANA
   5454: CIFS unused code


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5483 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-04-11 23:41:00 +00:00
parent 4ea83f7f2b
commit ad80d96da3
20 changed files with 1138 additions and 126 deletions

View File

@@ -35,6 +35,8 @@ import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.domain.ChildAssoc;
import org.alfresco.repo.domain.Node;
import org.alfresco.repo.domain.NodeStatus;
import org.alfresco.repo.node.BaseNodeServiceTest;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
@@ -353,4 +355,29 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest
mlTextProperty,
propertiesDirect.get(BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE));
}
public void testDuplicatePrimaryParentHandling() throws Exception
{
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph();
// get the node to play with
ChildAssociationRef n1pn3Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n1_p_n3"));
ChildAssociationRef n6pn8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8"));
final NodeRef n1Ref = n1pn3Ref.getParentRef();
final NodeRef n8Ref = n6pn8Ref.getChildRef();
// Add a make n1 a second primary parent of n8
Node n1 = nodeDaoService.getNode(n1Ref);
Node n8 = nodeDaoService.getNode(n8Ref);
ChildAssoc assoc = nodeDaoService.newChildAssoc(
n1,
n8,
true,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NAMESPACE, "n1pn8"));
// Now get the node primary parent
nodeService.getPrimaryParent(n8Ref);
// Get it again
nodeService.getPrimaryParent(n8Ref);
}
}

View File

@@ -900,6 +900,15 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
getSession().flush();
}
private Set<NodeRef> warnedDuplicateParents = new HashSet<NodeRef>(3);
/**
* @inheritDoc
*
* This method includes a check for multiple primary parent associations.
* The check doesn't fail but will warn (once per instance) of the occurence of
* the error. It is up to the administrator to fix the issue at the moment, but
* the server will not stop working.
*/
public ChildAssoc getPrimaryParentAssoc(Node node)
{
// get the assocs pointing to the node
@@ -914,12 +923,20 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
}
else if (primaryAssoc != null)
{
// we have more than one somehow
throw new DataIntegrityViolationException(
"Multiple primary associations: \n" +
" child: " + node + "\n" +
" first primary assoc: " + primaryAssoc + "\n" +
" second primary assoc: " + assoc);
// We have found one already.
synchronized(warnedDuplicateParents)
{
NodeRef childNodeRef = node.getNodeRef();
boolean added = warnedDuplicateParents.add(childNodeRef);
if (added)
{
logger.warn(
"Multiple primary associations: \n" +
" first primary assoc: " + primaryAssoc + "\n" +
" second primary assoc: " + assoc + "\n" +
"When running in a cluster, check that the caches are properly shared.");
}
}
}
primaryAssoc = assoc;
// we keep looping to hunt out data integrity issues
@@ -938,9 +955,21 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
}
if (!rootNode.equals(node))
{
// it wasn't the root node
throw new DataIntegrityViolationException("Non-root node has no primary parent: \n" +
" child: " + node);
// Reload the node to ensure that it is properly initialized
getSession().refresh(node);
// Check if it has any parents yet.
if (node.getParentAssocs().size() == 0)
{
// It wasn't the root node and definitely has no parent
throw new DataIntegrityViolationException(
"Non-root node has no primary parent: \n" +
" child: " + node);
}
else
{
// Repeat this method with confidence
primaryAssoc = getPrimaryParentAssoc(node);
}
}
}
// done

View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.node.index;
import org.alfresco.util.AbstractLifecycleBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationEvent;
public class IndexRecoveryBootstrapBean extends AbstractLifecycleBean
{
protected final static Log log = LogFactory.getLog(IndexRecoveryBootstrapBean.class);
IndexRecovery indexRecoveryComponent;
@Override
protected void onBootstrap(ApplicationEvent event)
{
// reindex
log.info("Checking/Recovering indexes ...");
indexRecoveryComponent.reindex();
}
@Override
protected void onShutdown(ApplicationEvent event)
{
// Nothing to do
}
public IndexRecovery getIndexRecoveryComponent()
{
return indexRecoveryComponent;
}
public void setIndexRecoveryComponent(IndexRecovery indexRecoveryComponent)
{
this.indexRecoveryComponent = indexRecoveryComponent;
}
}