mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged 1.4 to HEAD
svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4329 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4331 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4332 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4339 . git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4653 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -218,6 +218,38 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<!-- This component checks the interconnection between the metadata, indexes and content -->
|
||||||
|
<bean id="configurationChecker" class="org.alfresco.repo.admin.ConfigurationChecker">
|
||||||
|
<property name="strict">
|
||||||
|
<value>${system.bootstrap.config_check.strict}</value>
|
||||||
|
</property>
|
||||||
|
<property name="checkAllContent">
|
||||||
|
<value>false</value>
|
||||||
|
</property>
|
||||||
|
<property name="dirRoot">
|
||||||
|
<value>${dir.root}</value>
|
||||||
|
</property>
|
||||||
|
<property name="indexRecoveryMode">
|
||||||
|
<value>${index.recovery.mode}</value>
|
||||||
|
</property>
|
||||||
|
<!-- helper beans -->
|
||||||
|
<property name="authenticationComponent">
|
||||||
|
<ref bean="authenticationComponent"/>
|
||||||
|
</property>
|
||||||
|
<property name="dictionaryService">
|
||||||
|
<ref bean="DictionaryService"/>
|
||||||
|
</property>
|
||||||
|
<property name="nodeService">
|
||||||
|
<ref bean="NodeService"/>
|
||||||
|
</property>
|
||||||
|
<property name="searchService">
|
||||||
|
<ref bean="SearchService"/>
|
||||||
|
</property>
|
||||||
|
<property name="contentService">
|
||||||
|
<ref bean="ContentService"/>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!-- This component ensures that patches get applied on startup -->
|
<!-- This component ensures that patches get applied on startup -->
|
||||||
|
|
||||||
<bean id="patchExecuter" class="org.alfresco.repo.admin.patch.PatchExecuter">
|
<bean id="patchExecuter" class="org.alfresco.repo.admin.patch.PatchExecuter">
|
||||||
|
@@ -9,7 +9,8 @@
|
|||||||
-->
|
-->
|
||||||
<beans>
|
<beans>
|
||||||
|
|
||||||
<!-- Datasource bean -->
|
<!-- DBCP Configuration -->
|
||||||
|
<!-- http://jakarta.apache.org/commons/dbcp/configuration.html -->
|
||||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
||||||
<!-- connection settings -->
|
<!-- connection settings -->
|
||||||
<property name="driverClassName">
|
<property name="driverClassName">
|
||||||
@@ -28,30 +29,39 @@
|
|||||||
<value>false</value>
|
<value>false</value>
|
||||||
</property>
|
</property>
|
||||||
<!-- pool settings -->
|
<!-- pool settings -->
|
||||||
<property name="initialSize" >
|
<property name="minIdle" >
|
||||||
<value>${db.pool.initial}</value>
|
<value>${db.pool.initial}</value>
|
||||||
</property>
|
</property>
|
||||||
<property name="maxActive" >
|
<property name="maxActive" >
|
||||||
<value>${db.pool.max}</value>
|
<value>${db.pool.max}</value>
|
||||||
</property>
|
</property>
|
||||||
<property name="timeBetweenEvictionRunsMillis" >
|
|
||||||
<value>300000</value>
|
|
||||||
</property>
|
|
||||||
<property name="minEvictableIdleTimeMillis" >
|
|
||||||
<value>-1</value>
|
|
||||||
</property>
|
|
||||||
<property name="testOnBorrow" >
|
|
||||||
<value>false</value>
|
|
||||||
</property>
|
|
||||||
<property name="maxWait" >
|
<property name="maxWait" >
|
||||||
<value>50000</value>
|
<value>10000</value>
|
||||||
</property>
|
|
||||||
<property name="testWhileIdle" >
|
|
||||||
<value>true</value>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="validationQuery" >
|
<property name="validationQuery" >
|
||||||
<value>select 1</value>
|
<value>select 1</value>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="timeBetweenEvictionRunsMillis" >
|
||||||
|
<value>300000</value>
|
||||||
|
</property>
|
||||||
|
<property name="minEvictableIdleTimeMillis" >
|
||||||
|
<value>60000</value>
|
||||||
|
</property>
|
||||||
|
<property name="testOnBorrow" >
|
||||||
|
<value>false</value>
|
||||||
|
</property>
|
||||||
|
<property name="testOnReturn" >
|
||||||
|
<value>false</value>
|
||||||
|
</property>
|
||||||
|
<property name="testWhileIdle" >
|
||||||
|
<value>true</value>
|
||||||
|
</property>
|
||||||
|
<property name="removeAbandoned" >
|
||||||
|
<value>true</value>
|
||||||
|
</property>
|
||||||
|
<property name="removeAbandonedTimeout" >
|
||||||
|
<value>30</value>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
@@ -2,3 +2,14 @@
|
|||||||
|
|
||||||
system.err.property_not_set=Property ''{0}'' has not been set: {1}
|
system.err.property_not_set=Property ''{0}'' has not been set: {1}
|
||||||
system.err.duplicate_name=Duplicate child name not allowed: {0}
|
system.err.duplicate_name=Duplicate child name not allowed: {0}
|
||||||
|
|
||||||
|
# Bootstrap configuration check messages
|
||||||
|
|
||||||
|
system.config_check.warn.dir_root=The Alfresco ''dir.root'' property is set to a relative path ''{0}''. ''dir.root'' should be overridden to point to a specific folder.
|
||||||
|
system.config_check.msg.dir_root=The Alfresco root data directory (''dir.root'') is: {0}
|
||||||
|
system.config_check.err.indexes.duplicate_root_node=The store ''{0}'' has a duplicate root node entry.
|
||||||
|
system.config_check.err.missing_index=CONTENT INTEGRITY ERROR: Indexes not found for {0} stores.
|
||||||
|
system.config_check.err.missing_content=CONTENT INTEGRITY ERROR: Content not found for {0} stores.
|
||||||
|
system.config_check.err.fix_dir_root=Ensure that the ''dir.root'' property is pointing to the correct data location.
|
||||||
|
system.config_check.msg.howto_index_recover=You may set 'index.recovery.mode=FULL' if you need to rebuild the indexes.
|
||||||
|
system.config_check.warn.starting_with_errors=Alfresco is starting with errors.
|
@@ -46,7 +46,7 @@
|
|||||||
</source>
|
</source>
|
||||||
<target>
|
<target>
|
||||||
<class>fm:forum</class>
|
<class>fm:forum</class>
|
||||||
<mandatory>true</mandatory>
|
<mandatory enforced="true">true</mandatory>
|
||||||
<many>false</many>
|
<many>false</many>
|
||||||
</target>
|
</target>
|
||||||
<duplicate>false</duplicate>
|
<duplicate>false</duplicate>
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
<property name="jcr:primaryType">
|
<property name="jcr:primaryType">
|
||||||
<type>d:qname</type>
|
<type>d:qname</type>
|
||||||
<protected>true</protected>
|
<protected>true</protected>
|
||||||
<mandatory>true</mandatory>
|
<mandatory enforced="true">true</mandatory>
|
||||||
</property>
|
</property>
|
||||||
<property name="jcr:mixinTypes">
|
<property name="jcr:mixinTypes">
|
||||||
<type>d:qname</type>
|
<type>d:qname</type>
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
</source>
|
</source>
|
||||||
<target>
|
<target>
|
||||||
<class>nt:base</class>
|
<class>nt:base</class>
|
||||||
<mandatory>true</mandatory>
|
<mandatory enforced="true">true</mandatory>
|
||||||
<many>false</many>
|
<many>false</many>
|
||||||
</target>
|
</target>
|
||||||
<child-name>jcr:content</child-name>
|
<child-name>jcr:content</child-name>
|
||||||
|
@@ -16,6 +16,9 @@ dir.indexes.lock=${dir.indexes}/locks
|
|||||||
# The index recovery mode (NONE, VALIDATE, AUTO, FULL)
|
# The index recovery mode (NONE, VALIDATE, AUTO, FULL)
|
||||||
index.recovery.mode=VALIDATE
|
index.recovery.mode=VALIDATE
|
||||||
|
|
||||||
|
# Change the failure behaviour of the configuration checker
|
||||||
|
system.bootstrap.config_check.strict=true
|
||||||
|
|
||||||
# #################### #
|
# #################### #
|
||||||
# Lucene configuration #
|
# Lucene configuration #
|
||||||
# #################### #
|
# #################### #
|
||||||
@@ -64,7 +67,6 @@ lucene.commit.lock.timeout=100000
|
|||||||
lucene.lock.poll.interval=100
|
lucene.lock.poll.interval=100
|
||||||
|
|
||||||
# Database configuration
|
# Database configuration
|
||||||
|
|
||||||
db.schema.update=true
|
db.schema.update=true
|
||||||
db.driver=org.gjt.mm.mysql.Driver
|
db.driver=org.gjt.mm.mysql.Driver
|
||||||
db.name=alfresco
|
db.name=alfresco
|
||||||
@@ -75,7 +77,6 @@ db.pool.initial=10
|
|||||||
db.pool.max=20
|
db.pool.max=20
|
||||||
|
|
||||||
# Email configuration
|
# Email configuration
|
||||||
|
|
||||||
mail.host=
|
mail.host=
|
||||||
mail.port=25
|
mail.port=25
|
||||||
mail.username=anonymous
|
mail.username=anonymous
|
||||||
@@ -86,13 +87,11 @@ mail.encoding=UTF-8
|
|||||||
mail.header=
|
mail.header=
|
||||||
|
|
||||||
# System Configuration
|
# System Configuration
|
||||||
|
|
||||||
system.store=system://system
|
system.store=system://system
|
||||||
system.descriptor.childname=sys:descriptor
|
system.descriptor.childname=sys:descriptor
|
||||||
system.descriptor.current.childname=sys:descriptor-current
|
system.descriptor.current.childname=sys:descriptor-current
|
||||||
|
|
||||||
# User config
|
# User config
|
||||||
|
|
||||||
alfresco_user_store.store=user://alfrescoUserStore
|
alfresco_user_store.store=user://alfrescoUserStore
|
||||||
alfresco_user_store.system_container.childname=sys:system
|
alfresco_user_store.system_container.childname=sys:system
|
||||||
alfresco_user_store.user_container.childname=sys:people
|
alfresco_user_store.user_container.childname=sys:people
|
||||||
@@ -102,7 +101,6 @@ alfresco_user_store.authorities_container.childname=sys:authorities
|
|||||||
spaces.archive.store=archive://SpacesStore
|
spaces.archive.store=archive://SpacesStore
|
||||||
|
|
||||||
# Spaces Configuration
|
# Spaces Configuration
|
||||||
|
|
||||||
spaces.store=workspace://SpacesStore
|
spaces.store=workspace://SpacesStore
|
||||||
spaces.company_home.childname=app:company_home
|
spaces.company_home.childname=app:company_home
|
||||||
spaces.guest_home.childname=app:guest_home
|
spaces.guest_home.childname=app:guest_home
|
||||||
@@ -117,12 +115,10 @@ spaces.wcm.childname=app:wcm
|
|||||||
spaces.content_forms.childname=app:wcm_forms
|
spaces.content_forms.childname=app:wcm_forms
|
||||||
|
|
||||||
# Folders for storing people
|
# Folders for storing people
|
||||||
|
|
||||||
system.system_container.childname=sys:system
|
system.system_container.childname=sys:system
|
||||||
system.people_container.childname=sys:people
|
system.people_container.childname=sys:people
|
||||||
|
|
||||||
# Folders for storing workflow related info
|
# Folders for storing workflow related info
|
||||||
|
|
||||||
system.workflow_container.childname=sys:workflow
|
system.workflow_container.childname=sys:workflow
|
||||||
|
|
||||||
# Are user names case sensitive?
|
# Are user names case sensitive?
|
||||||
@@ -136,7 +132,6 @@ system.workflow_container.childname=sys:workflow
|
|||||||
#
|
#
|
||||||
# Must other databases are case sensitive by default.
|
# Must other databases are case sensitive by default.
|
||||||
#
|
#
|
||||||
|
|
||||||
user.name.caseSensitive=false
|
user.name.caseSensitive=false
|
||||||
|
|
||||||
# AVM Specific properties.
|
# AVM Specific properties.
|
||||||
|
@@ -116,7 +116,7 @@
|
|||||||
<child-association name="act:actions">
|
<child-association name="act:actions">
|
||||||
<target>
|
<target>
|
||||||
<class>act:action</class>
|
<class>act:action</class>
|
||||||
<mandatory>true</mandatory>
|
<mandatory enforced="true">true</mandatory>
|
||||||
<many>true</many>
|
<many>true</many>
|
||||||
</target>
|
</target>
|
||||||
</child-association>
|
</child-association>
|
||||||
@@ -130,7 +130,7 @@
|
|||||||
<child-association name="act:savedActions">
|
<child-association name="act:savedActions">
|
||||||
<target>
|
<target>
|
||||||
<class>act:action</class>
|
<class>act:action</class>
|
||||||
<mandatory>true</mandatory>
|
<mandatory enforced="true">true</mandatory>
|
||||||
<many>true</many>
|
<many>true</many>
|
||||||
</target>
|
</target>
|
||||||
</child-association>
|
</child-association>
|
||||||
|
375
source/java/org/alfresco/repo/admin/ConfigurationChecker.java
Normal file
375
source/java/org/alfresco/repo/admin/ConfigurationChecker.java
Normal file
@@ -0,0 +1,375 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 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.admin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
import org.alfresco.i18n.I18NUtil;
|
||||||
|
import org.alfresco.repo.node.index.FullIndexRecoveryComponent.RecoveryMode;
|
||||||
|
import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
|
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||||
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.service.cmr.search.LimitBy;
|
||||||
|
import org.alfresco.service.cmr.search.ResultSet;
|
||||||
|
import org.alfresco.service.cmr.search.ResultSetRow;
|
||||||
|
import org.alfresco.service.cmr.search.SearchParameters;
|
||||||
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.util.AbstractLifecycleBean;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component to perform a bootstrap check of the alignment of the
|
||||||
|
* database, Lucene indexes and content store.
|
||||||
|
* <p>
|
||||||
|
* The algorithm is:
|
||||||
|
* <ul>
|
||||||
|
* <li>Get all stores from the NodeService</li>
|
||||||
|
* <li>Get each root node</li>
|
||||||
|
* <li>Perform a Lucene query for each root node</li>
|
||||||
|
* <li>Query Lucene for a small set of content nodes</li>
|
||||||
|
* <li>Get content readers for each node</li>
|
||||||
|
* </ul>
|
||||||
|
* If any of the steps fail then the bootstrap bean will fail, except if
|
||||||
|
* the indexes are marked for full recovery. In this case, the Lucene
|
||||||
|
* checks are not required as the indexes will be due for a rebuild.
|
||||||
|
*
|
||||||
|
* @author Derek Hulley
|
||||||
|
*/
|
||||||
|
public class ConfigurationChecker extends AbstractLifecycleBean
|
||||||
|
{
|
||||||
|
private static Log logger = LogFactory.getLog(ConfigurationChecker.class);
|
||||||
|
|
||||||
|
private static final String WARN_RELATIVE_DIR_ROOT = "system.config_check.warn.dir_root";
|
||||||
|
private static final String MSG_DIR_ROOT = "system.config_check.msg.dir_root";
|
||||||
|
private static final String ERR_DUPLICATE_ROOT_NODE = "system.config_check.err.indexes.duplicate_root_node";
|
||||||
|
private static final String ERR_MISSING_INDEXES = "system.config_check.err.missing_index";
|
||||||
|
private static final String ERR_MISSING_CONTENT = "system.config_check.err.missing_content";
|
||||||
|
private static final String ERR_FIX_DIR_ROOT = "system.config_check.err.fix_dir_root";
|
||||||
|
private static final String MSG_HOWTO_INDEX_RECOVER = "system.config_check.msg.howto_index_recover";
|
||||||
|
private static final String WARN_STARTING_WITH_ERRORS = "system.config_check.warn.starting_with_errors";
|
||||||
|
|
||||||
|
private boolean strict;
|
||||||
|
private RecoveryMode indexRecoveryMode;
|
||||||
|
private String dirRoot;
|
||||||
|
private boolean checkAllContent;
|
||||||
|
|
||||||
|
private AuthenticationComponent authenticationComponent;
|
||||||
|
private DictionaryService dictionaryService;
|
||||||
|
private NodeService nodeService;
|
||||||
|
private SearchService searchService;
|
||||||
|
private ContentService contentService;
|
||||||
|
|
||||||
|
public ConfigurationChecker()
|
||||||
|
{
|
||||||
|
this.checkAllContent = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder(50);
|
||||||
|
sb.append("ConfigurationChecker")
|
||||||
|
.append("[indexRecoveryMode=").append(indexRecoveryMode)
|
||||||
|
.append(", checkAllContent=").append(checkAllContent)
|
||||||
|
.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This flag controls the behaviour of the component in the event of problems being found.
|
||||||
|
* Generally, the system should be <b>strict</b>, but this can be changed if indexes are
|
||||||
|
* going to be recovered, or if missing content is acceptable.
|
||||||
|
*
|
||||||
|
* @param strict <code>true</code> to prevent system startup if problems are found, otherwise
|
||||||
|
* <code>false</code> to allow the system to startup regardless.
|
||||||
|
*/
|
||||||
|
public void setStrict(boolean strict)
|
||||||
|
{
|
||||||
|
this.strict = strict;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param checkAllContent <code>true</code> to get all content URLs when checking for
|
||||||
|
* missing content, or <code>false</code> to just do a quick sanity check against
|
||||||
|
* the content store.
|
||||||
|
*/
|
||||||
|
public void setCheckAllContent(boolean checkAllContent)
|
||||||
|
{
|
||||||
|
this.checkAllContent = checkAllContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the index recovery mode. If this is
|
||||||
|
* {@link org.alfresco.repo.node.index.FullIndexRecoveryComponent.RecoveryMode#VALIDATE FULL}
|
||||||
|
* then the index checks are ignored as the indexes will be scheduled for a rebuild
|
||||||
|
* anyway.
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.node.index.FullIndexRecoveryComponent.RecoveryMode
|
||||||
|
*/
|
||||||
|
public void setIndexRecoveryMode(String indexRecoveryMode)
|
||||||
|
{
|
||||||
|
this.indexRecoveryMode = RecoveryMode.valueOf(indexRecoveryMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDirRoot(String dirRoot)
|
||||||
|
{
|
||||||
|
this.dirRoot = dirRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthenticationComponent(AuthenticationComponent authenticationComponent)
|
||||||
|
{
|
||||||
|
this.authenticationComponent = authenticationComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDictionaryService(DictionaryService dictionaryService)
|
||||||
|
{
|
||||||
|
this.dictionaryService = dictionaryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeService(NodeService nodeService)
|
||||||
|
{
|
||||||
|
this.nodeService = nodeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSearchService(SearchService searchService)
|
||||||
|
{
|
||||||
|
this.searchService = searchService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContentService(ContentService contentService)
|
||||||
|
{
|
||||||
|
this.contentService = contentService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBootstrap(ApplicationEvent event)
|
||||||
|
{
|
||||||
|
// authenticate
|
||||||
|
try
|
||||||
|
{
|
||||||
|
authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
|
check();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
authenticationComponent.clearCurrentSecurityContext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs the check work.
|
||||||
|
*/
|
||||||
|
private void check()
|
||||||
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Starting bootstrap configuration check: " + this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check the dir.root
|
||||||
|
boolean isRelativeRoot = dirRoot.startsWith(".");
|
||||||
|
if (isRelativeRoot)
|
||||||
|
{
|
||||||
|
String msg = I18NUtil.getMessage(WARN_RELATIVE_DIR_ROOT, dirRoot);
|
||||||
|
logger.warn(msg);
|
||||||
|
}
|
||||||
|
File dirRootFile = new File(dirRoot);
|
||||||
|
String msgDirRoot = I18NUtil.getMessage(MSG_DIR_ROOT, dirRootFile);
|
||||||
|
logger.info(msgDirRoot);
|
||||||
|
|
||||||
|
// get all root nodes from the NodeService, i.e. database
|
||||||
|
List<StoreRef> storeRefs = nodeService.getStores();
|
||||||
|
List<StoreRef> missingIndexStoreRefs = new ArrayList<StoreRef>(0);
|
||||||
|
List<StoreRef> missingContentStoreRefs = new ArrayList<StoreRef>(0);
|
||||||
|
for (StoreRef storeRef : storeRefs)
|
||||||
|
{
|
||||||
|
NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
|
||||||
|
if (indexRecoveryMode != RecoveryMode.FULL)
|
||||||
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Checking index for store: " + storeRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
// perform a Lucene query for the root node
|
||||||
|
SearchParameters sp = new SearchParameters();
|
||||||
|
sp.addStore(storeRef);
|
||||||
|
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
|
||||||
|
sp.setQuery("ID:" + LuceneQueryParser.escape(rootNodeRef.toString()));
|
||||||
|
|
||||||
|
ResultSet results = null;
|
||||||
|
int size = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
results = searchService.query(sp);
|
||||||
|
size = results.length();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
try { results.close(); } catch (Throwable e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
{
|
||||||
|
// indexes missing for root node
|
||||||
|
missingIndexStoreRefs.add(storeRef);
|
||||||
|
// debug
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Index missing for store: \n" +
|
||||||
|
" store: " + storeRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (size > 1)
|
||||||
|
{
|
||||||
|
// there are duplicates
|
||||||
|
String msg = I18NUtil.getMessage(ERR_DUPLICATE_ROOT_NODE, storeRef);
|
||||||
|
throw new AlfrescoRuntimeException(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// select a content property
|
||||||
|
QName contentPropertyQName = null;
|
||||||
|
Collection<QName> typeQNames = dictionaryService.getAllTypes();
|
||||||
|
/* BREAK POINT */ contentPropertyFound:
|
||||||
|
for (QName typeQName : typeQNames)
|
||||||
|
{
|
||||||
|
TypeDefinition classDef = dictionaryService.getType(typeQName);
|
||||||
|
Map<QName, PropertyDefinition> propertyDefs = classDef.getProperties();
|
||||||
|
for (PropertyDefinition propertyDef : propertyDefs.values())
|
||||||
|
{
|
||||||
|
if (!propertyDef.getDataType().getName().equals(DataTypeDefinition.CONTENT))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
contentPropertyQName = propertyDef.getName();
|
||||||
|
break contentPropertyFound;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// do a search for nodes with content
|
||||||
|
if (contentPropertyQName != null)
|
||||||
|
{
|
||||||
|
String attributeName = "\\@" + LuceneQueryParser.escape(contentPropertyQName.toString());
|
||||||
|
|
||||||
|
SearchParameters sp = new SearchParameters();
|
||||||
|
sp.addStore(storeRef);
|
||||||
|
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
|
||||||
|
sp.setQuery(attributeName + ":*");
|
||||||
|
if (!checkAllContent)
|
||||||
|
{
|
||||||
|
sp.setLimit(1);
|
||||||
|
sp.setLimitBy(LimitBy.FINAL_SIZE);
|
||||||
|
}
|
||||||
|
ResultSet results = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
results = searchService.query(sp);
|
||||||
|
// iterate and attempt to get the content
|
||||||
|
for (ResultSetRow row : results)
|
||||||
|
{
|
||||||
|
NodeRef nodeRef = row.getNodeRef();
|
||||||
|
ContentReader reader = contentService.getReader(nodeRef, contentPropertyQName);
|
||||||
|
if (reader == null)
|
||||||
|
{
|
||||||
|
// content not written
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (reader.exists())
|
||||||
|
{
|
||||||
|
// the data is present in the content store
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// URL is missing
|
||||||
|
missingContentStoreRefs.add(storeRef);
|
||||||
|
// debug
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Content missing from store: \n" +
|
||||||
|
" store: " + storeRef + "\n" +
|
||||||
|
" content: " + reader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// break out if necessary
|
||||||
|
if (!checkAllContent)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
try { results.close(); } catch (Throwable e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check for missing indexes
|
||||||
|
int missingStoreIndexes = missingIndexStoreRefs.size();
|
||||||
|
if (missingStoreIndexes > 0)
|
||||||
|
{
|
||||||
|
String msg = I18NUtil.getMessage(ERR_MISSING_INDEXES, missingStoreIndexes);
|
||||||
|
logger.error(msg);
|
||||||
|
String msgRecover = I18NUtil.getMessage(MSG_HOWTO_INDEX_RECOVER);
|
||||||
|
logger.info(msgRecover);
|
||||||
|
}
|
||||||
|
// check for missing content
|
||||||
|
int missingStoreContent = missingContentStoreRefs.size();
|
||||||
|
if (missingStoreContent > 0)
|
||||||
|
{
|
||||||
|
String msg = I18NUtil.getMessage(ERR_MISSING_CONTENT, missingStoreContent);
|
||||||
|
logger.error(msg);
|
||||||
|
}
|
||||||
|
// handle either content or indexes missing
|
||||||
|
if (missingStoreIndexes > 0 || missingStoreContent > 0)
|
||||||
|
{
|
||||||
|
String msg = I18NUtil.getMessage(ERR_FIX_DIR_ROOT, dirRootFile);
|
||||||
|
logger.error(msg);
|
||||||
|
|
||||||
|
// Now determine the failure behaviour
|
||||||
|
if (strict)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException(msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String warn = I18NUtil.getMessage(WARN_STARTING_WITH_ERRORS);
|
||||||
|
logger.warn(warn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onShutdown(ApplicationEvent event)
|
||||||
|
{
|
||||||
|
// nothing here
|
||||||
|
}
|
||||||
|
}
|
@@ -259,6 +259,13 @@ public class RoutingContentServiceTest extends TestCase
|
|||||||
// check the indexing doesn't spank everthing
|
// check the indexing doesn't spank everthing
|
||||||
txn.commit();
|
txn.commit();
|
||||||
txn = null;
|
txn = null;
|
||||||
|
|
||||||
|
// cleanup
|
||||||
|
txn = getUserTransaction();
|
||||||
|
txn.begin();
|
||||||
|
nodeService.deleteNode(contentNodeRef);
|
||||||
|
txn.commit();
|
||||||
|
txn = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -49,16 +49,19 @@ public class PdfBoxMetadataExtracter extends AbstractMetadataExtracter
|
|||||||
is = reader.getContentInputStream();
|
is = reader.getContentInputStream();
|
||||||
// stream the document in
|
// stream the document in
|
||||||
pdf = PDDocument.load(is);
|
pdf = PDDocument.load(is);
|
||||||
// Scoop out the metadata
|
if (!pdf.isEncrypted())
|
||||||
PDDocumentInformation docInfo = pdf.getDocumentInformation();
|
{
|
||||||
|
// Scoop out the metadata
|
||||||
|
PDDocumentInformation docInfo = pdf.getDocumentInformation();
|
||||||
|
|
||||||
trimPut(ContentModel.PROP_AUTHOR, docInfo.getAuthor(), destination);
|
trimPut(ContentModel.PROP_AUTHOR, docInfo.getAuthor(), destination);
|
||||||
trimPut(ContentModel.PROP_TITLE, docInfo.getTitle(), destination);
|
trimPut(ContentModel.PROP_TITLE, docInfo.getTitle(), destination);
|
||||||
trimPut(ContentModel.PROP_DESCRIPTION, docInfo.getSubject(), destination);
|
trimPut(ContentModel.PROP_DESCRIPTION, docInfo.getSubject(), destination);
|
||||||
|
|
||||||
Calendar created = docInfo.getCreationDate();
|
Calendar created = docInfo.getCreationDate();
|
||||||
if (created != null)
|
if (created != null)
|
||||||
destination.put(ContentModel.PROP_CREATED, created.getTime());
|
destination.put(ContentModel.PROP_CREATED, created.getTime());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@@ -221,6 +221,15 @@ import org.alfresco.service.namespace.QName;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.service.cmr.dictionary.AssociationDefinition#isTargetMandatoryEnforced()
|
||||||
|
*/
|
||||||
|
public boolean isTargetMandatoryEnforced()
|
||||||
|
{
|
||||||
|
return assoc.isTargetMandatoryEnforced();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.AssociationDefinition#isTargetMany()
|
* @see org.alfresco.repo.dictionary.AssociationDefinition#isTargetMany()
|
||||||
*/
|
*/
|
||||||
|
@@ -35,6 +35,7 @@ public abstract class M2ClassAssociation
|
|||||||
private String targetClassName = null;
|
private String targetClassName = null;
|
||||||
private String targetRoleName = null;
|
private String targetRoleName = null;
|
||||||
private Boolean isTargetMandatory = null;
|
private Boolean isTargetMandatory = null;
|
||||||
|
private Boolean isTargetMandatoryEnforced = null;
|
||||||
private Boolean isTargetMany = null;
|
private Boolean isTargetMany = null;
|
||||||
|
|
||||||
|
|
||||||
@@ -175,6 +176,18 @@ public abstract class M2ClassAssociation
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isTargetMandatoryEnforced()
|
||||||
|
{
|
||||||
|
return isTargetMandatoryEnforced == null ? false : isTargetMandatoryEnforced;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setTargetMandatoryEnforced(boolean isTargetMandatoryEnforced)
|
||||||
|
{
|
||||||
|
this.isTargetMandatoryEnforced = isTargetMandatoryEnforced;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isTargetMany()
|
public boolean isTargetMany()
|
||||||
{
|
{
|
||||||
return isTargetMany == null ? true : isTargetMany;
|
return isTargetMany == null ? true : isTargetMany;
|
||||||
|
@@ -157,7 +157,10 @@
|
|||||||
<structure name="target">
|
<structure name="target">
|
||||||
<value name="class" field="targetClassName"/>
|
<value name="class" field="targetClassName"/>
|
||||||
<value name="role" field="targetRoleName" usage="optional"/>
|
<value name="role" field="targetRoleName" usage="optional"/>
|
||||||
<value name="mandatory" field="isTargetMandatory" usage="optional"/>
|
<structure name="mandatory" usage="optional">
|
||||||
|
<value style="attribute" name="enforced" field="isTargetMandatoryEnforced" usage="optional"/>
|
||||||
|
<value style="text" field="isTargetMandatory" />
|
||||||
|
</structure>
|
||||||
<value name="many" field="isTargetMany" usage="optional"/>
|
<value name="many" field="isTargetMany" usage="optional"/>
|
||||||
</structure>
|
</structure>
|
||||||
</mapping>
|
</mapping>
|
||||||
|
@@ -557,7 +557,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
|||||||
{
|
{
|
||||||
// it was marked as optional, so we just ignore it
|
// it was marked as optional, so we just ignore it
|
||||||
String msg = I18NUtil.getMessage(MSG_OPTIONAL_STATEMENT_FAILED, sql, e.getMessage(), file.getAbsolutePath(), line);
|
String msg = I18NUtil.getMessage(MSG_OPTIONAL_STATEMENT_FAILED, sql, e.getMessage(), file.getAbsolutePath(), line);
|
||||||
logger.warn(msg);
|
logger.debug(msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -18,7 +18,9 @@ package org.alfresco.repo.node.integrity;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -30,14 +32,17 @@ import org.alfresco.repo.policy.PolicyComponent;
|
|||||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||||
import org.alfresco.repo.transaction.TransactionListenerAdapter;
|
import org.alfresco.repo.transaction.TransactionListenerAdapter;
|
||||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||||
|
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||||
|
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
import org.alfresco.util.PropertyCheck;
|
import org.alfresco.util.PropertyCheck;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@@ -52,12 +57,16 @@ public class IncompleteNodeTagger
|
|||||||
implements NodeServicePolicies.OnCreateNodePolicy,
|
implements NodeServicePolicies.OnCreateNodePolicy,
|
||||||
NodeServicePolicies.OnUpdatePropertiesPolicy,
|
NodeServicePolicies.OnUpdatePropertiesPolicy,
|
||||||
NodeServicePolicies.OnAddAspectPolicy,
|
NodeServicePolicies.OnAddAspectPolicy,
|
||||||
NodeServicePolicies.OnRemoveAspectPolicy
|
NodeServicePolicies.OnRemoveAspectPolicy,
|
||||||
|
NodeServicePolicies.OnCreateChildAssociationPolicy,
|
||||||
|
NodeServicePolicies.OnDeleteChildAssociationPolicy,
|
||||||
|
NodeServicePolicies.OnCreateAssociationPolicy,
|
||||||
|
NodeServicePolicies.OnDeleteAssociationPolicy
|
||||||
{
|
{
|
||||||
private static Log logger = LogFactory.getLog(IncompleteNodeTagger.class);
|
private static Log logger = LogFactory.getLog(IncompleteNodeTagger.class);
|
||||||
|
|
||||||
/** key against which the set of nodes to check is stored in the current transaction */
|
/** key against which the set of nodes to check is stored in the current transaction */
|
||||||
private static final String KEY_NODE_SET = "IncompleteNodeTagger.NodeSet";
|
private static final String KEY_NODES = "IncompleteNodeTagger.Nodes";
|
||||||
|
|
||||||
private PolicyComponent policyComponent;
|
private PolicyComponent policyComponent;
|
||||||
private DictionaryService dictionaryService;
|
private DictionaryService dictionaryService;
|
||||||
@@ -118,41 +127,99 @@ public class IncompleteNodeTagger
|
|||||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveAspect"),
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveAspect"),
|
||||||
this,
|
this,
|
||||||
new JavaBehaviour(this, "onRemoveAspect"));
|
new JavaBehaviour(this, "onRemoveAspect"));
|
||||||
|
policyComponent.bindAssociationBehaviour(
|
||||||
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"),
|
||||||
|
this,
|
||||||
|
new JavaBehaviour(this, "onCreateChildAssociation"));
|
||||||
|
policyComponent.bindAssociationBehaviour(
|
||||||
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteChildAssociation"),
|
||||||
|
this,
|
||||||
|
new JavaBehaviour(this, "onDeleteChildAssociation"));
|
||||||
|
policyComponent.bindAssociationBehaviour(
|
||||||
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateAssociation"),
|
||||||
|
this,
|
||||||
|
new JavaBehaviour(this, "onCreateAssociation"));
|
||||||
|
policyComponent.bindAssociationBehaviour(
|
||||||
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteAssociation"),
|
||||||
|
this,
|
||||||
|
new JavaBehaviour(this, "onDeleteAssociation"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the set of nodes to check, or null if none were registered
|
* @return Returns the set of nodes to check properties, or null if none were registered
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Set<NodeRef> getNodeSet()
|
private Map<NodeRef, Set<QName>> getNodes()
|
||||||
{
|
{
|
||||||
return (Set<NodeRef>) AlfrescoTransactionSupport.getResource(KEY_NODE_SET);
|
return (Map<NodeRef, Set<QName>>) AlfrescoTransactionSupport.getResource(KEY_NODES);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that this service is registered with the transaction and saves the node
|
* Ensures that this service is registered with the transaction and saves the node
|
||||||
* reference for use later.
|
* reference for use (property check) later.
|
||||||
*
|
*
|
||||||
* @param nodeRef
|
* @param nodeRef
|
||||||
*/
|
*/
|
||||||
private void save(NodeRef nodeRef)
|
private Set<QName> save(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
|
Set<QName> assocs = null;
|
||||||
|
|
||||||
// register this service
|
// register this service
|
||||||
AlfrescoTransactionSupport.bindListener(this);
|
AlfrescoTransactionSupport.bindListener(this);
|
||||||
|
|
||||||
// get the event list
|
// get the event list
|
||||||
Set<NodeRef> nodeRefs = getNodeSet();
|
Map<NodeRef, Set<QName>> nodes = getNodes();
|
||||||
if (nodeRefs == null)
|
if (nodes == null)
|
||||||
{
|
{
|
||||||
nodeRefs = new HashSet<NodeRef>(31, 0.75F);
|
nodes = new HashMap<NodeRef, Set<QName>>(31, 0.75F);
|
||||||
AlfrescoTransactionSupport.bindResource(KEY_NODE_SET, nodeRefs);
|
AlfrescoTransactionSupport.bindResource(KEY_NODES, nodes);
|
||||||
}
|
}
|
||||||
// add node to the set
|
// add node to the set
|
||||||
nodeRefs.add(nodeRef);
|
if (nodes.containsKey(nodeRef))
|
||||||
|
{
|
||||||
|
assocs = nodes.get(nodeRef);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nodes.put(nodeRef, null);
|
||||||
|
}
|
||||||
|
|
||||||
// done
|
// done
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("Added node reference to set: " + nodeRef);
|
logger.debug("Added node reference to property set: " + nodeRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
return assocs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures that this service is registered with the transaction and saves the node
|
||||||
|
* reference for use (association check) later.
|
||||||
|
*
|
||||||
|
* @param nodeRef
|
||||||
|
* @param assocType
|
||||||
|
*/
|
||||||
|
private void saveAssoc(NodeRef nodeRef, QName assocType)
|
||||||
|
{
|
||||||
|
// register this service
|
||||||
|
AlfrescoTransactionSupport.bindListener(this);
|
||||||
|
|
||||||
|
Set<QName> assocs = save(nodeRef);
|
||||||
|
if (assocs == null)
|
||||||
|
{
|
||||||
|
assocs = new HashSet<QName>(7, 0.75f);
|
||||||
|
Map<NodeRef, Set<QName>> nodes = getNodes();
|
||||||
|
nodes.put(nodeRef, assocs);
|
||||||
|
}
|
||||||
|
if (assocType != null)
|
||||||
|
{
|
||||||
|
assocs.add(assocType);
|
||||||
|
}
|
||||||
|
// done
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Added association to node: " + nodeRef + ", " + assocType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +227,7 @@ public class IncompleteNodeTagger
|
|||||||
{
|
{
|
||||||
NodeRef nodeRef = childAssocRef.getChildRef();
|
NodeRef nodeRef = childAssocRef.getChildRef();
|
||||||
save(nodeRef);
|
save(nodeRef);
|
||||||
|
saveAssoc(nodeRef, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdateProperties(
|
public void onUpdateProperties(
|
||||||
@@ -202,28 +270,69 @@ public class IncompleteNodeTagger
|
|||||||
save(nodeRef);
|
save(nodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AssocSourceTypeIntegrityEvent
|
||||||
|
* @see AssocTargetTypeIntegrityEvent
|
||||||
|
* @see AssocSourceMultiplicityIntegrityEvent
|
||||||
|
* @see AssocTargetMultiplicityIntegrityEvent
|
||||||
|
* @see AssocTargetRoleIntegrityEvent
|
||||||
|
*/
|
||||||
|
public void onCreateChildAssociation(ChildAssociationRef childAssocRef)
|
||||||
|
{
|
||||||
|
saveAssoc(childAssocRef.getParentRef(), childAssocRef.getTypeQName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AssocSourceMultiplicityIntegrityEvent
|
||||||
|
* @see AssocTargetMultiplicityIntegrityEvent
|
||||||
|
*/
|
||||||
|
public void onDeleteChildAssociation(ChildAssociationRef childAssocRef)
|
||||||
|
{
|
||||||
|
saveAssoc(childAssocRef.getParentRef(), childAssocRef.getTypeQName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AssocSourceTypeIntegrityEvent
|
||||||
|
* @see AssocTargetTypeIntegrityEvent
|
||||||
|
* @see AssocSourceMultiplicityIntegrityEvent
|
||||||
|
* @see AssocTargetMultiplicityIntegrityEvent
|
||||||
|
*/
|
||||||
|
public void onCreateAssociation(AssociationRef nodeAssocRef)
|
||||||
|
{
|
||||||
|
saveAssoc(nodeAssocRef.getSourceRef(), nodeAssocRef.getTypeQName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AssocSourceMultiplicityIntegrityEvent
|
||||||
|
* @see AssocTargetMultiplicityIntegrityEvent
|
||||||
|
*/
|
||||||
|
public void onDeleteAssociation(AssociationRef nodeAssocRef)
|
||||||
|
{
|
||||||
|
saveAssoc(nodeAssocRef.getSourceRef(), nodeAssocRef.getTypeQName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process all the nodes that require checking within the transaction.
|
* Process all the nodes that require checking within the transaction.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void beforeCommit(boolean readOnly)
|
public void beforeCommit(boolean readOnly)
|
||||||
{
|
{
|
||||||
Set<NodeRef> nodeRefs = getNodeSet();
|
Map<NodeRef, Set<QName>> nodes = getNodes();
|
||||||
// clear the set out of the transaction
|
// clear the set out of the transaction
|
||||||
// there may be processes that react to the addition/removal of the aspect,
|
// there may be processes that react to the addition/removal of the aspect,
|
||||||
// and these will, in turn, lead to further events
|
// and these will, in turn, lead to further events
|
||||||
AlfrescoTransactionSupport.unbindResource(KEY_NODE_SET);
|
AlfrescoTransactionSupport.unbindResource(KEY_NODES);
|
||||||
// process each node
|
// process each node
|
||||||
for (NodeRef nodeRef : nodeRefs)
|
for (Map.Entry<NodeRef, Set<QName>> entry : nodes.entrySet())
|
||||||
{
|
{
|
||||||
if (nodeService.exists(nodeRef))
|
if (nodeService.exists(entry.getKey()))
|
||||||
{
|
{
|
||||||
processNode(nodeRef);
|
processNode(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processNode(NodeRef nodeRef)
|
private void processNode(NodeRef nodeRef, Set<QName> assocTypes)
|
||||||
{
|
{
|
||||||
// ignore the node if the marker aspect is already present
|
// ignore the node if the marker aspect is already present
|
||||||
boolean isTagged = nodeService.hasAspect(nodeRef, ContentModel.ASPECT_INCOMPLETE);
|
boolean isTagged = nodeService.hasAspect(nodeRef, ContentModel.ASPECT_INCOMPLETE);
|
||||||
@@ -267,7 +376,46 @@ public class IncompleteNodeTagger
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// all properties passed (both class- and aspect-defined) - remove aspect
|
|
||||||
|
// test associations
|
||||||
|
if (assocTypes != null)
|
||||||
|
{
|
||||||
|
Map<QName, AssociationDefinition> assocDefs = typeDef.getAssociations();
|
||||||
|
if (assocTypes.size() > 0)
|
||||||
|
{
|
||||||
|
// check only those associations that have changed
|
||||||
|
for (QName assocType : assocTypes)
|
||||||
|
{
|
||||||
|
AssociationDefinition assocDef = assocDefs.get(assocType);
|
||||||
|
if (assocDef != null)
|
||||||
|
{
|
||||||
|
if (!checkAssociation(nodeRef, assocDef))
|
||||||
|
{
|
||||||
|
addOrRemoveTag(nodeRef, true, isTagged);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// check all associations (typically for new objects)
|
||||||
|
for (QName assocType : assocDefs.keySet())
|
||||||
|
{
|
||||||
|
AssociationDefinition assocDef = assocDefs.get(assocType);
|
||||||
|
if (assocDef != null)
|
||||||
|
{
|
||||||
|
if (!checkAssociation(nodeRef, assocDef))
|
||||||
|
{
|
||||||
|
addOrRemoveTag(nodeRef, true, isTagged);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// all properties and associations passed (both class- and aspect-defined) - remove aspect
|
||||||
addOrRemoveTag(nodeRef, false, isTagged);
|
addOrRemoveTag(nodeRef, false, isTagged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,6 +453,41 @@ public class IncompleteNodeTagger
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param nodeRef
|
||||||
|
* @param assocDef
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean checkAssociation(NodeRef nodeRef, AssociationDefinition assocDef)
|
||||||
|
{
|
||||||
|
boolean complete = true;
|
||||||
|
|
||||||
|
if (assocDef.isTargetMandatory() && !assocDef.isTargetMandatoryEnforced())
|
||||||
|
{
|
||||||
|
int actualSize = 0;
|
||||||
|
if (assocDef.isChild())
|
||||||
|
{
|
||||||
|
// check the child assocs present
|
||||||
|
List<ChildAssociationRef> childAssocRefs = nodeService.getChildAssocs(
|
||||||
|
nodeRef,
|
||||||
|
assocDef.getName(),
|
||||||
|
RegexQNamePattern.MATCH_ALL);
|
||||||
|
actualSize = childAssocRefs.size();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// check the target assocs present
|
||||||
|
List<AssociationRef> targetAssocRefs = nodeService.getTargetAssocs(nodeRef, assocDef.getName());
|
||||||
|
actualSize = targetAssocRefs.size();
|
||||||
|
}
|
||||||
|
if (assocDef.isTargetMandatory() && actualSize == 0)
|
||||||
|
{
|
||||||
|
complete = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return complete;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds or removes the {@link ContentModel#ASPECT_INCOMPLETE incomplete} marker aspect.
|
* Adds or removes the {@link ContentModel#ASPECT_INCOMPLETE incomplete} marker aspect.
|
||||||
* This only performs the operation if the tag aspect is or is not present, depending
|
* This only performs the operation if the tag aspect is or is not present, depending
|
||||||
|
@@ -130,4 +130,22 @@ public class IncompleteNodeTaggerTest extends TestCase
|
|||||||
NodeRef nodeRef = createNode("abc", IntegrityTest.TEST_TYPE_WITH_PROPERTIES, properties);
|
NodeRef nodeRef = createNode("abc", IntegrityTest.TEST_TYPE_WITH_PROPERTIES, properties);
|
||||||
checkTagging(nodeRef, false);
|
checkTagging(nodeRef, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCreateWithoutAssoc() throws Exception
|
||||||
|
{
|
||||||
|
NodeRef nodeRef = createNode("abc", IntegrityTest.TEST_TYPE_WITH_NON_ENFORCED_CHILD_ASSOCS, properties);
|
||||||
|
checkTagging(nodeRef, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCreateWithAssoc() throws Exception
|
||||||
|
{
|
||||||
|
NodeRef nodeRef = createNode("abc", IntegrityTest.TEST_TYPE_WITH_NON_ENFORCED_CHILD_ASSOCS, properties);
|
||||||
|
nodeService.createNode(nodeRef,
|
||||||
|
IntegrityTest.TEST_ASSOC_CHILD_NON_ENFORCED,
|
||||||
|
QName.createQName(IntegrityTest.NAMESPACE, "easyas"),
|
||||||
|
IntegrityTest.TEST_TYPE_WITHOUT_ANYTHING,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
checkTagging(nodeRef, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -62,12 +62,14 @@ public class IntegrityTest extends TestCase
|
|||||||
public static final QName TEST_TYPE_WITH_PROPERTIES = QName.createQName(NAMESPACE, "typeWithProperties");
|
public static final QName TEST_TYPE_WITH_PROPERTIES = QName.createQName(NAMESPACE, "typeWithProperties");
|
||||||
public static final QName TEST_TYPE_WITH_ASSOCS = QName.createQName(NAMESPACE, "typeWithAssocs");
|
public static final QName TEST_TYPE_WITH_ASSOCS = QName.createQName(NAMESPACE, "typeWithAssocs");
|
||||||
public static final QName TEST_TYPE_WITH_CHILD_ASSOCS = QName.createQName(NAMESPACE, "typeWithChildAssocs");
|
public static final QName TEST_TYPE_WITH_CHILD_ASSOCS = QName.createQName(NAMESPACE, "typeWithChildAssocs");
|
||||||
|
public static final QName TEST_TYPE_WITH_NON_ENFORCED_CHILD_ASSOCS = QName.createQName(NAMESPACE, "typeWithNonEnforcedChildAssocs");
|
||||||
|
|
||||||
public static final QName TEST_ASSOC_NODE_ZEROMANY_ZEROMANY = QName.createQName(NAMESPACE, "assoc-0to* - 0to*");
|
public static final QName TEST_ASSOC_NODE_ZEROMANY_ZEROMANY = QName.createQName(NAMESPACE, "assoc-0to* - 0to*");
|
||||||
public static final QName TEST_ASSOC_CHILD_ZEROMANY_ZEROMANY = QName.createQName(NAMESPACE, "child-0to* - 0to*");
|
public static final QName TEST_ASSOC_CHILD_ZEROMANY_ZEROMANY = QName.createQName(NAMESPACE, "child-0to* - 0to*");
|
||||||
public static final QName TEST_ASSOC_NODE_ONE_ONE = QName.createQName(NAMESPACE, "assoc-1to1 - 1to1");
|
public static final QName TEST_ASSOC_NODE_ONE_ONE = QName.createQName(NAMESPACE, "assoc-1to1 - 1to1");
|
||||||
public static final QName TEST_ASSOC_CHILD_ONE_ONE = QName.createQName(NAMESPACE, "child-1to1 - 1to1");
|
public static final QName TEST_ASSOC_CHILD_ONE_ONE = QName.createQName(NAMESPACE, "child-1to1 - 1to1");
|
||||||
public static final QName TEST_ASSOC_ASPECT_ONE_ONE = QName.createQName(NAMESPACE, "aspect-assoc-1to1 - 1to1");
|
public static final QName TEST_ASSOC_ASPECT_ONE_ONE = QName.createQName(NAMESPACE, "aspect-assoc-1to1 - 1to1");
|
||||||
|
public static final QName TEST_ASSOC_CHILD_NON_ENFORCED = QName.createQName(NAMESPACE, "child-non-enforced");
|
||||||
|
|
||||||
public static final QName TEST_ASPECT_WITH_PROPERTIES = QName.createQName(NAMESPACE, "aspectWithProperties");
|
public static final QName TEST_ASPECT_WITH_PROPERTIES = QName.createQName(NAMESPACE, "aspectWithProperties");
|
||||||
public static final QName TEST_ASPECT_WITH_ASSOC = QName.createQName(NAMESPACE, "aspectWithAssoc");
|
public static final QName TEST_ASPECT_WITH_ASSOC = QName.createQName(NAMESPACE, "aspectWithAssoc");
|
||||||
|
@@ -106,6 +106,25 @@
|
|||||||
</child-association>
|
</child-association>
|
||||||
</associations>
|
</associations>
|
||||||
</type>
|
</type>
|
||||||
|
<!-- Type with mandatory non-enforced child assocs -->
|
||||||
|
<type name="test:typeWithNonEnforcedChildAssocs">
|
||||||
|
<title>Type With Child Assocs</title>
|
||||||
|
<parent>sys:base</parent>
|
||||||
|
<associations>
|
||||||
|
<child-association name="test:child-non-enforced">
|
||||||
|
<source>
|
||||||
|
<mandatory>false</mandatory>
|
||||||
|
<many>true</many>
|
||||||
|
</source>
|
||||||
|
<target>
|
||||||
|
<class>test:typeWithoutAnything</class>
|
||||||
|
<mandatory>true</mandatory>
|
||||||
|
<many>true</many>
|
||||||
|
</target>
|
||||||
|
<duplicate>false</duplicate>
|
||||||
|
</child-association>
|
||||||
|
</associations>
|
||||||
|
</type>
|
||||||
</types>
|
</types>
|
||||||
|
|
||||||
<aspects>
|
<aspects>
|
||||||
|
@@ -45,7 +45,7 @@
|
|||||||
<child-association name="rule:action">
|
<child-association name="rule:action">
|
||||||
<target>
|
<target>
|
||||||
<class>act:action</class>
|
<class>act:action</class>
|
||||||
<mandatory>true</mandatory>
|
<mandatory enforced="true">true</mandatory>
|
||||||
<many>false</many>
|
<many>false</many>
|
||||||
</target>
|
</target>
|
||||||
</child-association>
|
</child-association>
|
||||||
|
@@ -103,6 +103,13 @@ public interface AssociationDefinition
|
|||||||
*/
|
*/
|
||||||
public boolean isTargetMandatory();
|
public boolean isTargetMandatory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the target class is mandatory, it is enforced?
|
||||||
|
*
|
||||||
|
* @return true => enforced
|
||||||
|
*/
|
||||||
|
public boolean isTargetMandatoryEnforced();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can there be many target class instances in this association?
|
* Can there be many target class instances in this association?
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user