mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-30 18:15:39 +00:00
40170: Fix compile error following merge from 4.1.0 to 4.1.1 40175: ALF-14002 (5108), ALF-14220 (5109), ALF-15419 (5110) patch versions for 4.1.1 that came from commits made to V4.0-BUG-FIX after 4.0.2 was released. 40203: Fix 4.1 -> 4.1.1 merge error that was stopping start up of Share. Required change to extra config in 4.1.1 added for ALF-12524. There are other differences in the file for ALF-14812 and ALF-14813 but were not impacted. 40206: ALF-15281 - FTP/FTPS: With preserve timestamps turned off, the modification date does not change. 40208: ALF-12831: Upgrade to swftools 0.9.2 40210: ALF-13933: First attempt at installing LibreOffice 3.5 - Installed to a subdirectory called libreoffice - OpenOffice, Openoffice and OpenOffice.org replaced in all display strings 40229: ALF-7278: Merged V3.4-BUG-FIX (3.4.11) to V4.1-BUG-FIX (4.1.1) 40227: ALF-15436 CLONE Alfresco 3.4c + Share + TIFF preview only shows the first page 40237: Fix for ALF-14663 from Vadim Danilchenko - the 'edit online' button in Share fails but we do not send any error message 40258: Merged BRANCHES/DEV/BELARUS/V4.1-BUG-FIX-2012_07_09 to BRANCHES/DEV/V4.1-BUG-FIX: 39668: ALF-15214 patch.fixBpmPackages performs unnecessary work 40261: Merged V3.4-BUG-FIX to V4.1-BUG-FIX 38592: Fixed ALF-14929: NodeDAO might not be last node write to the database - Regression introduced when Hibernate was removed - Fix validated by unit test 38596: Merged DEV to V3.4-BUG-FIX 38594: ALF-14744: Documents uploaded via WebDAV mount from Windows 7, and copied by a jscript rule are zero-length Change CreateNodeRuleTrigger.onCreateNode() method: Search for property of "d:content" type in node TypeDefinition, AspectDefinitions of node aspects and don't fire rules if found. 38781: Fixed ALF-14979: Long running AVM XPath queries on startup - Basic XPath was always fetching all siblings 38896: ALF-14744: Fix rule-firing regressions plus unit test - CreateNodeRuleTrigger must remember new nodes, regardless of whether it fires to avoid an update being fired on a node created in the same transaction - Tests should not assume that inbound rule will be fired on a content-less node (when the node's type or aspects have content properties) 38909: Merged DEV to V3.4-BUG-FIX (3.4.11) << Fix for issued identified by QA on 20/6/12 after verification of customer issues >> 38849: ALF-11956: WCM accessibility Navigation between the fields with erroneous data has been modified to allow navigation between elements of composite widgets such as Date/Time pickers etc... - the fix for ALF-10804 is backported (required for the current fix); - ability of cancelling and reactivating the strict navigation sequence has been added (pressing the Escape key for cancelling and focusing the alert link for reactivating); - generation of duplicate ids for comboboxes of the 'MonthDayPicker' widget has been fixed 38544: ALF-11956: WCM accessibility Draft implementation of 'FocusResolver' which introduces functionality of strict sequence for navigation between fields of the XForms widgets with erroneous data detected during validation 38934: Fix for ALF-13658/ALF-14849 38990: ALF-13048 Configuration of temp directories for converters (Openoffice and JOD) More general approach taken for JOD : - Allow an OpenOffice user template profile to be used by the JOD started OpenOffice process via the alfresco global property jodconverter.templateProfileDir - Among other settings, the profile contains values set in Tools|Options via the UI This includes the temporary directory: Tools|Options|openOffice.org|Temporary Files - If blank, a default profile is created. The user profile is recreated on each restart from the template. May be set to an existing user's profile such as: C:\Users\<username>\AppData\Roaming\OpenOffice.org\3 39115: Merged V3.4 to V3.4-BUG-FIX 38593: Merged DEV to V3.4 38572: ALF-13578: CIFS: AlfJLANWorker threads (concurrency) - server not responding Add nodeServices.exists(nodeRef) check to errorHandler in ContentDiskDriver.closeFile() to hide InvalidNodeRefException here. 38591: ALF-13578: CIFS: AlfJLANWorker threads (concurrency) - server not responding Replace "catch (AlfrescoRuntimeException e)" with "catch (RuntimeException e)" in ContentDiskDriver. Add "catch (InvalidNodeRefException ex)" to ContentDiskDriver.renameFile() method and throw java.io.FileNotFoundException here. 39063: Process the async packet queue at the end of CIFS NIO socket processing, before re-enabling socket events. ALF-13578. 39117: Merged V3.4 to V3.4-BUG-FIX (RECORD ONLY) 39116: ALF-13578: Reversed r39063 due to QA time constraints. Fix will be made limited availability and in next service pack. 39179: Merged DEV to V3.4-BUG-FIX (3.4.11) 38911: ALF-14827: Cannot see metrics data to Alfresco Enterprise Content Store in Hyperic HQ The attribute "TotalSize" is no longer exists in the Alfresco 3.4.x SpaceFree and SpaceTotal are added to the alfresco enterprise plugin. 38910: ALF-15016: Cannot see services to FTP, NFS Server in Hyperic HQ Alfresco enterrprise plugin fixed so that FTP and NFS Server resources now available in resources tab. 39230: ALF-15048 - Create Rule 'Execute Script'- 'Append Copyright to file' - Script that added the copyright was hidden in a .acp file (a zip file). .acp is normally used by wireshark so was not found in searches. 39294: Merged V3.4 to V3.4-BUG-FIX 39293: ALF-14698: Merged PATCHES/V3.4.6 to V3.4 38786: Merged V4.0-BUG-FIX to PATCHES/V3.4.6 (partial rework) 34279: NodeDAO: re-parent "lost & found" orphan child nodes (see ALF-12358 & ALF-13066 / SYS-301) - if orphaned nodes are identified (eg. via getPath(s)) then attempt partial recovery by placing them in (temp) lost_found - ... ALF-12358 ('child' node has deleted parent(s)) - ... ALF-13066 (non-root 'child' node has no parent(s)) - for internal use only - allows index tracking (eg. Solr) to continue - precursor to fixing underlying root causes 34338: NodeDAO: re-parent "lost & found" orphan child nodes (see ALF-12358 & ALF-13066 / SYS-301) - test fix (follow-on to r34279) 34341: NodeDAO: re-parent "lost & found" orphan child nodes (see ALF-12358 & ALF-13066 / SYS-301) - ano test fix (once more with feeling) 34434: ALF-13066: Fix for intermittent failure (testConcurrentLinkToDeletedNode) 38959: ALF-15136: Merged HEAD to PATCHES/V3.4.6 32659: Fixed ALF-11946: Lucene index recovery startup can cause full table scans and file sorts - Made the backward timestepping work in bounded segments, whereas previously there was no lower bound causing the database to creak under load and the whole process to take a long time. - Seen during benchmark testing as well 39211: ALF-15109: 'Touch' nodes in every case where we add / remove secondary parent associations. Causing group membership fallout at SAP. 39218: ALF-15109: Improved fix - must fire cascaded secondary association deletions at DbNodeServiceImpl level to ensure appropriate index events are fired and prevent out of sync indexes! 39240: ALF-15109: Another attempt. Now we are firing all the right events on cascade removal of secondary associations a lot of things are coming out in the wash! - Cascade delete secondary associations in a first recursive pass - Use a List of Pairs rather than a Map to avoid missing multiple associations to the same child 39295: Fixed merge issue 39381: ALF-12781 - Unable to set email contributors authority 39595: Fix for ALF-12506 - utils.setLocale() override the value to a lower case. 39932: ALF-9540: copy from drive to CIFS is slower than direct drive to drive copy by a factor of ~ 15 39935: ALF-9606: JSF, WebDav + Kerberos - Browser goes to a previous visited page when done/cancel edit online document - User is now redirected to logon when session expires. 39961: ALF-9540: Fix some broken unit tests caused by missing policies. 40026: Return success status for CIFS set security descriptor call even when the SecurityDescriptorInterface is not implemented. ALF-15357 Attempt to fix slow MS Office docx file save, unable to reproduce locally. 40090: ALF-15388: Merged V4.1-BUG-FIX to V3.4-BUG-FIX 40022: Fix for ALF-15144 - Slow Share doclib high-level folder browsing due to version history retrieval Revision: 40159 Author: taksoy Date: Tuesday, August 07, 2012 1:44:29 PM Message: ALF-13636: ReferenceError: "containerId" is not defined - Exception thrown during folder rule creation ---- Modified : /alfresco/BRANCHES/DEV/V3.4-BUG-FIX/root/projects/slingshot/source/web/modules/documentlibrary/global-folder.js 40231: ALF-13575: Merged DEV to V3.4-BUG-FIX 39879: Use of NetBIOS name versus DNS name in links accessed through CIFS - hostname is now determined from the path used to mount the drive on the client 40251: Merged DEV to V3.4-BUG-FIX 39667: ALF-4832: Incorrect behaviour of user's activities information in Moderated sites Introduce new method to ActivityPostService that accept userName. Post activity using new method when user is joined to site. 40252: Merged PATCHES/V3.4.6 to V3.4-BUG-FIX 39437: ALF-15458 / ALF-15184: ADMLuceneIndexerImpl debug can cause indexing to fail - Don't try to print the path of a deleted node! 39520: Merged DEV to PATCHES/V3.4.6 38728: ALF-15459 / ALF-14714 : A user can overwrite a "WRITE_LOCK" on a document created by a different user -The document owner is not considered to be the lock owner now. -ALF-12081 was backported. 39581: ALF-15460 / ALF-15216: Need predefined JGroups configuration for FILE_PING - Now FILE_PING can be selected using alfresco.jgroups.defaultProtocol=TCP-FPING - New parameter alfresco.fping.shared.dir specifies its shared directory and defaults to ${dir.contentstore} 39662: ALF-15461 / ALF-15243: "Failed to initialise config service" after a node comes back into the cluster - Nested writable transaction in a read only transaction - Removed old school transaction management 39768: ALF-15462 / ALF-10725: Account for local index impact of reparenting orphaned nodes - Unfortunately this means AbstractNodeDAOImpl now must talk to NodeIndexer but this may be revisited 39770: ALF-15462 / ALF-10725: Fix test failure - an orphaned node WITH the root aspect must still have parents or it is unindexable! 39816: ALF-15462 / ALF-10725: Revisit orphans once more - delete_ChildAssocsToAndFrom removed because it's evil and could orphan a node that's just shown up (read committed) from another transaction - Now only parent assocs of the deleted node are removed automatically and children are handled through normal cascading operations - The foreign keys will now block the deletion of a node with a new child created mid-transaction 39846: ALF-15461 / ALF-15243: Fix unit test failures 40253: Merged PATCHES/V3.4.9 to V3.4.-BUG-FIX 39703: ALF-15463: More synchronization, TRACE logging and test for ALF-15215: Missing synchronization in RepositoryContainer.getRegistry() 39885: ALF-15464 / ALF-15311: JGroups resends incorrect message for XMIT_REQ - Added new configuration files for heartbeat channel that removes NAKACK protocol as guaranteed delivery is not necessary for heartbeat. 40262: Merged V3.4-BUG-FIX to V4.1-BUG-FIX (RECORD ONLY) 36853: Merge DEV to V3.4-BUG-FIX 31272 : ALF-8588 - IMAP Cannot attach two attachments with the same name. 38923: Merged HEAD to BRANCHES/DEV/V3.4-BUG-FIX 32757: Fix for ALF-9365 Merged BRANCHES/DEV/V4.0-BUG-FIX to BRANCHES/DEV/V3.4-BUG-FIX 35693: Fix for ALF-13806 - Get content webscript incorrectly returns text/plain mimetype for HTML files, not text/html Merged BRANCHES/V4.0 to BRANCHES/DEV/V3.4-BUG-FIX 36560: Correctly size content length header after HTML stripping process (ALF-9365) 39015: Merged in upgrade of truezip to 7.5.5 see ALF-14247 39056: Merged V4.1-BUG-FIX to V3.4-BUG-FIX: ALF-15053: Ensure that sub-folders of "res" can be accessed in the DocLib 39361: Added truezip-swing jar. It seems that Truezip needs Swing :( git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@40274 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
644 lines
26 KiB
Java
644 lines
26 KiB
Java
/*
|
|
* 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.node.db;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
import javax.transaction.UserTransaction;
|
|
|
|
import org.alfresco.model.ContentModel;
|
|
import org.alfresco.repo.domain.node.NodeDAO;
|
|
import org.alfresco.repo.domain.node.Transaction;
|
|
import org.alfresco.repo.node.BaseNodeServiceTest;
|
|
import org.alfresco.repo.node.cleanup.NodeCleanupRegistry;
|
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
|
import org.alfresco.repo.transaction.TransactionListenerAdapter;
|
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
|
import org.alfresco.service.cmr.repository.MLText;
|
|
import org.alfresco.service.cmr.repository.NodeRef;
|
|
import org.alfresco.service.cmr.repository.NodeService;
|
|
import org.alfresco.service.namespace.QName;
|
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
|
import org.alfresco.service.transaction.TransactionService;
|
|
import org.springframework.extensions.surf.util.I18NUtil;
|
|
|
|
/**
|
|
* @see org.alfresco.repo.node.db.DbNodeServiceImpl
|
|
*
|
|
* @author Derek Hulley
|
|
*/
|
|
@SuppressWarnings("unused")
|
|
public class DbNodeServiceImplTest extends BaseNodeServiceTest
|
|
{
|
|
private TransactionService txnService;
|
|
private NodeDAO nodeDAO;
|
|
private DictionaryService dictionaryService;
|
|
|
|
protected NodeService getNodeService()
|
|
{
|
|
// Force cascading
|
|
DbNodeServiceImpl dbNodeServiceImpl = (DbNodeServiceImpl) applicationContext.getBean("dbNodeServiceImpl");
|
|
|
|
return (NodeService) applicationContext.getBean("dbNodeService");
|
|
}
|
|
|
|
@Override
|
|
protected void onSetUpInTransaction() throws Exception
|
|
{
|
|
super.onSetUpInTransaction();
|
|
txnService = (TransactionService) applicationContext.getBean("transactionComponent");
|
|
nodeDAO = (NodeDAO) applicationContext.getBean("nodeDAO");
|
|
dictionaryService = (DictionaryService) applicationContext.getBean("dictionaryService");
|
|
}
|
|
|
|
/**
|
|
* Manually trigger the cleanup registry
|
|
*/
|
|
public void testNodeCleanupRegistry() throws Exception
|
|
{
|
|
setComplete();
|
|
endTransaction();
|
|
NodeCleanupRegistry cleanupRegistry = (NodeCleanupRegistry) applicationContext.getBean("nodeCleanupRegistry");
|
|
cleanupRegistry.doClean();
|
|
}
|
|
|
|
/**
|
|
* <a href="https://issues.alfresco.com/jira/browse/ALF-14929">ALF-14929</a>
|
|
*/
|
|
public synchronized void testTxnCommitTime() throws Exception
|
|
{
|
|
/*
|
|
* This test is subject to intermittent - but correct - failures if bug ALF-14929 is present
|
|
*/
|
|
|
|
String currentTxn = AlfrescoTransactionSupport.getTransactionId();
|
|
assertNotNull("Must have a txn change UUID for all transactions.");
|
|
|
|
long start = System.currentTimeMillis();
|
|
this.wait(10L);
|
|
|
|
// The listener
|
|
final TestTxnCommitTimeTxnListener listener = new TestTxnCommitTimeTxnListener();
|
|
AlfrescoTransactionSupport.bindListener(listener);
|
|
|
|
// First see what the latest transaction is
|
|
long currentTxnCommitTime = listener.getTxnCommitTime(currentTxn, start);
|
|
assertEquals("Should not have found a written txn", 0L, currentTxnCommitTime);
|
|
|
|
// Now commit
|
|
setComplete();
|
|
endTransaction();
|
|
|
|
// Now check again. The transaction time must be greater than the last time that
|
|
// the listener wrote through.
|
|
long recordedCommitTimeMs = listener.getTxnCommitTime(currentTxn, start);
|
|
assertTrue(
|
|
"DAO txn write time must be greater than last listener write time",
|
|
recordedCommitTimeMs > listener.lastWriteTime);
|
|
}
|
|
|
|
/**
|
|
* @see DbNodeServiceImplTest#testTxnCommitTime()
|
|
*/
|
|
private class TestTxnCommitTimeTxnListener extends TransactionListenerAdapter
|
|
{
|
|
/*
|
|
* Note: equals hides this instance when listeners are processed
|
|
*/
|
|
private String txnIdStr;
|
|
private long lastWriteTime = 0L;
|
|
|
|
@Override
|
|
public boolean equals(Object obj)
|
|
{
|
|
return false;
|
|
}
|
|
@Override
|
|
public synchronized void beforeCommit(boolean readOnly)
|
|
{
|
|
if (txnIdStr == null)
|
|
{
|
|
txnIdStr = AlfrescoTransactionSupport.getTransactionId();
|
|
// Make a change
|
|
nodeService.setProperty(rootNodeRef, ContentModel.PROP_COUNTER, new Integer(5));
|
|
// Reschedule for removal
|
|
AlfrescoTransactionSupport.bindListener(this);
|
|
}
|
|
else
|
|
{
|
|
nodeService.removeProperty(rootNodeRef, ContentModel.PROP_COUNTER);
|
|
}
|
|
lastWriteTime = System.currentTimeMillis();
|
|
// We wait a bit so that the time differences are significant
|
|
try { this.wait(20L); } catch (InterruptedException e) {}
|
|
}
|
|
public long getTxnCommitTime(String txnId, long fromTime)
|
|
{
|
|
List<Transaction> startTxns = nodeDAO.getTxnsByCommitTimeAscending(fromTime, null, Integer.MAX_VALUE, null, false);
|
|
long time = 0L;
|
|
for (Transaction txn : startTxns)
|
|
{
|
|
if (txnId.equals(txn.getChangeTxnId()))
|
|
{
|
|
// Found our transaction
|
|
time = txn.getCommitTimeMs();
|
|
}
|
|
}
|
|
return time;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Deletes a child node and then iterates over the children of the parent node,
|
|
* getting the QName. This caused some issues after we did some optimization
|
|
* using lazy loading of the associations.
|
|
*/
|
|
public void testLazyLoadIssue() throws Exception
|
|
{
|
|
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph();
|
|
// commit results
|
|
setComplete();
|
|
endTransaction();
|
|
|
|
UserTransaction userTransaction = txnService.getUserTransaction();
|
|
|
|
try
|
|
{
|
|
userTransaction.begin();
|
|
|
|
ChildAssociationRef n6pn8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8"));
|
|
NodeRef n6Ref = n6pn8Ref.getParentRef();
|
|
NodeRef n8Ref = n6pn8Ref.getChildRef();
|
|
|
|
// delete n8
|
|
nodeService.deleteNode(n8Ref);
|
|
|
|
// get the parent children
|
|
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(n6Ref);
|
|
for (ChildAssociationRef assoc : assocs)
|
|
{
|
|
// just checking
|
|
}
|
|
|
|
userTransaction.commit();
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
try { userTransaction.rollback(); } catch (IllegalStateException ee) {}
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Checks that the node status changes correctly during:
|
|
* <ul>
|
|
* <li>creation</li>
|
|
* <li>property changes</li>
|
|
* <li>aspect changes</li>
|
|
* <li>moving</li>
|
|
* <li>deletion</li>
|
|
* </ul>
|
|
*/
|
|
public void testNodeStatus() throws Throwable
|
|
{
|
|
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph();
|
|
// get the node to play with
|
|
ChildAssociationRef n6pn8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8"));
|
|
final NodeRef n6Ref = n6pn8Ref.getParentRef();
|
|
final NodeRef n8Ref = n6pn8Ref.getChildRef();
|
|
final Map<QName, Serializable> properties = nodeService.getProperties(n6Ref);
|
|
|
|
// commit results
|
|
setComplete();
|
|
endTransaction();
|
|
|
|
// change property - check status
|
|
RetryingTransactionCallback<Object> changePropertiesWork = new RetryingTransactionCallback<Object>()
|
|
{
|
|
public Object execute()
|
|
{
|
|
nodeService.setProperty(n6Ref, ContentModel.PROP_CREATED, new Date());
|
|
return null;
|
|
}
|
|
};
|
|
executeAndCheck(n6Ref, changePropertiesWork);
|
|
|
|
// add an aspect
|
|
RetryingTransactionCallback<Object> addAspectWork = new RetryingTransactionCallback<Object>()
|
|
{
|
|
public Object execute()
|
|
{
|
|
nodeService.addAspect(n6Ref, ASPECT_QNAME_TEST_MARKER, null);
|
|
return null;
|
|
}
|
|
};
|
|
executeAndCheck(n6Ref, addAspectWork);
|
|
|
|
// remove an aspect
|
|
RetryingTransactionCallback<Object> removeAspectWork = new RetryingTransactionCallback<Object>()
|
|
{
|
|
public Object execute()
|
|
{
|
|
nodeService.removeAspect(n6Ref, ASPECT_QNAME_TEST_MARKER);
|
|
return null;
|
|
}
|
|
};
|
|
executeAndCheck(n6Ref, removeAspectWork);
|
|
|
|
// move the node
|
|
RetryingTransactionCallback<Object> moveNodeWork = new RetryingTransactionCallback<Object>()
|
|
{
|
|
public Object execute()
|
|
{
|
|
nodeService.moveNode(
|
|
n6Ref,
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName(NAMESPACE, "moved"));
|
|
return null;
|
|
}
|
|
};
|
|
executeAndCheck(n6Ref, moveNodeWork);
|
|
|
|
// delete the node
|
|
RetryingTransactionCallback<Object> deleteNodeWork = new RetryingTransactionCallback<Object>()
|
|
{
|
|
public Object execute()
|
|
{
|
|
nodeService.deleteNode(n6Ref);
|
|
return null;
|
|
}
|
|
};
|
|
executeAndCheck(n6Ref, deleteNodeWork);
|
|
|
|
// check cascade-deleted nodes
|
|
RetryingTransactionCallback<Object> checkCascadeCallback = new RetryingTransactionCallback<Object>()
|
|
{
|
|
public Object execute()
|
|
{
|
|
// check n6
|
|
NodeRef.Status n6Status = nodeDAO.getNodeRefStatus(n6Ref);
|
|
if (!n6Status.isDeleted())
|
|
{
|
|
throw new RuntimeException("Deleted node does not have deleted status");
|
|
}
|
|
// n8 is a primary child - it should be deleted too
|
|
NodeRef.Status n8Status = nodeDAO.getNodeRefStatus(n8Ref);
|
|
if (!n8Status.isDeleted())
|
|
{
|
|
throw new RuntimeException("Cascade-deleted node does not have deleted status");
|
|
}
|
|
return null;
|
|
}
|
|
};
|
|
retryingTransactionHelper.doInTransaction(checkCascadeCallback);
|
|
|
|
// check node recreation
|
|
RetryingTransactionCallback<Object> checkRecreateCallback = new RetryingTransactionCallback<Object>()
|
|
{
|
|
public Object execute()
|
|
{
|
|
properties.put(ContentModel.PROP_STORE_PROTOCOL, n6Ref.getStoreRef().getProtocol());
|
|
properties.put(ContentModel.PROP_STORE_IDENTIFIER, n6Ref.getStoreRef().getIdentifier());
|
|
properties.put(ContentModel.PROP_NODE_UUID, n6Ref.getId());
|
|
|
|
// recreate n6
|
|
nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName(NAMESPACE, "recreated-n6"),
|
|
ContentModel.TYPE_CONTAINER,
|
|
properties);
|
|
return null;
|
|
}
|
|
};
|
|
retryingTransactionHelper.doInTransaction(checkRecreateCallback);
|
|
}
|
|
|
|
private void executeAndCheck(NodeRef nodeRef, RetryingTransactionCallback<Object> callback) throws Throwable
|
|
{
|
|
UserTransaction txn = txnService.getUserTransaction();
|
|
txn.begin();
|
|
|
|
NodeRef.Status currentStatus = nodeService.getNodeStatus(nodeRef);
|
|
assertNotNull(currentStatus);
|
|
String currentTxnId = AlfrescoTransactionSupport.getTransactionId();
|
|
assertNotNull(currentTxnId);
|
|
assertNotSame(currentTxnId, currentStatus.getChangeTxnId());
|
|
try
|
|
{
|
|
callback.execute();
|
|
// get the status
|
|
NodeRef.Status newStatus = nodeService.getNodeStatus(nodeRef);
|
|
assertNotNull(newStatus);
|
|
// check
|
|
assertEquals("Change didn't update status", currentTxnId, newStatus.getChangeTxnId());
|
|
txn.commit();
|
|
}
|
|
catch (Throwable e)
|
|
{
|
|
try { txn.rollback(); } catch (Throwable ee) {}
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
public void testMLTextValues() throws Exception
|
|
{
|
|
// Set the server default locale
|
|
Locale.setDefault(Locale.ENGLISH);
|
|
|
|
MLText mlTextProperty = new MLText();
|
|
mlTextProperty.addValue(Locale.ENGLISH, "Very good!");
|
|
mlTextProperty.addValue(Locale.FRENCH, "Très bon!");
|
|
mlTextProperty.addValue(Locale.GERMAN, "Sehr gut!");
|
|
|
|
nodeService.setProperty(
|
|
rootNodeRef,
|
|
BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE,
|
|
mlTextProperty);
|
|
|
|
// Check unfiltered property retrieval
|
|
Serializable textValueDirect = nodeService.getProperty(
|
|
rootNodeRef,
|
|
BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE);
|
|
assertEquals(
|
|
"MLText type not returned direct",
|
|
mlTextProperty,
|
|
textValueDirect);
|
|
|
|
// Check unfiltered mass property retrieval
|
|
Map<QName, Serializable> propertiesDirect = nodeService.getProperties(rootNodeRef);
|
|
assertEquals(
|
|
"MLText type not returned direct in Map",
|
|
mlTextProperty,
|
|
propertiesDirect.get(BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE));
|
|
}
|
|
|
|
/**
|
|
* Ensure that plain strings going into MLText properties is handled
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
public void testStringIntoMLTextProperty() throws Exception
|
|
{
|
|
String text = "Hello";
|
|
nodeService.setProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE, text);
|
|
Serializable mlTextCheck = nodeService.getProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE);
|
|
assertTrue("Plain string insertion should be returned as MLText", mlTextCheck instanceof MLText);
|
|
Locale defaultLocale = I18NUtil.getLocale();
|
|
MLText mlTextCheck2 = (MLText) mlTextCheck;
|
|
String mlTextDefaultCheck = mlTextCheck2.getDefaultValue();
|
|
assertEquals("Default MLText value was not set correctly", text, mlTextDefaultCheck);
|
|
|
|
// Reset the property
|
|
nodeService.setProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE, null);
|
|
Serializable nullValueCheck = nodeService.getProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE);
|
|
|
|
// Now, just pass a String in
|
|
nodeService.setProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE, text);
|
|
// Now update the property with some MLText
|
|
MLText mlText = new MLText();
|
|
mlText.addValue(Locale.ENGLISH, "Very good!");
|
|
mlText.addValue(Locale.FRENCH, "Très bon!");
|
|
mlText.addValue(Locale.GERMAN, "Sehr gut!");
|
|
nodeService.setProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE, mlText);
|
|
// Get it back and check
|
|
mlTextCheck = nodeService.getProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE);
|
|
assertEquals("Setting of MLText over String failed.", mlText, mlTextCheck);
|
|
}
|
|
|
|
/**
|
|
* Ensure that plain strings going into MLText properties is handled
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
public void testSingleStringMLTextProperty() throws Exception
|
|
{
|
|
// Set the property with single-value MLText
|
|
MLText mlText = new MLText();
|
|
mlText.addValue(Locale.GERMAN, "Sehr gut!");
|
|
nodeService.setProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE, mlText);
|
|
// Get it back and check
|
|
MLText mlTextCheck = (MLText) nodeService.getProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE);
|
|
assertEquals("Setting of MLText over String failed.", mlText, mlTextCheck);
|
|
}
|
|
|
|
/**
|
|
* It would appear that an issue has arisen with creating and deleting nodes
|
|
* in the same transaction.
|
|
*/
|
|
public void testInTransactionCreateAndDelete() throws Exception
|
|
{
|
|
// Create a node
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName(NAMESPACE, this.getName()),
|
|
TYPE_QNAME_TEST_CONTENT).getChildRef();
|
|
// Delete the node
|
|
nodeService.deleteNode(nodeRef);
|
|
}
|
|
|
|
public void testAspectRemovalWithCommit() throws Throwable
|
|
{
|
|
// Create a node to add the aspect to
|
|
NodeRef sourceNodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "testAspectRemoval-source"),
|
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
|
|
|
// Create a target for the associations
|
|
NodeRef targetNodeRef = nodeService.createNode(
|
|
rootNodeRef,
|
|
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "testAspectRemoval-target"),
|
|
ContentModel.TYPE_CONTAINER).getChildRef();
|
|
|
|
// Add the aspect to the source
|
|
nodeService.addAspect(sourceNodeRef, ASPECT_WITH_ASSOCIATIONS, null);
|
|
// Make the associations
|
|
nodeService.addChild(
|
|
sourceNodeRef,
|
|
targetNodeRef,
|
|
ASSOC_ASPECT_CHILD_ASSOC,
|
|
QName.createQName(NAMESPACE, "aspect-child"));
|
|
nodeService.createAssociation(sourceNodeRef, targetNodeRef, ASSOC_ASPECT_NORMAL_ASSOC);
|
|
|
|
// Check that the correct associations are present
|
|
assertEquals("Expected exactly one child",
|
|
1, nodeService.getChildAssocs(sourceNodeRef).size());
|
|
assertEquals("Expected exactly one target",
|
|
1, nodeService.getTargetAssocs(sourceNodeRef, RegexQNamePattern.MATCH_ALL).size());
|
|
|
|
// Force a commit here
|
|
setComplete();
|
|
endTransaction();
|
|
|
|
// start another transaction to remove the aspect
|
|
UserTransaction txn = txnService.getUserTransaction();
|
|
txn.begin();
|
|
|
|
try
|
|
{
|
|
Set<QName> aspects = nodeService.getAspects(sourceNodeRef);
|
|
int noAspectsBefore = aspects.size();
|
|
|
|
// Now remove the aspect
|
|
nodeService.removeAspect(sourceNodeRef, ASPECT_WITH_ASSOCIATIONS);
|
|
|
|
// Check that the associations were removed
|
|
assertEquals("Expected exactly zero child",
|
|
0, nodeService.getChildAssocs(sourceNodeRef).size());
|
|
assertEquals("Expected exactly zero target",
|
|
0, nodeService.getTargetAssocs(sourceNodeRef, RegexQNamePattern.MATCH_ALL).size());
|
|
aspects = nodeService.getAspects(sourceNodeRef);
|
|
assertEquals("Expected exactly one less aspect",
|
|
noAspectsBefore-1, aspects.size());
|
|
|
|
txn.commit();
|
|
}
|
|
catch (Throwable e)
|
|
{
|
|
try { txn.rollback(); } catch (Throwable ee) {}
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test Get Child Assocs By Property Value
|
|
* @throws Exception
|
|
*/
|
|
public void testGetChildAssocsByPropertyValue() throws Exception
|
|
{
|
|
Map<QName, ChildAssociationRef> assocRefs;
|
|
|
|
assocRefs = buildNodeGraph();
|
|
|
|
ChildAssociationRef rootRef = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "root"));
|
|
ChildAssociationRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "root_p_n1"));
|
|
ChildAssociationRef n2Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "root_p_n2"));
|
|
|
|
/**
|
|
* Positive test - get n1 and n2 by the value of a text property in this case PROP_SUBJECT which
|
|
* contains "Hello World"
|
|
*/
|
|
{
|
|
NodeRef parentNodeRef = n1Ref.getParentRef();
|
|
NodeRef childNodeRef = n1Ref.getChildRef();
|
|
assertTrue(nodeService.exists(parentNodeRef));
|
|
assertTrue(nodeService.exists(childNodeRef));
|
|
|
|
String subject = "Hello World";
|
|
nodeService.setProperty(n1Ref.getChildRef(), ContentModel.PROP_SUBJECT, subject);
|
|
List<ChildAssociationRef> refs = nodeService.getChildAssocsByPropertyValue(parentNodeRef, ContentModel.PROP_SUBJECT, subject);
|
|
assertTrue("failed to read one assoc", refs.size() == 1);
|
|
assertTrue("content not correct", refs.contains(n1Ref));
|
|
|
|
// Now go for another two documents.
|
|
nodeService.setProperty(n2Ref.getChildRef(), ContentModel.PROP_SUBJECT, subject);
|
|
refs = nodeService.getChildAssocsByPropertyValue(parentNodeRef, ContentModel.PROP_SUBJECT, subject);
|
|
assertTrue("failed to read two assocs", refs.size() == 2);
|
|
assertTrue("content not correct", refs.contains(n1Ref));
|
|
assertTrue("content not correct", refs.contains(n2Ref));
|
|
}
|
|
|
|
/**
|
|
* Positive tests of various types that should be accepted by the query
|
|
*/
|
|
{
|
|
NodeRef parentNodeRef = n1Ref.getParentRef();
|
|
NodeRef childNodeRef = n1Ref.getChildRef();
|
|
assertTrue(nodeService.exists(parentNodeRef));
|
|
assertTrue(nodeService.exists(childNodeRef));
|
|
|
|
// integer
|
|
int count = 123;
|
|
nodeService.setProperty(n1Ref.getChildRef(), ContentModel.PROP_COUNTER, count);
|
|
List<ChildAssociationRef> refs = nodeService.getChildAssocsByPropertyValue(parentNodeRef, ContentModel.PROP_COUNTER, count);
|
|
assertTrue("failed to read one assoc", refs.size() == 1);
|
|
assertTrue("content not correct", refs.contains(n1Ref));
|
|
|
|
// Double
|
|
Double alfLat = new Double(51.5216666);
|
|
Double alfLon = new Double(0.43);
|
|
nodeService.setProperty(n1Ref.getChildRef(), ContentModel.PROP_LATITUDE, alfLat);
|
|
refs = nodeService.getChildAssocsByPropertyValue(parentNodeRef, ContentModel.PROP_LATITUDE, alfLat);
|
|
assertTrue("failed to read one assoc", refs.size() == 1);
|
|
assertTrue("content not correct", refs.contains(n1Ref));
|
|
|
|
// float
|
|
// not implemeted due to float precision issues with float equals.
|
|
//float score = 1.3f;
|
|
//nodeService.setProperty(n1Ref.getChildRef(), ContentModel.PROP_RATING_SCORE, score);
|
|
//refs = nodeService.getChildAssocsByPropertyValue(parentNodeRef, ContentModel.PROP_RATING_SCORE, score);
|
|
//assertTrue("failed to read one assoc", refs.size() == 1);
|
|
//assertTrue("content not correct", refs.contains(n1Ref));
|
|
|
|
// Boolean TRUE
|
|
Boolean beauty = Boolean.TRUE;
|
|
nodeService.setProperty(n1Ref.getChildRef(), ContentModel.PROP_ENABLED, beauty);
|
|
assertTrue((Boolean)nodeService.getProperty(n1Ref.getChildRef(), ContentModel.PROP_ENABLED));
|
|
refs = nodeService.getChildAssocsByPropertyValue(parentNodeRef, ContentModel.PROP_ENABLED, beauty);
|
|
assertTrue("failed to read one assoc", refs.size() == 1);
|
|
assertTrue("content not correct", refs.contains(n1Ref));
|
|
|
|
// Boolean FALSE
|
|
beauty = Boolean.FALSE;
|
|
nodeService.setProperty(n1Ref.getChildRef(), ContentModel.PROP_ENABLED, beauty);
|
|
assertTrue(!(Boolean)nodeService.getProperty(n1Ref.getChildRef(), ContentModel.PROP_ENABLED));
|
|
refs = nodeService.getChildAssocsByPropertyValue(parentNodeRef, ContentModel.PROP_ENABLED, beauty);
|
|
assertTrue("failed to read one assoc", refs.size() == 1);
|
|
|
|
}
|
|
|
|
/**
|
|
* Negative test - invalid to search on sys:node-dbid
|
|
*/
|
|
try
|
|
{
|
|
List<ChildAssociationRef> refs = nodeService.getChildAssocsByPropertyValue(n1Ref.getParentRef(), ContentModel.PROP_NODE_DBID, "Fail");
|
|
fail("sys:node-dbid not rejected");
|
|
}
|
|
catch (IllegalArgumentException ie)
|
|
{
|
|
// expect to go here
|
|
}
|
|
|
|
/**
|
|
* Negative test - invalid to search on type MLText
|
|
*/
|
|
try
|
|
{
|
|
Serializable title = (String)nodeService.getProperty(n1Ref.getChildRef(), ContentModel.PROP_TITLE);
|
|
List<ChildAssociationRef> refs = nodeService.getChildAssocsByPropertyValue(n1Ref.getParentRef(), ContentModel.PROP_NAME, title);
|
|
fail("MLText type not rejected");
|
|
}
|
|
catch (IllegalArgumentException ie)
|
|
{
|
|
// expect to go here
|
|
}
|
|
}
|
|
}
|