mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge remote-tracking branch 'remotes/origin/release/V3.4' into merge/APPS-236_and_APPS-488_no
This commit is contained in:
19
.travis.yml
19
.travis.yml
@@ -82,12 +82,23 @@ jobs:
|
||||
- name: "Community Rest API Tests"
|
||||
stage: Tests
|
||||
install:
|
||||
- travis_retry travis_wait 90 mvn -B -q install $MVN_SKIP -PbuildDockerImage -pl :alfresco-governance-services-community-repo -am
|
||||
- |
|
||||
if [[ ${TRAVIS_BRANCH} == *community* ]]; then
|
||||
travis_retry travis_wait 90 mvn -B -q install $MVN_SKIP -PbuildDockerImage -pl :alfresco-governance-services-community-repo -am
|
||||
else
|
||||
travis_retry travis_wait 90 mvn -B -q install $MVN_SKIP -PbuildDockerImage -pl :alfresco-governance-services-enterprise-repo -am
|
||||
fi
|
||||
- travis_retry travis_wait 30 mvn -B -U -q clean install ${MVN_SKIP} -pl :alfresco-governance-services-automation-community-rest-api -am
|
||||
before_script:
|
||||
- bash scripts/startAlfresco.sh $COMMUNITY_REPO_PATH
|
||||
- |
|
||||
if [[ ${TRAVIS_BRANCH} == *community* ]]; then
|
||||
bash scripts/startAlfresco.sh $COMMUNITY_REPO_PATH
|
||||
else
|
||||
bash scripts/startAlfresco.sh $ENTERPRISE_REPO_PATH
|
||||
fi
|
||||
- bash scripts/waitForAlfrescoToStart.sh
|
||||
script:
|
||||
- echo "Community Rest API Tests"
|
||||
script: mvn -B test -pl :alfresco-governance-services-automation-community-rest-api -Dskip.automationtests=false
|
||||
after_failure: docker ps -a | grep '_alfresco_1' | awk '{print $1}' | xargs docker logs | tail -5000
|
||||
- name: "Enterprise Rest API Tests"
|
||||
stage: Tests
|
||||
install:
|
||||
|
@@ -86,251 +86,4 @@
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>install-alfresco</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>fetch-installer</id>
|
||||
<phase>generate-test-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<echo>Recreating database...</echo>
|
||||
<sql driver="org.postgresql.Driver" url="jdbc:postgresql:template1" userid="alfresco" password="alfresco" autocommit="true">drop database if exists alfresco; create database alfresco</sql>
|
||||
<echo>Downloading Alfresco installer...</echo>
|
||||
<get src="${installer.url}" dest="target/alf-installer.bin" />
|
||||
<chmod file="target/alf-installer.bin" perm="a+x" verbose="true" />
|
||||
<echo>Installing Alfresco...</echo>
|
||||
<exec executable="${basedir}/target/alf-installer.bin" dir="target" failonerror="true">
|
||||
<arg line="--mode unattended --alfresco_admin_password admin --disable-components postgres,alfrescowcmqs --jdbc_username alfresco --jdbc_password alfresco --prefix ${basedir}/target/alf-installation" />
|
||||
</exec>
|
||||
<delete file="target/alf-installer.bin" verbose="true" />
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>9.1-901-1.jdbc4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>apply-ags-community</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>fetch-amps</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-share</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>amp</type>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>amp</type>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
<outputDirectory>${project.build.directory}/amps</outputDirectory>
|
||||
<useBaseVersion>true</useBaseVersion>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.alfresco.maven.plugin</groupId>
|
||||
<artifactId>alfresco-maven-plugin</artifactId>
|
||||
<extensions>true</extensions>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>install-community-repo-amp</id>
|
||||
<goals>
|
||||
<goal>install</goal>
|
||||
</goals>
|
||||
<phase>process-test-resources</phase>
|
||||
<configuration>
|
||||
<backup>true</backup>
|
||||
<ampLocation>
|
||||
${project.build.directory}/amps/alfresco-governance-services-community-repo-${project.version}.amp
|
||||
</ampLocation>
|
||||
<warLocation>${project.build.directory}/alf-installation/tomcat/webapps/alfresco.war
|
||||
</warLocation>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>install-community-share-amp</id>
|
||||
<goals>
|
||||
<goal>install</goal>
|
||||
</goals>
|
||||
<phase>process-test-resources</phase>
|
||||
<configuration>
|
||||
<backup>true</backup>
|
||||
<ampLocation>
|
||||
${project.build.directory}/amps/alfresco-governance-services-community-share-${project.version}.amp
|
||||
</ampLocation>
|
||||
<warLocation>${project.build.directory}/alf-installation/tomcat/webapps/share.war
|
||||
</warLocation>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>apply-ags-enterprise</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>fetch-amps</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>${ags.share}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>amp</type>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>${ags.repo}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>amp</type>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
<outputDirectory>${project.build.directory}/amps</outputDirectory>
|
||||
<useBaseVersion>true</useBaseVersion>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.alfresco.maven.plugin</groupId>
|
||||
<artifactId>alfresco-maven-plugin</artifactId>
|
||||
<extensions>true</extensions>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>install-enterprise-repo-amp</id>
|
||||
<goals>
|
||||
<goal>install</goal>
|
||||
</goals>
|
||||
<phase>process-test-resources</phase>
|
||||
<configuration>
|
||||
<backup>true</backup>
|
||||
<ampLocation>${project.build.directory}/amps/${ags.repo}-${project.version}.amp</ampLocation>
|
||||
<warLocation>${project.build.directory}/alf-installation/tomcat/webapps/alfresco.war</warLocation>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>install-enterprise-share-amp</id>
|
||||
<goals>
|
||||
<goal>install</goal>
|
||||
</goals>
|
||||
<phase>process-test-resources</phase>
|
||||
<configuration>
|
||||
<backup>true</backup>
|
||||
<ampLocation>${project.build.directory}/amps/${ags.share}-${project.version}.amp</ampLocation>
|
||||
<warLocation>${project.build.directory}/alf-installation/tomcat/webapps/share.war</warLocation>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>run-alfresco</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.7.5.201505241946</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>prepare-jacoco</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>org.alfresco.*</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>start-alfresco</id>
|
||||
<phase>process-test-classes</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<echo>Starting Alfresco...</echo>
|
||||
<exec executable="${basedir}/target/alf-installation/alfresco.sh" dir="target/alf-installation" failonerror="true">
|
||||
<arg value="start" />
|
||||
<env key="CATALINA_OPTS" value="${argLine}" />
|
||||
</exec>
|
||||
<sleep minutes="5" />
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>stop-alfresco</id>
|
||||
<phase>post-integration-test</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<echo>Stopping Alfresco...</echo>
|
||||
<exec executable="${basedir}/target/alf-installation/alfresco.sh" dir="target/alf-installation" failonerror="true">
|
||||
<arg value="stop" />
|
||||
</exec>
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
@@ -139,7 +139,8 @@ public class SearchRecordsV1CmisTests extends BaseRMRestTest
|
||||
assertEquals(searchResponse.getEntries().size(), 5, "Expected total entries to be five");
|
||||
}
|
||||
|
||||
@Test
|
||||
// TODO enable the test when APPS-46 is fixed
|
||||
@Test (enabled = false)
|
||||
public void searchWhenTotalItemsReachWithNonRM()
|
||||
{
|
||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
||||
@@ -173,7 +174,8 @@ public class SearchRecordsV1CmisTests extends BaseRMRestTest
|
||||
assertEquals(searchResponse.getEntries().size(), 4, "Expected total entries to be four");
|
||||
}
|
||||
|
||||
@Test
|
||||
// TODO enable the test when APPS-46 is fixed
|
||||
@Test (enabled = false)
|
||||
public void searchWhenTotalItemsExceedNonRMUser()
|
||||
{
|
||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
||||
@@ -193,7 +195,8 @@ public class SearchRecordsV1CmisTests extends BaseRMRestTest
|
||||
* And setting skipCount and maxItems under the number of total items
|
||||
* Then hasMoreItems will be set to true
|
||||
*/
|
||||
@Test
|
||||
// TODO enable the test when APPS-46 is fixed
|
||||
@Test (enabled = false)
|
||||
public void searchResultsUnderTotalItemsRMUser()
|
||||
{
|
||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
||||
@@ -207,7 +210,8 @@ public class SearchRecordsV1CmisTests extends BaseRMRestTest
|
||||
assertEquals(searchResponse.getEntries().size(), 4, "Expected total entries to be four");
|
||||
}
|
||||
|
||||
@Test
|
||||
// TODO enable the test when APPS-46 is fixed
|
||||
@Test (enabled = false)
|
||||
public void searchResultsUnderTotalItemsNonRMUser()
|
||||
{
|
||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
||||
|
@@ -1,7 +1,11 @@
|
||||
log4j.rootLogger=info, console
|
||||
# Root logger option
|
||||
log4j.rootLogger=INFO, file
|
||||
|
||||
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.console.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.console.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
|
||||
# Direct log messages to a log file
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.File=./target/reports/rm-automation-community-rest-api.log
|
||||
log4j.appender.file.MaxBackupIndex=10
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
log4j.logger.com.example=debug
|
@@ -82,7 +82,7 @@
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<img src="${shareUrl}/res/components/documentlibrary/images/record-64.png" alt="" width="64" height="64" border="0" style="padding-right: 10px;" />
|
||||
<img src="${shareUrl}/rm/components/documentlibrary/images/record-64.png" alt="" width="64" height="64" border="0" style="padding-right: 10px;" />
|
||||
</td>
|
||||
<td>
|
||||
<table cellpadding="2" cellspacing="0" border="0">
|
||||
|
@@ -82,7 +82,7 @@
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<img src="${shareUrl}/res/rm/components/documentlibrary/images/record-64.png" alt="" width="64" height="64" border="0" style="padding-right: 10px;" />
|
||||
<img src="${shareUrl}/rm/components/documentlibrary/images/record-64.png" alt="" width="64" height="64" border="0" style="padding-right: 10px;" />
|
||||
</td>
|
||||
<td>
|
||||
<table cellpadding="2" cellspacing="0" border="0">
|
||||
|
@@ -80,7 +80,7 @@
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<img src="${shareUrl}/res/components/documentlibrary/images/record-64.png" alt="" width="64" height="64" border="0" style="padding-right: 10px;" />
|
||||
<img src="${shareUrl}/rm/components/documentlibrary/images/record-64.png" alt="" width="64" height="64" border="0" style="padding-right: 10px;" />
|
||||
</td>
|
||||
<td>
|
||||
<table cellpadding="2" cellspacing="0" border="0">
|
||||
|
@@ -71,6 +71,7 @@
|
||||
<property name="identifierService" ref="recordsManagementIdentifierService"/>
|
||||
<property name="recordService" ref="RecordService" />
|
||||
<property name="recordFolderService" ref="recordFolderService" />
|
||||
<property name="rmContainerCacheManager" ref="rmContainerCacheManager" />
|
||||
</bean>
|
||||
|
||||
<bean id="rma.nonElectronicRecord" class="org.alfresco.module.org_alfresco_module_rm.model.rma.type.NonElectronicRecordType" parent="rm.baseBehaviour">
|
||||
@@ -123,6 +124,7 @@
|
||||
<property name="capabilityService" ref="CapabilityService" />
|
||||
<property name="authorityService" ref="AuthorityService" />
|
||||
<property name="filePlanType" ref="rma.filePlan" />
|
||||
<property name="rmContainerCacheManager" ref="rmContainerCacheManager" />
|
||||
</bean>
|
||||
|
||||
<!-- rma model aspects -->
|
||||
|
@@ -390,6 +390,14 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- RM Container Cache Manager -->
|
||||
<bean id="rmContainerCache" class="org.alfresco.repo.cache.DefaultSimpleCache" />
|
||||
|
||||
<bean id="rmContainerCacheManager" class="org.alfresco.module.org_alfresco_module_rm.util.RMContainerCacheManager">
|
||||
<property name="nodeService" ref="nodeService" />
|
||||
<property name="cache" ref="rmContainerCache" />
|
||||
</bean>
|
||||
|
||||
<!-- File Plan Service -->
|
||||
|
||||
<bean id="rootContainerCache" class="org.alfresco.repo.cache.DefaultSimpleCache" />
|
||||
@@ -398,6 +406,7 @@
|
||||
parent="baseService"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanServiceImpl">
|
||||
<property name="rootContainerCache" ref="rootContainerCache" />
|
||||
<property name="rmContainerCacheManager" ref="rmContainerCacheManager" />
|
||||
</bean>
|
||||
|
||||
<bean id="FilePlanService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
|
@@ -141,6 +141,7 @@
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
|
@@ -42,6 +42,7 @@ import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.RMContainerCacheManager;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
|
||||
import org.alfresco.repo.cache.SimpleCache;
|
||||
import org.alfresco.repo.domain.node.NodeDAO;
|
||||
@@ -101,6 +102,9 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
||||
/** Site service */
|
||||
private SiteService siteService;
|
||||
|
||||
/** RM container cache manager **/
|
||||
private RMContainerCacheManager rmContainerCacheManager;
|
||||
|
||||
/**
|
||||
* Gets the file plan role service
|
||||
*
|
||||
@@ -174,6 +178,15 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
||||
this.rootContainerCache = rootContainerCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rmContainerCacheManager RM container cache manager
|
||||
*
|
||||
*/
|
||||
public void setRmContainerCacheManager(RMContainerCacheManager rmContainerCacheManager)
|
||||
{
|
||||
this.rmContainerCacheManager = rmContainerCacheManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlans(org.alfresco.service.cmr.repository.StoreRef)
|
||||
*/
|
||||
@@ -185,6 +198,9 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
||||
final Set<NodeRef> results = new HashSet<>();
|
||||
Set<QName> aspects = new HashSet<>(1);
|
||||
aspects.add(ASPECT_RECORDS_MANAGEMENT_ROOT);
|
||||
|
||||
if (!rmContainerCacheManager.isCached(storeRef))
|
||||
{
|
||||
getNodeDAO().getNodesWithAspects(aspects, Long.MIN_VALUE, Long.MAX_VALUE, new NodeDAO.NodeRefQueryCallback()
|
||||
{
|
||||
@Override
|
||||
@@ -194,11 +210,18 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
||||
if (storeRef.equals(nodeRef.getStoreRef()))
|
||||
{
|
||||
results.add(nodeRef);
|
||||
rmContainerCacheManager.add(nodeRef);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return rmContainerCacheManager.get(storeRef);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
|
@@ -33,6 +33,7 @@ import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.RMContainerCacheManager;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
@@ -55,7 +56,8 @@ import org.alfresco.service.namespace.QName;
|
||||
defaultType = "rma:recordsManagementContainer"
|
||||
)
|
||||
public class RecordsManagementContainerType extends BaseBehaviourBean
|
||||
implements NodeServicePolicies.OnCreateChildAssociationPolicy
|
||||
implements NodeServicePolicies.OnCreateChildAssociationPolicy,
|
||||
NodeServicePolicies.OnDeleteChildAssociationPolicy
|
||||
{
|
||||
/** behaviour name */
|
||||
private static final String BEHAVIOUR_NAME = "onCreateContainerType";
|
||||
@@ -69,9 +71,21 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
|
||||
/** record folder service */
|
||||
protected RecordFolderService recordFolderService;
|
||||
|
||||
/** RM container cache manager **/
|
||||
private RMContainerCacheManager rmContainerCacheManager;
|
||||
|
||||
/** I18N */
|
||||
private static final String MSG_CANNOT_CAST_TO_RM_TYPE = "rm.action.cast-to-rm-type";
|
||||
|
||||
/**
|
||||
* @param rmContainerCacheManager RM container cache manager
|
||||
*
|
||||
*/
|
||||
public void setRmContainerCacheManager(RMContainerCacheManager rmContainerCacheManager)
|
||||
{
|
||||
this.rmContainerCacheManager = rmContainerCacheManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param identifierService identifier service
|
||||
*/
|
||||
@@ -194,12 +208,48 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
|
||||
setIdenifierProperty(child);
|
||||
}
|
||||
}
|
||||
|
||||
if (rmContainerCacheManager != null)
|
||||
{
|
||||
rmContainerCacheManager.add(child);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to remove a deleted node from records management root cache
|
||||
*
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnDeleteAssociationPolicy#onDeleteAssociation(org.alfresco.service.cmr.repository.AssociationRef)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.ASSOCIATION,
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||
)
|
||||
public void onDeleteChildAssociation(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork()
|
||||
{
|
||||
// Get the elements of the deleted association
|
||||
final NodeRef child = childAssocRef.getChildRef();
|
||||
|
||||
if (rmContainerCacheManager != null)
|
||||
{
|
||||
rmContainerCacheManager.remove(child);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -39,6 +39,7 @@ import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
||||
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.RMContainerCacheManager;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
@@ -73,7 +74,8 @@ public class RmSiteType extends BaseBehaviourBean
|
||||
implements NodeServicePolicies.OnCreateNodePolicy,
|
||||
NodeServicePolicies.OnUpdatePropertiesPolicy,
|
||||
NodeServicePolicies.BeforeDeleteNodePolicy,
|
||||
NodeServicePolicies.OnCreateChildAssociationPolicy
|
||||
NodeServicePolicies.OnCreateChildAssociationPolicy,
|
||||
NodeServicePolicies.OnDeleteChildAssociationPolicy
|
||||
{
|
||||
/** Constant values */
|
||||
public static final String COMPONENT_DOCUMENT_LIBRARY = "documentLibrary";
|
||||
@@ -95,6 +97,9 @@ public class RmSiteType extends BaseBehaviourBean
|
||||
|
||||
private FilePlanType filePlanType;
|
||||
|
||||
/** RM container cache manager **/
|
||||
private RMContainerCacheManager rmContainerCacheManager;
|
||||
|
||||
/** Map of file plan type's key'ed by corresponding site types */
|
||||
protected Map<QName, QName> mapFilePlanType = new HashMap<>(3);
|
||||
|
||||
@@ -136,6 +141,15 @@ public class RmSiteType extends BaseBehaviourBean
|
||||
this.filePlanType = filePlanType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rmContainerCacheManager RM container cache manager
|
||||
*
|
||||
*/
|
||||
public void setRmContainerCacheManager(RMContainerCacheManager rmContainerCacheManager)
|
||||
{
|
||||
this.rmContainerCacheManager = rmContainerCacheManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a file plan type for a specific site type.
|
||||
*
|
||||
@@ -310,6 +324,36 @@ public class RmSiteType extends BaseBehaviourBean
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles site deletion in order to reset the records management root cache
|
||||
*
|
||||
* @param childAssocRef
|
||||
*
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnDeleteAssociationPolicy#onDeleteAssociation(org.alfresco.service.cmr.repository.AssociationRef)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.ASSOCIATION
|
||||
)
|
||||
public void onDeleteChildAssociation(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork()
|
||||
{
|
||||
// Resets RM Container Cache Manager
|
||||
if (rmContainerCacheManager != null)
|
||||
{
|
||||
rmContainerCacheManager.reset();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the limitation of creating only one rma:filePlan or one dod:filePlan depending on the type of rm site.
|
||||
* Let multiple cm:folder type be created under rm site.
|
||||
@@ -339,6 +383,13 @@ public class RmSiteType extends BaseBehaviourBean
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the deletion node policy (alf:onDeleteNode), resetting the records management root cache
|
||||
* and enabling file plan behavior as well
|
||||
*
|
||||
* @param childAssocRef
|
||||
* @param isNodeArchived
|
||||
*/
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
@@ -347,6 +398,12 @@ public class RmSiteType extends BaseBehaviourBean
|
||||
)
|
||||
public void onDeleteNodeOnCommit(ChildAssociationRef childAssocRef, boolean isNodeArchived)
|
||||
{
|
||||
// Resets RM Container Cache Manager
|
||||
if (rmContainerCacheManager != null)
|
||||
{
|
||||
rmContainerCacheManager.reset();
|
||||
}
|
||||
|
||||
filePlanType.enable();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.util;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.cache.SimpleCache;
|
||||
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.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
/**
|
||||
* Provides operations to manipulate the records management root cache
|
||||
*
|
||||
* @author Tiago Salvado
|
||||
*
|
||||
* @see RecordsManagementModel
|
||||
*/
|
||||
public class RMContainerCacheManager implements RecordsManagementModel
|
||||
{
|
||||
/** node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/** root records management cache */
|
||||
private SimpleCache<Pair<StoreRef, String>, Set<NodeRef>> cache;
|
||||
|
||||
/**
|
||||
* @param nodeService
|
||||
* node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cache
|
||||
*/
|
||||
public void setCache(SimpleCache<Pair<StoreRef, String>, Set<NodeRef>> cache)
|
||||
{
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if there is cached nodes for supplied storeRef
|
||||
*
|
||||
* @param storeRef
|
||||
* @return true if there are cached nodes, false otherwise
|
||||
*/
|
||||
public boolean isCached(StoreRef storeRef)
|
||||
{
|
||||
return cache.contains(getKey(storeRef));
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the cached nodes for supplied storeRef
|
||||
*
|
||||
* @param storeRef
|
||||
* @return a set containing the cached nodes
|
||||
*/
|
||||
public Set<NodeRef> get(StoreRef storeRef)
|
||||
{
|
||||
return cache.get(getKey(storeRef));
|
||||
}
|
||||
|
||||
/**
|
||||
* Caches the supplied node
|
||||
*
|
||||
* @param nodeRef
|
||||
*/
|
||||
public void add(NodeRef nodeRef)
|
||||
{
|
||||
if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT))
|
||||
{
|
||||
Set<NodeRef> entries;
|
||||
Pair<StoreRef, String> key = getKey(nodeRef.getStoreRef());
|
||||
|
||||
if (cache.contains(key))
|
||||
{
|
||||
entries = this.cache.get(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
entries = new HashSet<>();
|
||||
}
|
||||
|
||||
if (!entries.contains(nodeRef))
|
||||
{
|
||||
entries.add(nodeRef);
|
||||
}
|
||||
|
||||
cache.put(key, entries);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the supplied entry from the cache
|
||||
*
|
||||
* @param nodeRef
|
||||
*/
|
||||
public void remove(NodeRef nodeRef)
|
||||
{
|
||||
if (nodeRef != null)
|
||||
{
|
||||
if (nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT))
|
||||
{
|
||||
Pair<StoreRef, String> key = getKey(nodeRef.getStoreRef());
|
||||
if (cache.contains(key))
|
||||
{
|
||||
cache.get(key).remove(nodeRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the cache entries
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
this.cache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the cache key using the supplied storeRef
|
||||
*
|
||||
* @param storeRef
|
||||
* @return a pair corresponding to the cache key
|
||||
*/
|
||||
private Pair<StoreRef, String> getKey(StoreRef storeRef)
|
||||
{
|
||||
return new Pair<StoreRef, String>(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString());
|
||||
}
|
||||
}
|
@@ -57,6 +57,7 @@ import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.RMContainerCacheManager;
|
||||
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService;
|
||||
import org.alfresco.repo.policy.BehaviourFilter;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
@@ -173,6 +174,9 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
protected InplaceRecordService inplaceRecordService;
|
||||
protected RelationshipService relationshipService;
|
||||
|
||||
/** RM Container Cache Manager */
|
||||
protected RMContainerCacheManager rmContainerCacheManager;
|
||||
|
||||
/** test utils */
|
||||
protected UserAndGroupsUtils userAndGroupsUtils;
|
||||
|
||||
@@ -424,6 +428,9 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
holdService = (HoldService) applicationContext.getBean("HoldService");
|
||||
inplaceRecordService = (InplaceRecordService) applicationContext.getBean("InplaceRecordService");
|
||||
relationshipService = (RelationshipService) applicationContext.getBean("RelationshipService");
|
||||
|
||||
// RM Container Cache Manager
|
||||
rmContainerCacheManager = (RMContainerCacheManager) applicationContext.getBean("rmContainerCacheManager");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -484,6 +491,11 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
{
|
||||
siteService.deleteSite(collabSiteId);
|
||||
}
|
||||
|
||||
if (rmContainerCacheManager != null)
|
||||
{
|
||||
rmContainerCacheManager.reset();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
Reference in New Issue
Block a user