mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V2.9 to HEAD
9846: Merged V2.2 to V2.9 9805: Merged V2.1 to V2.2 9450: WCM - fix minor typo 9456: Added direct QName child node handling test 9462: ACT-759 - nested forks issue. 9495: Lowered thread priority for index merge threads to default 5 9534: Fixed ETWOONE-242: ContentMetadataExtracter can optionally ditch unextracted aspect-linked properties 9559: Fixed SDK classpath 9560: Fix ETWOONE-241 9583: Fix for ETWOONE-250 (FacesContext null issue when authenticating via a ticket or guest auth) 9592: (ALREADY ON HEAD) 9709: Upgrade commons pool git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10607 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -338,6 +338,9 @@
|
|||||||
<value>{http://www.alfresco.org/model/content/1.0}content</value>
|
<value>{http://www.alfresco.org/model/content/1.0}content</value>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="carryAspectProperties">
|
||||||
|
<value>true</value>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="import" class="org.alfresco.repo.action.executer.ImporterActionExecuter" parent="action-executer">
|
<bean id="import" class="org.alfresco.repo.action.executer.ImporterActionExecuter" parent="action-executer">
|
||||||
|
@@ -488,7 +488,7 @@
|
|||||||
<value>20</value>
|
<value>20</value>
|
||||||
</property>
|
</property>
|
||||||
<property name="threadPriority">
|
<property name="threadPriority">
|
||||||
<value>7</value>
|
<value>5</value>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
@@ -53,6 +53,9 @@
|
|||||||
<property name="metadataExtracterRegistry">
|
<property name="metadataExtracterRegistry">
|
||||||
<ref bean="avmMetadataExtracterRegistry" />
|
<ref bean="avmMetadataExtracterRegistry" />
|
||||||
</property>
|
</property>
|
||||||
|
<property name="carryAspectProperties">
|
||||||
|
<value>true</value>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
@@ -56,14 +56,18 @@ import org.alfresco.service.namespace.QName;
|
|||||||
*/
|
*/
|
||||||
public class ContentMetadataExtracter extends ActionExecuterAbstractBase
|
public class ContentMetadataExtracter extends ActionExecuterAbstractBase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The node service
|
|
||||||
*/
|
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
private ContentService contentService;
|
||||||
|
private DictionaryService dictionaryService;
|
||||||
|
private MetadataExtracterRegistry metadataExtracterRegistry;
|
||||||
|
private boolean carryAspectProperties;
|
||||||
|
|
||||||
|
public ContentMetadataExtracter()
|
||||||
|
{
|
||||||
|
carryAspectProperties = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the node service
|
|
||||||
*
|
|
||||||
* @param nodeService the node service
|
* @param nodeService the node service
|
||||||
*/
|
*/
|
||||||
public void setNodeService(NodeService nodeService)
|
public void setNodeService(NodeService nodeService)
|
||||||
@@ -71,11 +75,6 @@ public class ContentMetadataExtracter extends ActionExecuterAbstractBase
|
|||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Our content service
|
|
||||||
*/
|
|
||||||
private ContentService contentService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param contentService The contentService to set.
|
* @param contentService The contentService to set.
|
||||||
*/
|
*/
|
||||||
@@ -84,11 +83,6 @@ public class ContentMetadataExtracter extends ActionExecuterAbstractBase
|
|||||||
this.contentService = contentService;
|
this.contentService = contentService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The dictionary service
|
|
||||||
*/
|
|
||||||
private DictionaryService dictionaryService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dictService The DictionaryService to set.
|
* @param dictService The DictionaryService to set.
|
||||||
*/
|
*/
|
||||||
@@ -97,11 +91,6 @@ public class ContentMetadataExtracter extends ActionExecuterAbstractBase
|
|||||||
this.dictionaryService = dictService;
|
this.dictionaryService = dictService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Our Extracter
|
|
||||||
*/
|
|
||||||
private MetadataExtracterRegistry metadataExtracterRegistry;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param metadataExtracterRegistry The metadataExtracterRegistry to set.
|
* @param metadataExtracterRegistry The metadataExtracterRegistry to set.
|
||||||
*/
|
*/
|
||||||
@@ -110,6 +99,18 @@ public class ContentMetadataExtracter extends ActionExecuterAbstractBase
|
|||||||
this.metadataExtracterRegistry = metadataExtracterRegistry;
|
this.metadataExtracterRegistry = metadataExtracterRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not aspect-related properties must be carried to the new version of the node
|
||||||
|
*
|
||||||
|
* @param carryAspectProperties <tt>true</tt> (default) to carry all aspect-linked
|
||||||
|
* properties forward. <tt>false</tt> will clean the
|
||||||
|
* aspect of any unextracted values.
|
||||||
|
*/
|
||||||
|
public void setCarryAspectProperties(boolean carryAspectProperties)
|
||||||
|
{
|
||||||
|
this.carryAspectProperties = carryAspectProperties;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.action.executer.ActionExecuter#execute(org.alfresco.service.cmr.repository.NodeRef,
|
* @see org.alfresco.repo.action.executer.ActionExecuter#execute(org.alfresco.service.cmr.repository.NodeRef,
|
||||||
* NodeRef)
|
* NodeRef)
|
||||||
@@ -155,6 +156,7 @@ public class ContentMetadataExtracter extends ActionExecuterAbstractBase
|
|||||||
|
|
||||||
// Check that all properties have the appropriate aspect applied
|
// Check that all properties have the appropriate aspect applied
|
||||||
Set<QName> requiredAspectQNames = new HashSet<QName>(3);
|
Set<QName> requiredAspectQNames = new HashSet<QName>(3);
|
||||||
|
Set<QName> aspectPropertyQNames = new HashSet<QName>(17);
|
||||||
|
|
||||||
for (QName propertyQName : modifiedProperties.keySet())
|
for (QName propertyQName : modifiedProperties.keySet())
|
||||||
{
|
{
|
||||||
@@ -169,6 +171,21 @@ public class ContentMetadataExtracter extends ActionExecuterAbstractBase
|
|||||||
{
|
{
|
||||||
QName aspectQName = propertyContainerDef.getName();
|
QName aspectQName = propertyContainerDef.getName();
|
||||||
requiredAspectQNames.add(aspectQName);
|
requiredAspectQNames.add(aspectQName);
|
||||||
|
// Get all properties associated with the aspect
|
||||||
|
Set<QName> aspectProperties = propertyContainerDef.getProperties().keySet();
|
||||||
|
aspectPropertyQNames.addAll(aspectProperties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!carryAspectProperties)
|
||||||
|
{
|
||||||
|
// Remove any node properties that are defined on the aspects but were not extracted
|
||||||
|
for (QName aspectPropertyQName : aspectPropertyQNames)
|
||||||
|
{
|
||||||
|
if (!modifiedProperties.containsKey(aspectPropertyQName))
|
||||||
|
{
|
||||||
|
nodeProperties.remove(aspectPropertyQName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -78,6 +78,7 @@ import org.alfresco.service.transaction.TransactionService;
|
|||||||
import org.alfresco.util.BaseSpringTest;
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.PropertyMap;
|
import org.alfresco.util.PropertyMap;
|
||||||
|
import org.apache.commons.collections.map.SingletonMap;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
@@ -679,6 +680,95 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
|
|||||||
0, nodeService.getTargetAssocs(sourceNodeRef, RegexQNamePattern.MATCH_ALL).size());
|
0, nodeService.getTargetAssocs(sourceNodeRef, RegexQNamePattern.MATCH_ALL).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final QName ASPECT_QNAME_TEST_RENDERED = QName.createQName(NAMESPACE, "rendered");
|
||||||
|
private static final QName ASSOC_TYPE_QNAME_TEST_RENDITION = QName.createQName(NAMESPACE, "rendition-page");
|
||||||
|
private static final QName TYPE_QNAME_TEST_RENDITION_PAGE = QName.createQName(NAMESPACE, "rendition-page");
|
||||||
|
private static final QName PROP_QNAME_TEST_RENDITION_PAGE_CONTENT = QName.createQName(NAMESPACE, "rendition-page-content");
|
||||||
|
public void testAspectWithChildAssociationsCreationAndRetrieval() throws Exception
|
||||||
|
{
|
||||||
|
// Create a folder. This is like the user's home folder, say.
|
||||||
|
NodeRef folderNodeRef = nodeService.createNode(
|
||||||
|
rootNodeRef,
|
||||||
|
ContentModel.ASSOC_CHILDREN,
|
||||||
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "UserX-" + GUID.generate()),
|
||||||
|
ContentModel.TYPE_FOLDER).getChildRef();
|
||||||
|
// Create a document. This is the actual document uploaded by the user.
|
||||||
|
NodeRef fileNodeRef = nodeService.createNode(
|
||||||
|
folderNodeRef,
|
||||||
|
ContentModel.ASSOC_CONTAINS,
|
||||||
|
QName.createQName(BaseNodeServiceTest.NAMESPACE, "Uploaded.pdf"),
|
||||||
|
ContentModel.TYPE_FOLDER).getChildRef();
|
||||||
|
// So, thus far, this is exactly what you have. Now for the bit to add some renditions.
|
||||||
|
// First, we can make some content data pages - spoofed, of course
|
||||||
|
List<ContentData> renditionContentPages = new ArrayList<ContentData>(20);
|
||||||
|
// This loop is where you will, outside of the transaction, push the page content into the repo
|
||||||
|
for(int i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
ContentData contentData = new ContentData(null, MimetypeMap.MIMETYPE_PDF, 10245, "UTF-8");
|
||||||
|
renditionContentPages.add(contentData);
|
||||||
|
}
|
||||||
|
|
||||||
|
nodeService.addAspect(fileNodeRef, ASPECT_QNAME_TEST_RENDERED, null);
|
||||||
|
int pageNumber = 0;
|
||||||
|
for (ContentData renditionContentPage : renditionContentPages)
|
||||||
|
{
|
||||||
|
pageNumber++;
|
||||||
|
QName renditionQName = makePageAssocName(pageNumber);
|
||||||
|
Map<QName, Serializable> properties = Collections.singletonMap(
|
||||||
|
PROP_QNAME_TEST_RENDITION_PAGE_CONTENT,
|
||||||
|
(Serializable) renditionContentPage);
|
||||||
|
nodeService.createNode(
|
||||||
|
fileNodeRef,
|
||||||
|
ASSOC_TYPE_QNAME_TEST_RENDITION,
|
||||||
|
renditionQName,
|
||||||
|
TYPE_QNAME_TEST_RENDITION_PAGE,
|
||||||
|
properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
// That's it for uploading. Now we retrieve them.
|
||||||
|
if (!nodeService.hasAspect(fileNodeRef, ASPECT_QNAME_TEST_RENDERED))
|
||||||
|
{
|
||||||
|
// Jump to the original rendition retrieval code
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// It has the aspect, so it's the new model
|
||||||
|
List<ChildAssociationRef> fetchedRenditionChildAssocs = nodeService.getChildAssocs(
|
||||||
|
fileNodeRef,
|
||||||
|
ASSOC_TYPE_QNAME_TEST_RENDITION,
|
||||||
|
RegexQNamePattern.MATCH_ALL);
|
||||||
|
assertEquals(
|
||||||
|
"We didn't get the correct number of pages back",
|
||||||
|
renditionContentPages.size(),
|
||||||
|
fetchedRenditionChildAssocs.size());
|
||||||
|
// Get page ... 5. This is to prove that they are ordered.
|
||||||
|
ChildAssociationRef fetchedRenditionChildAssoc5 = fetchedRenditionChildAssocs.get(4);
|
||||||
|
QName page5QName = makePageAssocName(5);
|
||||||
|
assertEquals(
|
||||||
|
"Local name of page 5 assoc is not correct",
|
||||||
|
page5QName,
|
||||||
|
fetchedRenditionChildAssoc5.getQName());
|
||||||
|
// Now retrieve page 5 using the NodeService
|
||||||
|
List<ChildAssociationRef> fetchedRenditionChildAssocsPage5 = nodeService.getChildAssocs(
|
||||||
|
fileNodeRef,
|
||||||
|
ASSOC_TYPE_QNAME_TEST_RENDITION,
|
||||||
|
page5QName);
|
||||||
|
assertEquals("Expected exactly one result", 1, fetchedRenditionChildAssocsPage5.size());
|
||||||
|
assertEquals("Targeted page retrieval was not correct",
|
||||||
|
page5QName,
|
||||||
|
fetchedRenditionChildAssocsPage5.get(0).getQName());
|
||||||
|
}
|
||||||
|
private static final int MAX_RENDITION_PAGES = 100;
|
||||||
|
private static QName makePageAssocName(int pageNumber)
|
||||||
|
{
|
||||||
|
if (pageNumber > MAX_RENDITION_PAGES)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Rendition page number may not exceed " + MAX_RENDITION_PAGES);
|
||||||
|
}
|
||||||
|
String pageLocalName = String.format("renditionpage%05d", pageNumber);
|
||||||
|
QName renditionQName = QName.createQName(NAMESPACE, pageLocalName);
|
||||||
|
return renditionQName;
|
||||||
|
}
|
||||||
|
|
||||||
public void testCreateNodeNoProperties() throws Exception
|
public void testCreateNodeNoProperties() throws Exception
|
||||||
{
|
{
|
||||||
// flush to ensure that the pure JDBC query will work
|
// flush to ensure that the pure JDBC query will work
|
||||||
|
@@ -274,6 +274,17 @@
|
|||||||
</property>
|
</property>
|
||||||
</properties>
|
</properties>
|
||||||
</type>
|
</type>
|
||||||
|
|
||||||
|
<type name="test:rendition-page">
|
||||||
|
<title>Rendition Page</title>
|
||||||
|
<parent>sys:base</parent>
|
||||||
|
<properties>
|
||||||
|
<property name="test:rendition-page-content">
|
||||||
|
<type>d:content</type>
|
||||||
|
<mandatory enforced="true">true</mandatory>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</type>
|
||||||
</types>
|
</types>
|
||||||
|
|
||||||
<aspects>
|
<aspects>
|
||||||
@@ -352,6 +363,23 @@
|
|||||||
</associations>
|
</associations>
|
||||||
</aspect>
|
</aspect>
|
||||||
|
|
||||||
|
<aspect name="test:rendered">
|
||||||
|
<title>Aspect for Hanging Renditions Off</title>
|
||||||
|
<associations>
|
||||||
|
<child-association name="test:rendition-page">
|
||||||
|
<source>
|
||||||
|
<mandatory>false</mandatory>
|
||||||
|
<many>false</many>
|
||||||
|
</source>
|
||||||
|
<target>
|
||||||
|
<class>test:rendition-page</class>
|
||||||
|
<mandatory>false</mandatory>
|
||||||
|
<many>true</many>
|
||||||
|
</target>
|
||||||
|
</child-association>
|
||||||
|
</associations>
|
||||||
|
</aspect>
|
||||||
|
|
||||||
</aspects>
|
</aspects>
|
||||||
|
|
||||||
</model>
|
</model>
|
||||||
|
Reference in New Issue
Block a user