Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)

78392: Merged EOL (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud)
      75693: ACE-2149 Remove AVM/WCM - first round, based on the following Sparta commits
         08f1ff556cf3e8eb370e433b69b634026c848af1: SlimRepo: comment-out AVM schema bootstrap and wcm-services-context
            - plus associated bootstrap/startup fallout
            - note: disabling/removing WCM/AVM will be a work-in-progress due to tight code coupling :-(
         cdb78eeae53522cc2d78feb94be49d11648fa582; SlimRepo: comment-out AVM schema bootstrap and wcm-services-context
             - follow-on to fix "regenerate_renditions" fallout error (in Alfresco Explorer web client)
         33337ad4239df91b9a8dc7a00be43e55ffef5bef: SlimRepo: remove WCM/AVM - round 1 (wip)
            - removal of some of the AVM code and tests (including core impl such as AVMServiceImpl, AVMRepository, AVMSyncServiceImpl, underlying DAOs etc)
            - fix Spring config (major impact) and any obvious compile-time fallout
            - ensured repo starts and ran (some of the) repo unit tests
            - also check basic Explorer access
         47e50847bbbbdda5fd64a27c212dfbdd625cbfdb: Jenkins build/test repo - minor: disable/remove repo tests
            - disabled unused tests, removed remaining AVM* tests


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@82537 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Erik Winlof
2014-09-03 11:57:51 +00:00
parent a78c593e83
commit f01f727e5e
102 changed files with 10194 additions and 36653 deletions

View File

@@ -624,86 +624,6 @@
</bean>
<!-- deprecated - see "wcm-submit" (wcm-services-context.xml) -->
<bean id="simple-avm-submit" class="org.alfresco.repo.avm.actions.SimpleAVMSubmitAction" parent="action-executer">
<property name="avmService">
<ref bean="AVMService"/>
</property>
<property name="avmSyncService">
<ref bean="avmSyncService"/>
</property>
<property name="excluder">
<ref bean="globalPathExcluder"/>
</property>
<property name="publicAction">
<value>false</value>
</property>
</bean>
<!-- deprecated -->
<bean id="start-avm-workflow" class="org.alfresco.repo.avm.actions.StartAVMWorkflowAction" parent="action-executer">
<property name="workflowService">
<ref bean="WorkflowService"/>
</property>
<property name="personService">
<ref bean="personService"/>
</property>
<property name="publicAction">
<value>false</value>
</property>
</bean>
<!-- deprecated -->
<bean id="simple-avm-promote" class="org.alfresco.repo.avm.actions.SimpleAVMPromoteAction" parent="action-executer">
<property name="avmSyncService">
<ref bean="avmSyncService"/>
</property>
<property name="publicAction">
<value>false</value>
</property>
</bean>
<!-- deprecated - see "wcm-revert-snapshot" (wcm-services-context.xml) -->
<bean id="avm-revert-store" class="org.alfresco.repo.avm.actions.AVMRevertStoreAction" parent="action-executer">
<property name="avmSyncService">
<ref bean="avmSyncService"/>
</property>
<property name="publicAction">
<value>false</value>
</property>
</bean>
<!-- deprecated -->
<bean id="avm-revert-list" class="org.alfresco.repo.avm.actions.AVMRevertListAction" parent="action-executer">
<property name="avmSyncService">
<ref bean="avmSyncService"/>
</property>
<property name="publicAction">
<value>false</value>
</property>
</bean>
<!-- deprecated - note: still used by Web-Client (FileDetailsBean) -->
<bean id="avm-revert-to-version" class="org.alfresco.repo.avm.actions.AVMRevertToVersionAction" parent = "action-executer">
<property name="avmService">
<ref bean="AVMLockingAwareService"/>
</property>
<property name="publicAction">
<value>false</value>
</property>
</bean>
<!-- deprecated - see "wcm-undo" (wcm-services-context.xml) -->
<bean id="avm-undo-list" class="org.alfresco.repo.avm.actions.AVMUndoSandboxListAction" parent="action-executer">
<property name="avmService">
<ref bean="AVMService"/>
</property>
<property name="avmLockingService">
<ref bean="AVMLockingService"/>
</property>
<property name="publicAction">
<value>false</value>
</property>
</bean>
<!-- deprecated - note: still used by Web-Client (*Deploy*) -->
<bean id="avm-deploy-website" class="org.alfresco.repo.avm.actions.AVMDeployWebsiteAction" parent="action-executer">

View File

@@ -37,8 +37,10 @@
<import resource="classpath:alfresco/bootstrap-context.xml" />
<import resource="classpath:alfresco/repo-admin-context.xml"/>
<import resource="classpath:alfresco/workflow-context.xml" />
<!-- Sparta: disable/remove WCM/AVM
<import resource="classpath:alfresco/avm-services-context.xml" />
<import resource="classpath:alfresco/wcm-services-context.xml"/>
-->
<import resource="classpath:alfresco/audit-services-context.xml" />
<import resource="classpath:alfresco/attributes-service-context.xml"/>
<import resource="classpath:alfresco/deployment-service-context.xml"/>

View File

@@ -214,9 +214,11 @@
<property name="searchService">
<ref bean="SearchService" />
</property>
<!-- Sparta: disable/remove WCM/AVM (note: sandboxFactory is defined in wcm-services-context.xml)
<property name="sandboxFactory">
<ref bean="sandboxFactory" />
</property>
-->
</bean>
<!-- AVM Locking. -->

View File

@@ -101,10 +101,12 @@
</property>
<property name="schemaReferenceUrls">
<list>
<!-- Sparta: ignore schema reference for now
<value>classpath:alfresco/dbscripts/create/${db.script.dialect}/Schema-Reference-ALF.xml</value>
<value>classpath:alfresco/dbscripts/create/${db.script.dialect}/Schema-Reference-AVM.xml</value>
<value>classpath:alfresco/dbscripts/create/${db.script.dialect}/Schema-Reference-JBPM.xml</value>
<value>classpath:alfresco/dbscripts/create/${db.script.dialect}/Schema-Reference-ACT.xml</value>
-->
</list>
</property>
</bean>
@@ -122,6 +124,8 @@
</bean>
<!-- Bootstrap the AVM -->
<!-- Sparta: disable WCM/AVM
<bean id="avmBootstrap" class="org.alfresco.repo.avm.AvmBootstrap" >
<property name="avmLockingAwareService">
<ref bean="avmLockingAwareService"/>
@@ -136,6 +140,7 @@
<ref bean="avmSyncService"/>
</property>
</bean>
-->
<!-- Load models -->
<bean id="dictionaryRepositoryBootstrap" class="org.alfresco.repo.dictionary.DictionaryRepositoryBootstrap">
@@ -186,7 +191,10 @@
-->
<bean id="siteLoadBootstrap-Spaces" parent="spacesStoreImporter" singleton="true" />
<bean id="siteLoadBootstrap-Users" parent="userStoreImporter" singleton="true" />
<!-- Sparta: remove WCM/AVM
<bean id="siteLoadBootstrap-AVM" parent="sitesAVMZipBootstrap-base" singleton="true" />
-->
<bean id="workflowBootstrap" parent="workflowDeployer">
<property name="workflowDefinitions">

View File

@@ -108,9 +108,11 @@
<property name="contentService" >
<ref bean="contentService" />
</property>
<!-- Sparta: remove WCM/AVM
<property name="avmNodeDAO">
<ref bean="newAvmNodeDAO"/>
</property>
-->
<property name="transactionService" >
<ref bean="transactionService" />
</property>

View File

@@ -1240,6 +1240,7 @@
</property>
</bean>
<!-- Sparta: remove WCM/AVM
<bean id="avmLuceneIndexerAndSearcherFactory" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
<property name="sourceApplicationContextFactory">
<ref bean="Search" />
@@ -1254,6 +1255,7 @@
</list>
</property>
</bean>
-->
<bean id="admLuceneIndexerAndSearcherFactory" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory" depends-on="Search" >
<property name="sourceApplicationContextFactory">
@@ -1342,6 +1344,7 @@
</property>
</bean>
<!-- Sparta: remove WCM/AVM
<bean id="avmIndexRecoveryComponent" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
<property name="sourceApplicationContextFactory">
<ref bean="Search" />
@@ -1355,6 +1358,7 @@
</list>
</property>
</bean>
-->
<!-- only required for lucene index test support -->

View File

@@ -225,6 +225,8 @@
<!-- AVM -->
<!-- Sparta: remove WCM/AVM
<bean id="newAvmStoreDAO" class="org.alfresco.repo.domain.avm.ibatis.AVMStoreDAOImpl">
<property name="sqlSessionTemplate" ref="avmSqlSessionTemplate"/>
<property name="qnameDAO" ref="qnameDAO"/>
@@ -256,6 +258,7 @@
<property name="propertyValueDAO" ref="propertyValueDAO"/>
<property name="propertyUniqueContextCache" ref="propertyUniqueContextCache"/>
</bean>
-->
<!-- Permissions (including ACLs / ACEs) -->
@@ -270,11 +273,15 @@
<map>
<entry key="workspace"><ref bean="admPermissionsDaoComponent"></ref></entry>
<entry key="versionStore"><ref bean="admPermissionsDaoComponent"></ref></entry>
<!-- Sparta: remove WCM/AVM
<entry key="avm"><ref bean="avmPermissionsDaoComponent"/></entry>
-->
</map>
</property>
</bean>
<!-- Sparta: remove WCM/AVM
<bean id="avmPermissionsDaoComponent" class="org.alfresco.repo.domain.permissions.AVMPermissionsDaoComponentImpl">
<property name="aclDAO">
<ref bean="aclDAO"/>
@@ -289,6 +296,7 @@
<ref bean="admNodeACLDAO"/>
</property>
</bean>
-->
<bean id="admPermissionsDaoComponent" class="org.alfresco.repo.domain.permissions.ADMPermissionsDaoComponentImpl">
<property name="aclDAO">
@@ -312,12 +320,14 @@
<property name="preserveAuditableData" value="${system.auditableData.ACLs}"></property>
</bean>
<!-- Sparta: remove WCM/AVM
<bean id="avmNodeACLDAO" class="org.alfresco.repo.domain.permissions.AVMAccessControlListDAO">
<property name="avmRepository" ref="avmRepository"/>
<property name="avmService" ref="avmService"/>
<property name="aclDAO" ref="aclDAO"/>
<property name="avmNodeDAO" ref="newAvmNodeDAO"/>
</bean>
-->
<bean id="aclCrudDAO" class="org.alfresco.repo.domain.permissions.ibatis.AclCrudDAOImpl">
<property name="sqlSessionTemplate" ref="repoSqlSessionTemplate"/>

View File

@@ -1190,6 +1190,7 @@
</property>
</bean>
<!-- Sparta: remove WCM/AVM
<bean id="patch.resetWCMToGroupBasedPermissionsPatch" class="org.alfresco.repo.admin.patch.impl.ResetWCMToGroupBasedPermissionsPatch" parent="basePatch" >
<property name="id"><value>patch.resetWCMToGroupBasedPermissionsPatch</value></property>
<property name="description"><value>patch.resetWCMToGroupBasedPermissionsPatch.description</value></property>
@@ -1235,8 +1236,10 @@
<value>ContentManager</value>
</property>
</bean>
-->
<!-- note: does not need to be run if patch.wcmPostPermissionSnapshotPatch2 already applied -->
<!-- Sparta: remove WCM/AVM
<bean id="patch.wcmPostPermissionSnapshotPatch3" class="org.alfresco.repo.admin.patch.impl.WCMPostPermissionSnapshotPatch" parent="basePatch" >
<property name="id"><value>patch.wcmPostPermissionSnapshotPatch3</value></property>
<property name="description"><value>patch.wcmPostPermissionSnapshotPatch.description</value></property>
@@ -1264,8 +1267,10 @@
<ref bean="patchDAO"/>
</property>
</bean>
-->
<!-- note: NOOP - superceded by patch.resetWCMToGroupBasedPermissionsPatch -->
<!-- Sparta: remove WCM/AVM
<bean id="patch.moveWCMToGroupBasedPermissionsPatch" class="org.alfresco.repo.admin.patch.impl.NoOpPatch" parent="basePatch" >
<property name="id"><value>patch.moveWCMToGroupBasedPermissionsPatch</value></property>
<property name="description"><value>patch.noOpPatch.description</value></property>
@@ -1278,8 +1283,10 @@
</list>
</property>
</bean>
-->
<!-- note: NOOP - superceded by patch.wcmPostPermissionSnapshotPatch3 -->
<!-- Sparta: remove WCM/AVM
<bean id="patch.wcmPostPermissionSnapshotPatch2" class="org.alfresco.repo.admin.patch.impl.NoOpPatch" parent="basePatch" >
<property name="id"><value>patch.wcmPostPermissionSnapshotPatch2</value></property>
<property name="description"><value>patch.noOpPatch.description</value></property>
@@ -1292,6 +1299,7 @@
</list>
</property>
</bean>
-->
<!-- Redeploy both direct and indirect submit processes for addition submit failure handling -->
<bean id="patch.redeploySubmitProcess6" class="org.alfresco.repo.admin.patch.impl.GenericWorkflowPatch" parent="baseWorkflowPatch" >

View File

@@ -851,7 +851,9 @@
<value>avmServiceWriteTxnAdvisor</value>
<value>avmServiceReadTxnAdvisor</value>
<value>checkTxnAdvisor</value>
<!-- Sparta: remove WCM/AVM
<value>avmSnapShotTriggeredIndexingMethodInterceptor</value>
-->
</list>
</property>
</bean>
@@ -898,10 +900,12 @@
</property>
</bean>
<bean id="avmServiceBase" class="org.alfresco.repo.avm.AVMServiceImpl">
<bean id="avmServiceBase" class="org.alfresco.repo.avm.AVMServiceNOOPImpl">
<!-- Sparta: remove WCM/AVM - use NOOP impl for now (see also AVMSyncServiceNOOPImpl)
<property name="avmRepository">
<ref bean="avmRepository"/>
</property>
-->
</bean>
<bean id="checkTxnAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
@@ -1023,7 +1027,9 @@
<value>avmServiceWriteTxnAdvisor</value>
<value>avmServiceReadTxnAdvisor</value>
<value>checkTxnAdvisor</value>
<!-- Sparta: remove WCM/AVM
<value>avmSnapShotTriggeredIndexingMethodInterceptor</value>
-->
</list>
</property>
</bean>
@@ -1045,6 +1051,7 @@
</property>
</bean>
<!-- Sparta: remove WCM/AVM
<bean id="avmSnapShotTriggeredIndexingMethodInterceptor" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
<property name="sourceApplicationContextFactory">
<ref bean="Search" />
@@ -1058,16 +1065,20 @@
</list>
</property>
</bean>
-->
<!-- The AVMSyncService -->
<bean id="avmSyncService" class="org.alfresco.repo.avm.AVMSyncServiceImpl">
<bean id="avmSyncService" class="org.alfresco.repo.avm.AVMSyncServiceNOOPImpl">
<!-- Sparta: remove WCM/AVM - use NOOP impl for now (see also AVMServiceNOOPImpl)
<property name="avmService">
<ref bean="AVMService"/>
</property>
<property name="avmRepository">
<ref bean="avmRepository"/>
</property>
-->
</bean>
<!-- Read transaction advisor for sync service. -->

View File

@@ -43,6 +43,7 @@
<!-- Query collections should be loaded on demand using this component - once loaded thay are available for use -->
</bean>
<!-- Sparta: remove WCM/AVM
<bean id="search.avmSnapShotTriggeredIndexingMethodInterceptor" class="org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptorImpl">
<property name="avmService">
<ref bean="avmService" />
@@ -131,6 +132,7 @@
<property name="nodeDAO" ref="nodeDAO"/>
<property name="tenantService" ref="tenantService"/>
</bean>
-->
<bean id="search.dbQueryEngine" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">

View File

@@ -11,12 +11,13 @@
</property>
</bean>
<!-- Sparta: remove WCM/AVM
<bean id="search.avmIndexRecoveryBootstrap" class="org.alfresco.repo.node.index.IndexRecoveryBootstrapBean" >
<property name="indexRecoveryComponent">
<ref bean="search.avmIndexRecoveryComponent"/>
</property>
</bean>
-->
<bean id="search.indexConfigurationCheckerBootstrap" class="org.alfresco.repo.admin.IndexConfigurationCheckerBootstrapBean">
<property name="strict">

View File

@@ -78,6 +78,7 @@
</property>
</bean>
<!-- Sparta: remove WCM/AVM
<bean
id="search.avmIndexRecoveryComponent"
class="org.alfresco.repo.node.index.AVMFullIndexRecoveryComponent"
@@ -92,6 +93,7 @@
<ref bean="search.avmSnapShotTriggeredIndexingMethodInterceptor" />
</property>
</bean>
-->
<!-- Index tracking -->
@@ -155,6 +157,7 @@
<!-- AVM (WCM) index tracking -->
<!--===========================-->
<!-- Sparta: remove WCM/AVM
<bean
id="search.avmIndexTrackerComponent"
class="org.alfresco.repo.node.index.AVMRemoteSnapshotTracker"
@@ -179,9 +182,9 @@
</map>
</property>
</bean>
<bean id="search.avmIndexJobDetail" parent="search.baseAvmIndexJobDetail"/>
<!-- Schedule index tracking for AVM -->
<bean id="search.avmIndexTrackerTrigger" class="org.alfresco.util.CronTriggerBean">
<property name="jobDetail" ref="search.avmIndexJobDetail"/>
<property name="scheduler">
@@ -194,6 +197,7 @@
<value>${system.cronJob.startDelayMinutes}</value>
</property>
</bean>
-->
<!-- Failed FTS reindexer -->
<!--

View File

@@ -52,9 +52,11 @@
<entry key="workspace">
<ref bean="search.admLuceneIndexerAndSearcherFactory"></ref>
</entry>
<!-- Sparta: remove WCM/AVM
<entry key="avm">
<ref bean="search.avmLuceneIndexerAndSearcherFactory"></ref>
</entry>
-->
</map>
</property>
<property name="redirectedStoreBindings">
@@ -111,7 +113,9 @@
<list>
<ref bean="search.admLuceneIndexerAndSearcherFactory" />
<ref bean="search.admLuceneUnIndexedIndexerAndSearcherFactory" />
<!-- Sparta: remove WCM/AVM
<ref bean="search.avmLuceneIndexerAndSearcherFactory" />
-->
</list>
</property>
</bean>
@@ -121,7 +125,9 @@
<list>
<ref bean="search.admLuceneIndexerAndSearcherFactory" />
<ref bean="search.admLuceneUnIndexedIndexerAndSearcherFactory" />
<!-- Sparta: remove WCM/AVM
<ref bean="search.avmLuceneIndexerAndSearcherFactory" />
-->
</list>
</property>
</bean>
@@ -134,7 +140,9 @@
<list>
<ref bean="search.admLuceneIndexerAndSearcherFactory" />
<ref bean="search.admLuceneUnIndexedIndexerAndSearcherFactory" />
<!-- Sparta: remove WCM/AVM
<ref bean="search.avmLuceneIndexerAndSearcherFactory" />
-->
</list>
</property>
</bean>
@@ -341,6 +349,7 @@
</bean>
<!-- Indexer and searchers for lucene -->
<!-- Sparta: remove WCM/AVM
<bean id="search.avmLuceneIndexerAndSearcherFactory"
parent="search.abstractLuceneIndexerAndSearcherFactory"
class="org.alfresco.repo.search.impl.lucene.AVMLuceneIndexerAndSearcherFactory">
@@ -384,7 +393,9 @@
<ref bean="transformerDebug"></ref>
</property>
</bean>
-->
<!-- Sparta: remove WCM/AVM
<bean id="search.avm.luceneQueryEngineImpl" class="org.alfresco.repo.search.impl.querymodel.impl.lucene.LuceneQueryEngine" >
<property name="dictionaryService">
<ref bean="dictionaryService" />
@@ -408,6 +419,7 @@
<value>${lucene.indexer.maxRawResultSetSizeForInMemorySort}</value>
</property>
</bean>
-->
<!-- Indexer and searchers for lucene -->
<bean id="search.luceneCategoryService" class="org.alfresco.repo.search.impl.lucene.LuceneCategoryServiceImpl">
@@ -478,8 +490,10 @@
<property name="searchService">
<ref bean="search.searchService"/>
</property>
<!-- Sparta: remove WCM/AVM
<property name="avmSnapShotTriggeredIndexingMethodInterceptor">
<ref bean="search.avmSnapShotTriggeredIndexingMethodInterceptor"/>
</property>
-->
</bean>
</beans>

View File

@@ -26,7 +26,9 @@
<list>
<ref bean="search.admLuceneIndexerAndSearcherFactory" />
<ref bean="search.admLuceneUnIndexedIndexerAndSearcherFactory" />
<!-- Sparta: remove WCM/AVM
<ref bean="search.avmLuceneIndexerAndSearcherFactory" />
-->
</list>
</property>
</bean>
@@ -39,7 +41,9 @@
<list>
<ref bean="search.admLuceneIndexerAndSearcherFactory" />
<ref bean="search.admLuceneUnIndexedIndexerAndSearcherFactory" />
<!-- Sparta: remove WCM/AVM
<ref bean="search.avmLuceneIndexerAndSearcherFactory" />
-->
</list>
</property>
</bean>

View File

@@ -40,9 +40,11 @@
<property name="diskInterface">
<ref bean="contentDiskDriver"/>
</property>
<!-- Sparta: remove WCM/AVM
<property name="avmDiskInterface">
<ref bean="avmDiskDriver"/>
</property>
-->
</bean>
<!-- IO Handler -->
@@ -438,6 +440,7 @@
</bean>
<!-- WCM/AVM Filesystem Interface -->
<!-- Sparta: remove WCM/AVM
<bean id="avmDiskDriver" class="org.alfresco.filesys.avm.AVMDiskDriver">
<property name="avmService"><ref bean="AVMLockingAwareService"/></property>
<property name="transactionService"><ref bean="transactionService"/></property>
@@ -452,4 +455,6 @@
<property name="createVersionListener"><ref bean="createVersionTxnListener"/></property>
<property name="purgeVersionListener"><ref bean="purgeVersionTxnListener"/></property>
</bean>
-->
</beans>

View File

@@ -23,4 +23,4 @@ version.build=r@scm-revision@-b@build-number@
# Schema number
version.schema=8001
version.schema=8002

View File

@@ -23,8 +23,6 @@ import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.node.index.FullIndexRecoveryComponent.RecoveryMode;
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
import org.alfresco.repo.search.IndexMode;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.InvalidStoreRefException;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -51,7 +49,7 @@ public class IndexConfigurationCheckerImpl implements IndexConfigurationChecker
private RecoveryMode indexRecoveryMode;
private NodeService nodeService;
private SearchService searchService;
private AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor;
//private AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor;
/**
* Set the index recovert mode
@@ -87,10 +85,12 @@ public class IndexConfigurationCheckerImpl implements IndexConfigurationChecker
* avm trigger
* @param avmSnapShotTriggeredIndexingMethodInterceptor
*/
/* Sparta: remove WCM/AVM
public void setAvmSnapShotTriggeredIndexingMethodInterceptor(AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor)
{
this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor;
}
*/
@@ -129,6 +129,7 @@ public class IndexConfigurationCheckerImpl implements IndexConfigurationChecker
{
if (storeRef.getProtocol().equals(StoreRef.PROTOCOL_AVM))
{
/* Sparta: remove WCM/AVM
if (avmSnapShotTriggeredIndexingMethodInterceptor.isIndexingEnabled())
{
IndexMode storeIndexMode = avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(storeRef.getIdentifier());
@@ -149,6 +150,7 @@ public class IndexConfigurationCheckerImpl implements IndexConfigurationChecker
}
continue;
}
*/
}
if (logger.isDebugEnabled())

View File

@@ -21,7 +21,6 @@ package org.alfresco.repo.admin.patch.impl;
import java.sql.Savepoint;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.alfresco.error.AlfrescoRuntimeException;
@@ -29,8 +28,6 @@ import org.alfresco.repo.admin.patch.AbstractPatch;
import org.alfresco.repo.admin.patch.PatchExecuter;
import org.alfresco.repo.admin.registry.RegistryKey;
import org.alfresco.repo.admin.registry.RegistryService;
import org.alfresco.repo.avm.AVMDAOs;
import org.alfresco.repo.avm.PlainFileNode;
import org.alfresco.repo.batch.BatchProcessor;
import org.alfresco.repo.batch.BatchProcessor.BatchProcessWorkerAdaptor;
import org.alfresco.repo.content.ContentStore;
@@ -39,14 +36,13 @@ import org.alfresco.repo.domain.contentdata.ContentDataDAO;
import org.alfresco.repo.domain.control.ControlDAO;
import org.alfresco.repo.domain.patch.PatchDAO;
import org.alfresco.repo.lock.JobLockService;
import org.alfresco.repo.lock.LockAcquisitionException;
import org.alfresco.repo.lock.JobLockService.JobLockRefreshCallback;
import org.alfresco.repo.lock.LockAcquisitionException;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
@@ -316,8 +312,13 @@ public class ContentUrlConverterPatch extends AbstractPatch
logger.info(I18NUtil.getMessage("patch.convertContentUrls.adm.start"));
boolean admCompleted = applyADMLooping(running);
/* Sparta: remove WCM/AVM
logger.info(I18NUtil.getMessage("patch.convertContentUrls.avm.start"));
boolean avmCompleted = applyAVMLooping(running);
*/
boolean avmCompleted = true;
logger.info(I18NUtil.getMessage("patch.convertContentUrls.store.start", contentStore));
boolean urlLiftingCompleted = applyUrlLifting(running);
@@ -468,6 +469,7 @@ public class ContentUrlConverterPatch extends AbstractPatch
return false;
}
/*
private boolean applyAVMLooping(final AtomicBoolean running)
{
RetryingTransactionCallback<Boolean> callback = new RetryingTransactionCallback<Boolean>()
@@ -488,10 +490,12 @@ public class ContentUrlConverterPatch extends AbstractPatch
}
return done;
}
*/
/**
* Do the AVM conversion work
*/
/*
private boolean applyAVM() throws Exception
{
Long maxId = (Long) registryService.getProperty(KEY_AVM_MAX_ID);
@@ -563,6 +567,7 @@ public class ContentUrlConverterPatch extends AbstractPatch
// More to do
return false;
}
*/
private boolean applyUrlLifting(final AtomicBoolean running) throws Exception
{

View File

@@ -1,426 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.admin.patch.impl;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.admin.patch.AbstractPatch;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptorImpl.StoreType;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.security.AccessPermission;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* Remove ACLs on all but staging area stores On staging area stores, set ACls according to the users and roles as set
* on the web site Note: runs as the system user
*
* @author andyh
*/
public class MoveWCMToGroupBasedPermissionsPatch extends AbstractPatch
{
public static final String[] PERMISSIONS = new String[]
{
PermissionService.WCM_CONTENT_MANAGER, PermissionService.WCM_CONTENT_PUBLISHER,
PermissionService.WCM_CONTENT_CONTRIBUTOR, PermissionService.WCM_CONTENT_REVIEWER
};
protected static final String WCM_STORE_SEPARATOR = "--";
private static final String MSG_SUCCESS = "patch.moveWCMToGroupBasedPermissionsPatch.result";
AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor;
AVMService avmService;
PermissionService permissionService;
AuthorityService authorityService;
String replaceAllWith = PermissionService.WCM_CONTENT_MANAGER;
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
public void setAvmSnapShotTriggeredIndexingMethodInterceptor(
AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor)
{
this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor;
}
public void setPermissionService(PermissionService permissionService)
{
this.permissionService = permissionService;
}
public void setAuthorityService(AuthorityService authorityService)
{
this.authorityService = authorityService;
}
public void setReplaceAllWith(String replaceAllWith)
{
this.replaceAllWith = replaceAllWith;
}
@Override
protected String applyInternal() throws Exception
{
List<AVMStoreDescriptor> stores = this.avmService.getStores();
for (AVMStoreDescriptor store : stores)
{
Map<QName, PropertyValue> storeProperties = this.avmService.getStoreProperties(store.getName());
switch (StoreType.getStoreType(store.getName(), store, storeProperties))
{
/* Set permissions in staging */
case STAGING:
fixAllPermissions(store);
setStagingAreaPermissions(store);
setStagingAreaMasks(store);
// TODO: mark read only
break;
/* Clear permissions */
case AUTHOR:
case AUTHOR_PREVIEW:
case AUTHOR_WORKFLOW:
case AUTHOR_WORKFLOW_PREVIEW:
fixAllStagingPermissions(store);
setSandBoxMasks(store);
break;
case STAGING_PREVIEW:
fixAllStagingPermissions(store);
setStagingAreaMasks(store);
// TODO: mark read only
break;
case WORKFLOW:
case WORKFLOW_PREVIEW:
break;
/* non WCM stores - nothing to do */
case UNKNOWN:
default:
}
}
// build the result message
String msg = I18NUtil.getMessage(MoveWCMToGroupBasedPermissionsPatch.MSG_SUCCESS);
// done
return msg;
}
private boolean isPermissionSet(NodeRef nodeRef, String authority, String permission)
{
Set<AccessPermission> set = this.permissionService.getAllSetPermissions(nodeRef);
for (AccessPermission ap : set)
{
if (ap.getAuthority().equals(authority) && ap.isSetDirectly() && ap.getPermission().equals(permission))
{
return true;
}
}
return false;
}
private boolean isMaskSet(StoreRef storeRef, String authority, String permission)
{
Set<AccessPermission> set = this.permissionService.getAllSetPermissions(storeRef);
for (AccessPermission ap : set)
{
if (ap.getAuthority().equals(authority) && ap.isSetDirectly() && ap.getPermission().equals(permission))
{
return true;
}
}
return false;
}
private void makeGroupsIfRequired(String stagingStoreName, NodeRef dirRef)
{
for (String permission : MoveWCMToGroupBasedPermissionsPatch.PERMISSIONS)
{
String shortName = stagingStoreName + "-" + permission;
String group = this.authorityService.getName(AuthorityType.GROUP, shortName);
if (!this.authorityService.authorityExists(group))
{
String newGroup = this.authorityService.createAuthority(AuthorityType.GROUP, shortName);
this.permissionService.setPermission(dirRef, newGroup, permission, true);
}
}
}
protected void addToGroupIfRequired(String stagingStoreName, String user, String permission)
{
String shortName = stagingStoreName + "-" + permission;
String group = this.authorityService.getName(AuthorityType.GROUP, shortName);
Set<String> members = this.authorityService.getContainedAuthorities(AuthorityType.USER, group, true);
if (!members.contains(user))
{
this.authorityService.addAuthority(group, user);
}
}
private void fixAllPermissions(AVMStoreDescriptor store)
{
fixAllPermissionsImpl(store.getName());
}
private void fixAllStagingPermissions(AVMStoreDescriptor store)
{
String stagingAreaName = extractStagingAreaName(store.getName());
fixAllPermissionsImpl(stagingAreaName);
}
private void fixAllPermissionsImpl(String stagingStoreName)
{
QName propQName = QName.createQName(null, ".web_project.noderef");
PropertyValue pValue = this.avmService.getStoreProperty(stagingStoreName, propQName);
if (pValue != null)
{
NodeRef webProjectNodeRef = (NodeRef) pValue.getValue(DataTypeDefinition.NODE_REF);
// Apply sepcific user permissions as set on the web project
List<ChildAssociationRef> userInfoRefs = this.nodeService.getChildAssocs(webProjectNodeRef,
WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref : userInfoRefs)
{
NodeRef userInfoRef = ref.getChildRef();
//String username = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME); // not used
String userrole = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE);
if (userrole.equals(PermissionService.ALL_PERMISSIONS))
{
this.nodeService.setProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE, this.replaceAllWith);
}
}
}
}
protected void setStagingAreaPermissions(AVMStoreDescriptor store) throws Exception
{
QName propQName = QName.createQName(null, ".web_project.noderef");
NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, store.getName() + ":/www");
makeGroupsIfRequired(store.getName(), dirRef);
if (!isPermissionSet(dirRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ))
{
this.permissionService.setPermission(dirRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ,
true);
}
// Add group permissions
for (String permission : MoveWCMToGroupBasedPermissionsPatch.PERMISSIONS)
{
String cms = this.authorityService.getName(AuthorityType.GROUP, store.getName() + "-" + permission);
this.permissionService.setPermission(dirRef, cms, permission, true);
}
PropertyValue pValue = this.avmService.getStoreProperty(store.getName(), propQName);
if (pValue != null)
{
NodeRef webProjectNodeRef = (NodeRef) pValue.getValue(DataTypeDefinition.NODE_REF);
// Apply sepcific user permissions as set on the web project
List<ChildAssociationRef> userInfoRefs = this.nodeService.getChildAssocs(webProjectNodeRef,
WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref : userInfoRefs)
{
NodeRef userInfoRef = ref.getChildRef();
String username = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME);
String userrole = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE);
// remove existing
if (isPermissionSet(dirRef, username, userrole))
{
this.permissionService.deletePermission(dirRef, username, userrole);
}
addToGroupIfRequired(store.getName(), username, userrole);
}
}
}
protected void setStagingAreaMasks(AVMStoreDescriptor store)
{
// groups must exist
NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, store.getName() + ":/www");
if (!isMaskSet(dirRef.getStoreRef(), PermissionService.ALL_AUTHORITIES, PermissionService.READ))
{
this.permissionService.setPermission(dirRef.getStoreRef(), PermissionService.ALL_AUTHORITIES,
PermissionService.READ, true);
}
String cms = this.authorityService.getName(AuthorityType.GROUP, store.getName() + "-"
+ PermissionService.WCM_CONTENT_MANAGER);
if (!isMaskSet(dirRef.getStoreRef(), cms, PermissionService.CHANGE_PERMISSIONS))
{
this.permissionService.setPermission(dirRef.getStoreRef(), cms, PermissionService.CHANGE_PERMISSIONS, true);
}
if (!isMaskSet(dirRef.getStoreRef(), cms, PermissionService.READ_PERMISSIONS))
{
this.permissionService.setPermission(dirRef.getStoreRef(), cms, PermissionService.READ_PERMISSIONS, true);
}
QName propQName = QName.createQName(null, ".web_project.noderef");
PropertyValue pValue = this.avmService.getStoreProperty(store.getName(), propQName);
if (pValue != null)
{
NodeRef webProjectNodeRef = (NodeRef) pValue.getValue(DataTypeDefinition.NODE_REF);
// Apply sepcific user permissions as set on the web project
List<ChildAssociationRef> userInfoRefs = this.nodeService.getChildAssocs(webProjectNodeRef,
WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref : userInfoRefs)
{
NodeRef userInfoRef = ref.getChildRef();
String username = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME);
String userrole = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE);
if (userrole.equals(PermissionService.WCM_CONTENT_MANAGER))
{
// remove existing
if (isMaskSet(dirRef.getStoreRef(), username, PermissionService.CHANGE_PERMISSIONS))
{
this.permissionService.deletePermission(dirRef.getStoreRef(), username,
PermissionService.CHANGE_PERMISSIONS);
}
if (isMaskSet(dirRef.getStoreRef(), username, PermissionService.READ_PERMISSIONS))
{
this.permissionService.deletePermission(dirRef.getStoreRef(), username,
PermissionService.READ_PERMISSIONS);
}
}
}
}
}
protected void setSandBoxMasks(AVMStoreDescriptor sandBoxStore)
{
// get the settings from the staging store ...
String owner = extractOwner(sandBoxStore.getName());
String stagingAreaName = extractStagingAreaName(sandBoxStore.getName());
QName propQName = QName.createQName(null, ".web_project.noderef");
NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, sandBoxStore.getName() + ":/www");
//Map<QName, PropertyValue> woof = this.avmService.getStoreProperties(stagingAreaName); // not used
PropertyValue pValue = this.avmService.getStoreProperty(stagingAreaName, propQName);
if (!isMaskSet(dirRef.getStoreRef(), PermissionService.ALL_AUTHORITIES, PermissionService.READ))
{
this.permissionService.setPermission(dirRef.getStoreRef(), PermissionService.ALL_AUTHORITIES,
PermissionService.READ, true);
}
String cms = this.authorityService.getName(AuthorityType.GROUP, stagingAreaName + "-"
+ PermissionService.WCM_CONTENT_MANAGER);
if (!isMaskSet(dirRef.getStoreRef(), cms, PermissionService.WCM_CONTENT_MANAGER))
{
this.permissionService
.setPermission(dirRef.getStoreRef(), cms, PermissionService.WCM_CONTENT_MANAGER, true);
}
if (pValue != null)
{
NodeRef webProjectNodeRef = (NodeRef) pValue.getValue(DataTypeDefinition.NODE_REF);
// Apply sepcific user permissions as set on the web project
List<ChildAssociationRef> userInfoRefs = this.nodeService.getChildAssocs(webProjectNodeRef,
WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref : userInfoRefs)
{
NodeRef userInfoRef = ref.getChildRef();
String username = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME);
String userrole = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE);
if (username.equals(owner))
{
this.permissionService.setPermission(dirRef.getStoreRef(), username,
PermissionService.ALL_PERMISSIONS, true);
}
else if (userrole.equals("ContentManager"))
{
if (isMaskSet(dirRef.getStoreRef(), username, userrole))
{
this.permissionService.deletePermission(dirRef.getStoreRef(), username, userrole);
}
}
}
}
}
private String extractOwner(String name)
{
int start = name.indexOf(WCM_STORE_SEPARATOR);
if (start == -1)
{
throw new UnsupportedOperationException(name);
}
int end = name.indexOf(WCM_STORE_SEPARATOR, start + 1);
if (end == -1)
{
return name.substring(start + 2);
}
return name.substring(start + 2, end);
}
protected String extractStagingAreaName(String name)
{
int index = name.indexOf(WCM_STORE_SEPARATOR);
if (index == -1)
{
throw new UnsupportedOperationException(name);
}
return name.substring(0, index);
}
}

View File

@@ -1,364 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.admin.patch.impl;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.admin.patch.AbstractPatch;
import org.alfresco.repo.importer.ImporterBootstrap;
import org.alfresco.repo.rule.RuleModel;
import org.alfresco.service.cmr.admin.PatchException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.QName;
import org.springframework.context.MessageSource;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* Ensures that the <b>Web Projects</b> and <b>Web Forms</b>folders are present.
* <p>
* This uses the bootstrap importer to get the paths to look for. If not present,
* the required structures are created.
* <p>
*
* @author Kevin Roast
*/
public class WCMFoldersPatch extends AbstractPatch
{
private static final String MSG_WEBPROJECTS_EXISTS = "patch.wcmFolders.webprojects.result.exists";
private static final String MSG_WEBPROJECTS_CREATED = "patch.wcmFolders.webprojects.result.created";
private static final String MSG_WEBFORMS_EXISTS = "patch.wcmFolders.webforms.result.exists";
private static final String MSG_WEBFORMS_CREATED = "patch.wcmFolders.webforms.result.created";
private static final String PROPERTY_COMPANY_HOME_CHILDNAME = "spaces.company_home.childname";
private static final String PROPERTY_DICTIONARY_CHILDNAME = "spaces.dictionary.childname";
public static final String PROPERTY_WEBPROJECTS_FOLDER_CHILDNAME = "spaces.wcm.childname";
private static final String MSG_WEBPROJECTS_FOLDER_NAME = "spaces.wcm.name";
private static final String MSG_WEBPROJECTS_FOLDER_DESCRIPTION = "spaces.wcm.description";
public static final String PROPERTY_WEBFORMS_FOLDER_CHILDNAME = "spaces.wcm_content_forms.childname";
private static final String MSG_WEBFORMS_FOLDER_NAME = "spaces.wcm_content_forms.name";
private static final String MSG_WEBFORMS_FOLDER_DESCRIPTION = "spaces.wcm_content_forms.description";
private static final String PROPERTY_ICON = "space-icon-default";
private ImporterBootstrap importerBootstrap;
private MessageSource messageSource;
protected NodeRef companyHomeNodeRef;
protected NodeRef dictionaryNodeRef;
protected Properties configuration;
protected NodeRef wcmProjectsFolderNodeRef;
protected NodeRef wcmFormsFolderNodeRef;
public void setImporterBootstrap(ImporterBootstrap importerBootstrap)
{
this.importerBootstrap = importerBootstrap;
}
public void setMessageSource(MessageSource messageSource)
{
this.messageSource = messageSource;
}
/**
* Ensure that required common properties have been set
*/
protected void checkCommonProperties() throws Exception
{
if (importerBootstrap == null)
{
throw new PatchException("'importerBootstrap' property has not been set");
}
else if (namespaceService == null)
{
throw new PatchException("'namespaceService' property has not been set");
}
else if (searchService == null)
{
throw new PatchException("'searchService' property has not been set");
}
else if (nodeService == null)
{
throw new PatchException("'nodeService' property has not been set");
}
}
/**
* Extracts pertinent references and properties that are common to execution
* of this and derived patches.
*/
protected void setUp() throws Exception
{
// get the node store that we must work against
StoreRef storeRef = importerBootstrap.getStoreRef();
if (storeRef == null)
{
throw new PatchException("Bootstrap store has not been set");
}
NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef);
this.configuration = importerBootstrap.getConfiguration();
// get the association names that form the path
String companyHomeChildName = configuration.getProperty(PROPERTY_COMPANY_HOME_CHILDNAME);
if (companyHomeChildName == null || companyHomeChildName.length() == 0)
{
throw new PatchException("Bootstrap property '" + PROPERTY_COMPANY_HOME_CHILDNAME + "' is not present");
}
String dictionaryChildName = configuration.getProperty(PROPERTY_DICTIONARY_CHILDNAME);
if (dictionaryChildName == null || dictionaryChildName.length() == 0)
{
throw new PatchException("Bootstrap property '" + PROPERTY_DICTIONARY_CHILDNAME + "' is not present");
}
String wcmProjectsChildName = configuration.getProperty(PROPERTY_WEBPROJECTS_FOLDER_CHILDNAME);
if (wcmProjectsChildName == null || wcmProjectsChildName.length() == 0)
{
throw new PatchException("Bootstrap property '" + PROPERTY_WEBPROJECTS_FOLDER_CHILDNAME + "' is not present");
}
String wcmFormsChildName = configuration.getProperty(PROPERTY_WEBFORMS_FOLDER_CHILDNAME);
if (wcmFormsChildName == null || wcmFormsChildName.length() == 0)
{
throw new PatchException("Bootstrap property '" + PROPERTY_WEBFORMS_FOLDER_CHILDNAME + "' is not present");
}
// build the search string to get the company home node
StringBuilder sb = new StringBuilder(256);
sb.append("/").append(companyHomeChildName);
String xpath = sb.toString();
// get the company home
List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, xpath, null, namespaceService, false);
if (nodeRefs.size() == 0)
{
throw new PatchException("XPath didn't return any results: \n" +
" root: " + storeRootNodeRef + "\n" +
" xpath: " + xpath);
}
else if (nodeRefs.size() > 1)
{
throw new PatchException("XPath returned too many results: \n" +
" root: " + storeRootNodeRef + "\n" +
" xpath: " + xpath + "\n" +
" results: " + nodeRefs);
}
this.companyHomeNodeRef = nodeRefs.get(0);
// build the search string to get the dictionary node
sb.append("/").append(dictionaryChildName);
xpath = sb.toString();
// get the dictionary node
nodeRefs = searchService.selectNodes(storeRootNodeRef, xpath, null, namespaceService, false);
if (nodeRefs.size() == 0)
{
throw new PatchException("XPath didn't return any results: \n" +
" root: " + storeRootNodeRef + "\n" +
" xpath: " + xpath);
}
else if (nodeRefs.size() > 1)
{
throw new PatchException("XPath returned too many results: \n" +
" root: " + storeRootNodeRef + "\n" +
" xpath: " + xpath + "\n" +
" results: " + nodeRefs);
}
this.dictionaryNodeRef = nodeRefs.get(0);
// Check for the existence of the 'Web Projects' folder
xpath = wcmProjectsChildName;
nodeRefs = searchService.selectNodes(companyHomeNodeRef, xpath, null, namespaceService, false);
if (nodeRefs.size() > 1)
{
throw new PatchException("XPath returned too many results: \n" +
" company home node: " + companyHomeNodeRef + "\n" +
" xpath: " + xpath + "\n" +
" results: " + nodeRefs);
}
else if (nodeRefs.size() == 0)
{
// the node does not exist
this.wcmProjectsFolderNodeRef = null;
}
else
{
// we have the 'Web Projects' folder noderef
this.wcmProjectsFolderNodeRef = nodeRefs.get(0);
}
// Check for the existence of the 'Web Forms' folder
xpath = wcmFormsChildName;
nodeRefs = searchService.selectNodes(dictionaryNodeRef, xpath, null, namespaceService, false);
if (nodeRefs.size() > 1)
{
throw new PatchException("XPath returned too many results: \n" +
" dictionary node: " + dictionaryNodeRef + "\n" +
" xpath: " + xpath + "\n" +
" results: " + nodeRefs);
}
else if (nodeRefs.size() == 0)
{
// the node does not exist
this.wcmFormsFolderNodeRef = null;
}
else
{
// we have the 'Web Forms' folder noderef
this.wcmFormsFolderNodeRef = nodeRefs.get(0);
}
}
@Override
protected String applyInternal() throws Exception
{
// properties must be set
checkCommonProperties();
if (messageSource == null)
{
throw new PatchException("'messageSource' property has not been set");
}
// get useful values
setUp();
String msg = null;
if (wcmProjectsFolderNodeRef == null)
{
// create it
createWebProjectsFolder();
msg = I18NUtil.getMessage(MSG_WEBPROJECTS_CREATED, wcmProjectsFolderNodeRef);
}
else
{
// it already exists
msg = I18NUtil.getMessage(MSG_WEBPROJECTS_EXISTS, wcmProjectsFolderNodeRef);
}
if (wcmFormsFolderNodeRef == null)
{
// create it
createWebFormsFolder();
msg = msg + "\r\n" + I18NUtil.getMessage(MSG_WEBFORMS_CREATED, wcmProjectsFolderNodeRef);
}
else
{
// it already exists
msg = msg + "\r\n" + I18NUtil.getMessage(MSG_WEBFORMS_EXISTS, wcmProjectsFolderNodeRef);
}
// done
return msg;
}
private void createWebProjectsFolder()
{
// get required properties
String wcmProjectsChildName = configuration.getProperty(PROPERTY_WEBPROJECTS_FOLDER_CHILDNAME);
if (wcmProjectsChildName == null)
{
throw new PatchException("Bootstrap property '" + PROPERTY_WEBPROJECTS_FOLDER_CHILDNAME + "' is not present");
}
String name = messageSource.getMessage(
MSG_WEBPROJECTS_FOLDER_NAME,
null,
I18NUtil.getLocale());
if (name == null || name.length() == 0)
{
throw new PatchException("Bootstrap property '" + MSG_WEBPROJECTS_FOLDER_NAME + "' is not present");
}
String description = messageSource.getMessage(
MSG_WEBPROJECTS_FOLDER_DESCRIPTION,
null,
I18NUtil.getLocale());
if (description == null || description.length() == 0)
{
throw new PatchException("Bootstrap property '" + MSG_WEBPROJECTS_FOLDER_DESCRIPTION + "' is not present");
}
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(7);
properties.put(ContentModel.PROP_NAME, name);
properties.put(ContentModel.PROP_TITLE, name);
properties.put(ContentModel.PROP_DESCRIPTION, description);
properties.put(ApplicationModel.PROP_ICON, PROPERTY_ICON);
// create the node
ChildAssociationRef childAssocRef = nodeService.createNode(
companyHomeNodeRef,
ContentModel.ASSOC_CONTAINS,
QName.resolveToQName(namespaceService, wcmProjectsChildName),
ContentModel.TYPE_FOLDER,
properties);
wcmProjectsFolderNodeRef = childAssocRef.getChildRef();
// add the required aspects
nodeService.addAspect(wcmProjectsFolderNodeRef, ApplicationModel.ASPECT_UIFACETS, null);
// ALF-906: ensure that DM rules are not inherited by web projects
nodeService.addAspect(wcmProjectsFolderNodeRef, RuleModel.ASPECT_IGNORE_INHERITED_RULES, null);
}
private void createWebFormsFolder()
{
// get required properties
String wcmFormsChildName = configuration.getProperty(PROPERTY_WEBFORMS_FOLDER_CHILDNAME);
if (wcmFormsChildName == null)
{
throw new PatchException("Bootstrap property '" + PROPERTY_WEBFORMS_FOLDER_CHILDNAME + "' is not present");
}
String name = messageSource.getMessage(
MSG_WEBFORMS_FOLDER_NAME,
null,
I18NUtil.getLocale());
if (name == null || name.length() == 0)
{
throw new PatchException("Bootstrap property '" + MSG_WEBFORMS_FOLDER_NAME + "' is not present");
}
String description = messageSource.getMessage(
MSG_WEBFORMS_FOLDER_DESCRIPTION,
null,
I18NUtil.getLocale());
if (description == null || description.length() == 0)
{
throw new PatchException("Bootstrap property '" + MSG_WEBFORMS_FOLDER_DESCRIPTION + "' is not present");
}
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(7);
properties.put(ContentModel.PROP_NAME, name);
properties.put(ContentModel.PROP_TITLE, name);
properties.put(ContentModel.PROP_DESCRIPTION, description);
properties.put(ApplicationModel.PROP_ICON, PROPERTY_ICON);
// create the node
ChildAssociationRef childAssocRef = nodeService.createNode(
dictionaryNodeRef,
ContentModel.ASSOC_CONTAINS,
QName.resolveToQName(namespaceService, wcmFormsChildName),
ContentModel.TYPE_FOLDER,
properties);
wcmFormsFolderNodeRef = childAssocRef.getChildRef();
// add the required aspects
nodeService.addAspect(wcmFormsFolderNodeRef, ApplicationModel.ASPECT_UIFACETS, null);
}
}

View File

@@ -1,158 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.admin.patch.impl;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.repo.admin.patch.AbstractPatch;
import org.alfresco.repo.domain.patch.PatchDAO;
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
import org.alfresco.repo.search.impl.lucene.AVMLuceneIndexer;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* Snap shot all stores after applying the staging are permissions patch
*
* @author andyh
*/
public class WCMPostPermissionSnapshotPatch extends AbstractPatch
{
private static final String MSG_SUCCESS = "patch.wcmPostPermissionSnapshotPatch.result";
private static final String AVM_SITE_STORE_NAME = "sitestore";
private AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor;
private AVMService avmService;
private PatchDAO patchDAO;
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
public void setAvmSnapShotTriggeredIndexingMethodInterceptor(AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor)
{
this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor;
}
public void setPatchDAO(PatchDAO patchDAO)
{
this.patchDAO = patchDAO;
}
@Override
protected String applyInternal() throws Exception
{
List<AVMStoreDescriptor> stores = avmService.getStores();
Thread progressThread = null;
Long toDo = patchDAO.getAVMNodesCountWhereNewInStore();
List<AVMLuceneIndexer> indexers = new ArrayList<AVMLuceneIndexer>(stores.size());
for (AVMStoreDescriptor storeDesc : stores)
{
// post 4.0 we can safely skip "sitestore" no longer used by share
if(storeDesc.getName().equals(AVM_SITE_STORE_NAME))
{
continue;
}
AVMLuceneIndexer indexer = avmSnapShotTriggeredIndexingMethodInterceptor.getIndexer(storeDesc.getName());
indexers.add(indexer);
}
progressThread = new Thread(new ProgressWatcher(toDo, indexers), "WCMPactchProgressWatcher");
progressThread.start();
for (AVMStoreDescriptor storeDesc : stores)
{
// post 4.0 we can safely skip "sitestore" no longer used by share
if(storeDesc.getName().equals(AVM_SITE_STORE_NAME))
{
continue;
}
if (avmService.getStoreRoot(-1, storeDesc.getName()).getLayerID() == -1)
{
avmService.createSnapshot(storeDesc.getName(), "PermissionPatch", "Snapshot after 2.2 permission patch");
AVMLuceneIndexer indexer = avmSnapShotTriggeredIndexingMethodInterceptor.getIndexer(storeDesc.getName());
indexer.flushPending();
}
}
progressThread.interrupt();
progressThread.join();
// build the result message
String msg = I18NUtil.getMessage(MSG_SUCCESS);
// done
return msg;
}
private class ProgressWatcher implements Runnable
{
private boolean running = true;
Long toDo;
List<AVMLuceneIndexer> indexers;
ProgressWatcher(Long toDo, List<AVMLuceneIndexer> indexers)
{
this.toDo = toDo;
this.indexers = indexers;
}
public void run()
{
while (running)
{
try
{
Thread.sleep(60000);
}
catch (InterruptedException e)
{
running = false;
}
if (running)
{
long done = 0;
for(AVMLuceneIndexer indexer : indexers)
{
if(indexer != null)
{
done += indexer.getIndexedDocCount();
}
}
reportProgress(toDo, done);
}
}
}
}
}

View File

@@ -1,157 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import org.alfresco.repo.domain.contentdata.ContentDataDAO;
import org.alfresco.repo.domain.permissions.AclDAO;
/**
* This is the (shudder) global context for AVM. It a rendezvous
* point for access to needed global instances.
* @author britt
*/
public class AVMDAOs
{
/**
* The single instance of an AVMContext.
*/
private static final AVMDAOs fgInstance = new AVMDAOs();
private AVMDAOs()
{
}
/**
* Get the instance of this.
* @return
*/
public static AVMDAOs Instance()
{
return fgInstance;
}
/**
* The AVMNodeDAO.
*/
public AVMNodeDAO fAVMNodeDAO;
public org.alfresco.repo.domain.avm.AVMNodeDAO newAVMNodeDAO;
public org.alfresco.repo.domain.avm.AVMNodeLinksDAO newAVMNodeLinksDAO;
public ContentDataDAO contentDataDAO;
/**
* The AVMStore DAO.
*/
public AVMStoreDAO fAVMStoreDAO;
public org.alfresco.repo.domain.avm.AVMStoreDAO newAVMStoreDAO;
/**
* The VersionRootDAO.
*/
public VersionRootDAO fVersionRootDAO;
public org.alfresco.repo.domain.avm.AVMVersionRootDAO newAVMVersionRootDAO;
/**
* The ChildEntryDAO.
*/
public ChildEntryDAO fChildEntryDAO;
/**
* The AVMStorePropertyDAO
*/
public AVMStorePropertyDAO fAVMStorePropertyDAO;
public VersionLayeredNodeEntryDAO fVersionLayeredNodeEntryDAO;
public AclDAO fAclDAO;
/**
* @param nodeDAO the fAVMNodeDAO to set
*/
public void setNodeDAO(AVMNodeDAO nodeDAO)
{
fAVMNodeDAO = nodeDAO;
}
public void setNewAvmNodeDAO(org.alfresco.repo.domain.avm.AVMNodeDAO newAVMNodeDAO)
{
this.newAVMNodeDAO = newAVMNodeDAO;
}
public void setNewAvmNodeLinksDAO(org.alfresco.repo.domain.avm.AVMNodeLinksDAO newAVMNodeLinksDAO)
{
this.newAVMNodeLinksDAO = newAVMNodeLinksDAO;
}
public void setContentDataDAO(ContentDataDAO contentDataDAO)
{
this.contentDataDAO = contentDataDAO;
}
/**
* @param childEntryDAO the fChildEntryDAO to set
*/
public void setChildEntryDAO(ChildEntryDAO childEntryDAO)
{
fChildEntryDAO = childEntryDAO;
}
/**
* @param aVMStoreDAO The fAVMStoreDAO to set
*/
public void setAvmStoreDAO(AVMStoreDAO aVMStoreDAO)
{
fAVMStoreDAO = aVMStoreDAO;
}
public void setNewAvmStoreDAO(org.alfresco.repo.domain.avm.AVMStoreDAO newAVMStoreDAO)
{
this.newAVMStoreDAO = newAVMStoreDAO;
}
/**
* @param versionRootDAO the fVersionRootDAO to set
*/
public void setVersionRootDAO(VersionRootDAO versionRootDAO)
{
fVersionRootDAO = versionRootDAO;
}
public void setNewAvmVersionRootDAO(org.alfresco.repo.domain.avm.AVMVersionRootDAO newAVMVersionRootDAO)
{
this.newAVMVersionRootDAO = newAVMVersionRootDAO;
}
public void setAvmStorePropertyDAO(AVMStorePropertyDAO avmStorePropertyDAO)
{
fAVMStorePropertyDAO = avmStorePropertyDAO;
}
public void setVersionLayeredNodeEntryDAO(VersionLayeredNodeEntryDAO dao)
{
fVersionLayeredNodeEntryDAO = dao;
}
public void setAclDAO(AclDAO dao)
{
fAclDAO = dao;
}
}

View File

@@ -1,260 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.util.Map;
import java.util.Set;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.domain.permissions.Acl;
import org.alfresco.repo.security.permissions.ACLCopyMode;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.namespace.QName;
/**
* The Interface for versionable objects.
* @author britt
*/
public interface AVMNode
{
/**
* Set the ancestor of this node.
* @param ancestor The ancestor to set.
*/
public void setAncestor(AVMNode ancestor);
/**
* Change the ancestor of a node.
* @param ancestor The ancestor node that should be set.
*/
public void changeAncestor(AVMNode ancestor);
/**
* Get the ancestor of this node.
* @return The ancestor of this node.
*/
public AVMNode getAncestor();
/**
* Set the merged from node.
* @param mergedFrom The merged from node.
*/
public void setMergedFrom(AVMNode mergedFrom);
/**
* Get the node this was merged from.
* @return The node this was merged from.
*/
public AVMNode getMergedFrom();
/**
* Get the version number.
* @return The version number.
*/
public int getVersionID();
/**
* Set the version number.
* @param version The version number to set.
*/
public void setVersionID(int version);
/**
* Possibly copy ourselves.
* @param lPath The Lookup for this node.
* @return A copy of ourself or null if no copy was necessary.
*/
public AVMNode copy(Lookup lPath);
/**
* Get the type of this node.
*/
public int getType();
/**
* Get the descriptor for this node.
* @param lPath The Lookup.
* @param name The name of this in the current context.
* @return The descriptor for this node.
*/
public AVMNodeDescriptor getDescriptor(Lookup lPath, String name);
/**
* Get the descriptor for this node.
* @param lPath The Lookup.
* @return The descriptor for this node.
*/
public AVMNodeDescriptor getDescriptor(Lookup lPath);
/**
* Get a node descriptor for this node.
* @param parentPath The parent path.
* @param name The name looked up as.
* @param parentIndirection The indirection of the parent.
* @param parentIndirectionVersion The indirection version of the parent.
* @return The descriptor for this node.
*/
public AVMNodeDescriptor getDescriptor(String parentPath, String name, String parentIndirection, int parentIndirectionVersion);
/**
* Get the object id.
* @return The object id.
*/
public long getId();
/**
* Get the newnews.
* @return Whether the node is new.
*/
public boolean getIsNew();
/**
* Get a string representation for debugging.
* @param lPath The Lookup.
* @return A String representation.
*/
public String toString(Lookup lPath);
/**
* Set whether this node to be a root of a AVMStore
* @param isRoot
*/
public void setIsRoot(boolean isRoot);
/**
* Get whether this node is a root of a AVMStore.
* @return Whether this node is a root.
*/
public boolean getIsRoot();
/**
* Update the modification time of this node.
*/
public void updateModTime();
/**
* Set a property.
* @param qname the QName
* @param value The value to set.
*/
public void setProperty(QName qname, PropertyValue value);
/**
* Set a collection of properties on this node.
* @param properties The Map of QNames to PropertyValues.
*/
public void setProperties(Map<QName, PropertyValue> properties);
/**
* Add properties to those that already exist.
* @param properties The properties to add.
*/
public void addProperties(Map<QName, PropertyValue> properties);
/**
* Get a property by name.
* @param name The name of the property to get.
* @return A PropertyValue
*/
public PropertyValue getProperty(QName name);
/**
* Get all the properties associated with this node.
* @return A Map of QNames to PropertyValues.
*/
public Map<QName, PropertyValue> getProperties();
/**
* Delete a property from this node.
* @param qnameEntityId the ID of the QName to delete
*/
public void deleteProperty(QName qname);
/**
* Delete all properties from this node.
*/
public void deleteProperties();
/**
* Set an ACL on this node.
* @param acl The ACL to set.
*/
public void setAcl(Acl acl);
/**
* Get the ACL on this node.
* @return The ACL on this node.
*/
public Acl getAcl();
/**
* Set the store that we are new in.
* @param store The store we are new in.
*/
public void setStoreNew(AVMStore store);
/**
* Get the possibly null store that we're new in.
* @return The store that we're new in.
*/
public AVMStore getStoreNew();
/**
* Copy ACL from another node.
*
* @param other
* @param mode
*/
public void copyACLs(AVMNode other, ACLCopyMode mode);
public void copyACLs(Acl otherAcl, Acl parentAcl, ACLCopyMode mode);
/**
* Copy metadata from another node.
* @param other The other node.
*/
public void copyMetaDataFrom(AVMNode other, Long parentAcl);
/**
* Get the GUID associated with this version.
* @return The GUID.
*/
public String getGuid();
/**
* Set the GUID associated with this version.
* @param guid
*/
public void setGuid(String guid);
/**
* Get the Aspects that this node has.
* @return A Set of Aspects IDs.
*/
public Set<QName> getAspects();
public void addAspect(QName aspectQName);
public void removeAspect(QName aspectQName);
/**
* Get the Basic Attributes on this node.
* @return
*/
public BasicAttributes getBasicAttributes();
}

View File

@@ -1,131 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.namespace.QName;
/**
* DAO for AVMNodes interface.
* @author britt
*/
public interface AVMNodeDAO
{
/**
* Save the given node, having never been saved before.
*/
public void save(AVMNode node);
/**
* Delete a single node.
* @param node The node to delete.
*/
public void delete(AVMNode node);
public void createAspect(long nodeId, QName aspectQName);
public void deleteAspect(long nodeId, QName aspectQName);
public void deleteAspects(long nodeId);
public Set<QName> getAspects(long nodeId);
public void createOrUpdateProperty(long nodeId, QName propQName, PropertyValue value);
public void deleteProperty(long nodeId, QName propQName);
public void deleteProperties(long nodeId);
public Map<QName, PropertyValue> getProperties(long nodeId);
/**
* Get by ID.
* @param id The id to get.
*/
public AVMNode getByID(long id);
/**
* Get the root of a particular version.
* @param store The store we're querying.
* @param version The version.
* @return The VersionRoot or null.
*/
public DirectoryNode getAVMStoreRoot(AVMStore store, int version);
/**
* Update a node that has been dirtied.
* @param node The node.
*/
public void update(AVMNode node);
// update optimisation, eg. when creating files
public void updateModTimeAndGuid(AVMNode node);
/**
* Get the ancestor of a node.
* @param node The node whose ancestor is desired.
* @return The ancestor or null.
*/
public AVMNode getAncestor(AVMNode node);
/**
* Get the node the given node was merged from.
* @param node The node whose merged from is desired.
* @return The merged from node or null.
*/
public AVMNode getMergedFrom(AVMNode node);
/**
* Get up to batchSize orphans.
* @param batchSize Get no more than this number.
* @return A List of orphaned AVMNodes.
*/
public List<AVMNode> getOrphans(int batchSize);
/**
* Get all the nodes that are new in the given store.
* @param store The store to query.
* @return A List of AVMNodes.
*/
public List<AVMNode> getNewInStore(AVMStore store);
/**
* Clear newInStore field for a store. (Snapshot)
* @param store
*/
public void clearNewInStore(AVMStore store);
/**
* Get any new layered entries in a store.
* @param store
* @return
*/
public List<Long> getNewLayeredInStoreIDs(AVMStore store);
public List<Layered> getNewLayeredInStore(AVMStore store);
/**
* Clear the cache.
*/
public void clear();
}

View File

@@ -1,603 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.alfresco.repo.avm.util.RawServices;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.domain.avm.AVMHistoryLinkEntity;
import org.alfresco.repo.domain.permissions.Acl;
import org.alfresco.repo.security.permissions.ACLCopyMode;
import org.alfresco.service.cmr.avm.AVMReadOnlyException;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Base class for all repository file system like objects.
* @author britt
*/
public abstract class AVMNodeImpl implements AVMNode
{
private static Log logger = LogFactory.getLog(AVMNodeImpl.class);
protected static final boolean DEBUG = logger.isDebugEnabled();
/**
* The Object ID.
*/
private long fID;
/**
* The Version ID.
*/
private int fVersionID;
/**
* The basic attributes of this. Owner, creator, mod time, etc.
*/
private BasicAttributes fBasicAttributes;
/**
* The version number (for concurrency control).
*/
private long fVers;
/**
* The rootness of this node.
*/
private boolean fIsRoot;
/**
* The ACL on this node.
*/
private Acl fACL;
/**
* The Store that we're new in.
*/
private AVMStore fStoreNew;
/**
* The GUID for this version.
*/
private String fGUID;
/**
* The Aspects that belong to this node.
*/
private Set<QName> fAspects;
private Map<QName, PropertyValue> fProperties;
/**
* Default constructor.
*/
protected AVMNodeImpl()
{
}
/**
* Constructor used when creating a new concrete subclass instance.
* @param store The AVMStore that owns this.
*/
protected AVMNodeImpl(AVMStore store)
{
this();
setVersionID(-1);
setIsRoot(false);
long time = System.currentTimeMillis();
String user =
RawServices.Instance().getAuthenticationContext().getCurrentUserName();
if (user == null)
{
user = RawServices.Instance().getAuthenticationContext().getSystemUserName();
}
setBasicAttributes(new BasicAttributesImpl(user,
user,
user,
time,
time,
time));
setStoreNew(store);
setGuid(GUID.generate());
}
/**
* Set the ancestor of this node.
* @param ancestor The ancestor to set.
*/
public void setAncestor(AVMNode ancestor)
{
if (ancestor == null)
{
return;
}
AVMDAOs.Instance().newAVMNodeLinksDAO.createHistoryLink(ancestor.getId(), this.getId());
}
/**
* Change the ancestor of this node.
* @param ancestor The new ancestor to give it.
*/
public void changeAncestor(AVMNode ancestor)
{
AVMHistoryLinkEntity hlEntity = AVMDAOs.Instance().newAVMNodeLinksDAO.getHistoryLinkByDescendent(this.getId());
if (hlEntity != null)
{
AVMDAOs.Instance().newAVMNodeLinksDAO.deleteHistoryLink(hlEntity.getAncestorNodeId(), hlEntity.getDescendentNodeId());
}
setAncestor(ancestor);
}
/**
* Get the ancestor of this node.
* @return The ancestor of this node.
*/
public AVMNode getAncestor()
{
return AVMDAOs.Instance().fAVMNodeDAO.getAncestor(this);
}
/**
* Set the node that was merged into this.
* @param mergedFrom The node that was merged into this.
*/
public void setMergedFrom(AVMNode mergedFrom)
{
if (mergedFrom == null)
{
return;
}
AVMDAOs.Instance().newAVMNodeLinksDAO.createMergeLink(mergedFrom.getId(), this.getId());
}
/**
* Get the node that was merged into this.
* @return The node that was merged into this.
*/
public AVMNode getMergedFrom()
{
return AVMDAOs.Instance().fAVMNodeDAO.getMergedFrom(this);
}
/**
* Equality based on object ids.
* @param obj The thing to compare against.
* @return Equality.
*/
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (!(obj instanceof AVMNode))
{
return false;
}
return getId() == ((AVMNode)obj).getId();
}
/**
* Get a reasonable hash value.
* @return The hash code.
*/
@Override
public int hashCode()
{
return (int)getId();
}
/**
* Set the object id.
* @param id The id to set.
*/
public void setId(long id)
{
fID = id;
}
/**
* Get the id of this node.
* @return The object id.
*/
public long getId()
{
return fID;
}
/**
* Set the versionID for this node.
* @param versionID The id to set.
*/
public void setVersionID(int versionID)
{
fVersionID = versionID;
}
/**
* Get the version id of this node.
* @return The version id.
*/
public int getVersionID()
{
return fVersionID;
}
/**
* Set the basic attributes.
* @param attrs
*/
public void setBasicAttributes(BasicAttributes attrs)
{
fBasicAttributes = attrs;
}
/**
* Get the basic attributes.
* @return The basic attributes.
*/
public BasicAttributes getBasicAttributes()
{
return fBasicAttributes;
}
/**
* Get whether this is a new node.
* @return Whether this is new.
*/
public boolean getIsNew()
{
return getStoreNew() != null;
}
/**
* Set the version (for concurrency control).
* @param The version for optimistic locks.
*/
public void setVers(long vers)
{
fVers = vers;
}
/**
* Get the version (for concurrency control).
* @return vers The version for optimistic locks.
*/
public long getVers()
{
return fVers;
}
/**
* Get whether this is a root node.
* @return Whether this is a root node.
*/
public boolean getIsRoot()
{
return fIsRoot;
}
/**
* @param isRoot
*/
public void setIsRoot(boolean isRoot)
{
fIsRoot = isRoot;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNode#updateModTime()
*/
public void updateModTime()
{
if (DEBUG)
{
checkReadOnly();
}
String user =
RawServices.Instance().getAuthenticationContext().getCurrentUserName();
if (user == null)
{
user = RawServices.Instance().getAuthenticationContext().getSystemUserName();
}
getBasicAttributes().setModDate(System.currentTimeMillis());
getBasicAttributes().setLastModifier(user);
}
/**
* Copy all properties from another node.
* @param other The other node.
*/
protected void copyProperties(AVMNode other)
{
Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>();
for (Map.Entry<QName, PropertyValue> entry : other.getProperties().entrySet())
{
props.put(entry.getKey(), entry.getValue());
}
setProperties(props);
}
/**
* Copy all aspects from another node.
* @param other The other node.
*/
protected void copyAspects(AVMNode other)
{
Set<QName> aspects = new HashSet<QName>(other.getAspects());
setAspects(aspects);
}
protected void copyCreationAndOwnerBasicAttributes(AVMNode other)
{
getBasicAttributes().setCreateDate(other.getBasicAttributes().getCreateDate());
getBasicAttributes().setCreator(other.getBasicAttributes().getCreator());
getBasicAttributes().setOwner(other.getBasicAttributes().getOwner());
}
public void copyACLs(AVMNode other, ACLCopyMode mode)
{
Acl otherAcl = other.getAcl();
Long otherAclId = (otherAcl == null ? null : otherAcl.getId());
copyACLs(otherAclId, otherAclId, mode);
}
public void copyACLs(Acl otherAcl, Acl parentAcl, ACLCopyMode mode)
{
Long otherAclId = (otherAcl == null ? null : otherAcl.getId());
Long parentAclId = (parentAcl == null ? null : parentAcl.getId());
copyACLs(otherAclId, parentAclId, mode);
}
protected void copyACLs(AVMNode other, Long parentAcl, ACLCopyMode mode)
{
Acl otherAcl = other.getAcl();
copyACLs((otherAcl == null ? null : otherAcl.getId()), parentAcl, mode);
}
protected void copyACLs(Long otherAcl, Long parentAcl, ACLCopyMode mode)
{
if (otherAcl != null)
{
Acl aclCopy = AVMDAOs.Instance().fAclDAO.getAclCopy(otherAcl, parentAcl, mode);
setAcl(aclCopy);
}
else
{
setAcl(null);
}
}
/**
* Copy out metadata from another node.
* @param other The other node.
*/
public void copyMetaDataFrom(AVMNode other, Long parentAcl)
{
copyAspects(other);
copyACLs(other, parentAcl, ACLCopyMode.COPY);
copyProperties(other);
copyCreationAndOwnerBasicAttributes(other);
}
/**
* Set a property on a node. Overwrite it if it exists.
* @param name The name of the property.
* @param value The value to set.
*/
public void setProperty(QName qname, PropertyValue value)
{
if (DEBUG)
{
checkReadOnly();
}
getProperties().put(qname, value);
AVMDAOs.Instance().fAVMNodeDAO.createOrUpdateProperty(this.getId(), qname, value);
}
public void addProperties(Map<QName, PropertyValue> properties)
{
for (Map.Entry<QName, PropertyValue> entry : properties.entrySet())
{
setProperty(entry.getKey(), entry.getValue());
}
}
/**
* Set a collection of properties on this node.
* @param properties The Map of QNames to PropertyValues.
*/
public void setProperties(Map<QName, PropertyValue> properties)
{
fProperties = properties;
for (Map.Entry<QName, PropertyValue> entry : properties.entrySet())
{
setProperty(entry.getKey(), entry.getValue());
}
}
/**
* Get a property by name.
* @param name The name of the property.
* @return The PropertyValue or null if non-existent.
*/
public PropertyValue getProperty(QName qname)
{
return getProperties().get(qname);
}
/**
* {@inheritDoc}
*/
public Map<QName, PropertyValue> getProperties()
{
if (fProperties == null)
{
fProperties = AVMDAOs.Instance().fAVMNodeDAO.getProperties(getId());
}
return fProperties;
}
/**
* Delete a property from this node.
* @param name The name of the property.
*/
public void deleteProperty(QName qname)
{
if (DEBUG)
{
checkReadOnly();
}
getProperties().remove(qname);
AVMDAOs.Instance().fAVMNodeDAO.deleteProperty(getId(), qname);
}
/**
* Delete all properties from this node.
*/
public void deleteProperties()
{
getProperties().clear();
AVMDAOs.Instance().fAVMNodeDAO.deleteProperties(getId());
}
/**
* Set the ACL on this node.
* @param acl The ACL to set.
*/
public void setAcl(Acl acl)
{
fACL = acl;
}
/**
* Get the ACL on this node.
* @return The ACL on this node.
*/
public Acl getAcl()
{
return fACL;
}
/**
* Set the store we are new in.
* @param store The store we are new in.
*/
public void setStoreNew(AVMStore store)
{
fStoreNew = store;
}
/**
* Get the possibly null store we are new in.
* @return The store we are new in.
*/
public AVMStore getStoreNew()
{
return fStoreNew;
}
protected void checkReadOnly()
{
if (getStoreNew() == null)
{
throw new AVMReadOnlyException("Write Operation on R/O Node.");
}
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNode#getGuid()
*/
public String getGuid()
{
return fGUID;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNode#setGuid(java.lang.String)
*/
public void setGuid(String guid)
{
fGUID = guid;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNode#getAspects()
*/
public Set<QName> getAspects()
{
if (fAspects == null)
{
fAspects = AVMDAOs.Instance().fAVMNodeDAO.getAspects(getId());
}
return fAspects;
}
/**
* Set the aspects on this node.
* @param aspects
*/
public void setAspects(Set<QName> aspects)
{
fAspects = aspects;
if ((aspects != null) && (aspects.size() > 0))
{
for (QName aspectQName : aspects)
{
AVMDAOs.Instance().fAVMNodeDAO.createAspect(this.getId(), aspectQName);
}
}
}
public void addAspect(QName aspectQName)
{
fAspects = null;
AVMDAOs.Instance().fAVMNodeDAO.createAspect(this.getId(), aspectQName);
}
public void removeAspect(QName aspectQName)
{
fAspects = null;
AVMDAOs.Instance().fAVMNodeDAO.deleteAspect(this.getId(), aspectQName);
}
// debug
public String toString()
{
return toString(null);
}
}

View File

@@ -228,6 +228,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
*/
public List<StoreRef> getStores()
{
/* Sparta: disable/remove WCM/AVM
// For AVM stores we fake up StoreRefs.
List<AVMStoreDescriptor> stores = fAVMService.getStores();
List<StoreRef> result = new ArrayList<StoreRef>();
@@ -237,6 +238,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
result.add(new StoreRef(StoreRef.PROTOCOL_AVM, name));
}
return result;
*/
return Collections.emptyList();
}
/**

View File

@@ -1,44 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import org.hibernate.proxy.HibernateProxy;
/**
* Utility for unwrapping (getting the actual instance of) an AVMNode from what
* may be a HibernateProxy. Bitter Hibernate note: Hibernate proxies for polymorphic
* types are fundamentally broken.
* @author britt
*
* @deprecated
*/
public class AVMNodeUnwrapper
{
/**
* @deprecated
*/
public static AVMNode Unwrap(AVMNode node)
{
if (node instanceof HibernateProxy)
{
return (AVMNode)((HibernateProxy)node).getHibernateLazyInitializer().getImplementation();
}
return node;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,735 @@
/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avm.LayeringDescriptor;
import org.alfresco.service.cmr.avm.VersionDescriptor;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
// Sparta: disable WCM/AVM - temporary (until WCM/AVM has been fully removed)
public class AVMServiceNOOPImpl implements AVMService
{
/**
* Basic constructor for the service.
*/
public AVMServiceNOOPImpl()
{
}
@Override
public InputStream getFileInputStream(int version, String path)
{
// TODO Auto-generated method stub
return null;
}
@Override
public InputStream getFileInputStream(AVMNodeDescriptor desc)
{
// TODO Auto-generated method stub
return null;
}
@Override
public OutputStream getFileOutputStream(String path)
{
// TODO Auto-generated method stub
return null;
}
@Override
public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(
int version, String path)
{
// TODO Auto-generated method stub
return null;
}
@Override
public SortedMap<String, AVMNodeDescriptor> getDirectoryListingDirect(
int version, String path)
{
// TODO Auto-generated method stub
return null;
}
@Override
public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(
AVMNodeDescriptor dir)
{
// TODO Auto-generated method stub
return null;
}
@Override
public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(
AVMNodeDescriptor dir, String childNamePattern)
{
// TODO Auto-generated method stub
return null;
}
@Override
public List<String> getDeleted(int version, String path)
{
// TODO Auto-generated method stub
return null;
}
@Override
public OutputStream createFile(String path, String name)
{
// TODO Auto-generated method stub
return null;
}
@Override
public void createDirectory(String path, String name)
{
// TODO Auto-generated method stub
}
@Override
public void createLayeredFile(String targetPath, String parent, String name)
{
// TODO Auto-generated method stub
}
@Override
public void createLayeredDirectory(String targetPath, String parent,
String name)
{
// TODO Auto-generated method stub
}
@Override
public void retargetLayeredDirectory(String path, String target)
{
// TODO Auto-generated method stub
}
@Override
public void createStore(String name)
{
// TODO Auto-generated method stub
}
@Override
public void createStore(String name, Map<QName, PropertyValue> props)
{
// TODO Auto-generated method stub
}
@Override
public void createBranch(int version, String srcPath, String dstPath,
String name)
{
// TODO Auto-generated method stub
}
@Override
public void removeNode(String parent, String name)
{
// TODO Auto-generated method stub
}
@Override
public void rename(String srcParent, String srcName, String dstParent,
String dstName)
{
// TODO Auto-generated method stub
}
@Override
public void uncover(String dirPath, String name)
{
// TODO Auto-generated method stub
}
@Override
public int getNextVersionID(String storeName)
{
// TODO Auto-generated method stub
return 0;
}
@Override
public int getLatestSnapshotID(String storeName)
{
// TODO Auto-generated method stub
return 0;
}
@Override
public Map<String, Integer> createSnapshot(String store, String tag,
String description)
{
// TODO Auto-generated method stub
return null;
}
@Override
public List<VersionDescriptor> getStoreVersions(String name)
{
// TODO Auto-generated method stub
return null;
}
@Override
public List<VersionDescriptor> getStoreVersions(String name, Date from,
Date to)
{
// TODO Auto-generated method stub
return null;
}
@Override
public List<AVMStoreDescriptor> getStores()
{
return Collections.emptyList();
}
@Override
public AVMStoreDescriptor getStore(String name)
{
// TODO Auto-generated method stub
return null;
}
@Override
public AVMNodeDescriptor getStoreRoot(int version, String name)
{
// TODO Auto-generated method stub
return null;
}
@Override
public AVMNodeDescriptor lookup(int version, String path)
{
// TODO Auto-generated method stub
return null;
}
@Override
public AVMNodeDescriptor lookup(int version, String path,
boolean includeDeleted)
{
// TODO Auto-generated method stub
return null;
}
@Override
public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name)
{
// TODO Auto-generated method stub
return null;
}
@Override
public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name,
boolean includeDeleted)
{
// TODO Auto-generated method stub
return null;
}
@Override
public Pair<Integer, String> getAPath(AVMNodeDescriptor desc)
{
// TODO Auto-generated method stub
return null;
}
@Override
public String getIndirectionPath(int version, String path)
{
// TODO Auto-generated method stub
return null;
}
@Override
public void purgeStore(String name)
{
// TODO Auto-generated method stub
}
@Override
public void purgeVersion(int version, String name)
{
// TODO Auto-generated method stub
}
@Override
public void makePrimary(String path)
{
// TODO Auto-generated method stub
}
@Override
public List<AVMNodeDescriptor> getHistory(AVMNodeDescriptor desc, int count)
{
// TODO Auto-generated method stub
return null;
}
@Override
public void setOpacity(String path, boolean opacity)
{
// TODO Auto-generated method stub
}
@Override
public AVMNodeDescriptor getCommonAncestor(AVMNodeDescriptor left,
AVMNodeDescriptor right)
{
// TODO Auto-generated method stub
return null;
}
@Override
public LayeringDescriptor getLayeringInfo(int version, String path)
{
// TODO Auto-generated method stub
return null;
}
@Override
public void setNodeProperty(String path, QName name, PropertyValue value)
{
// TODO Auto-generated method stub
}
@Override
public void setNodeProperties(String path,
Map<QName, PropertyValue> properties)
{
// TODO Auto-generated method stub
}
@Override
public PropertyValue getNodeProperty(int version, String path, QName name)
{
// TODO Auto-generated method stub
return null;
}
@Override
public Map<QName, PropertyValue> getNodeProperties(int version, String path)
{
// TODO Auto-generated method stub
return null;
}
@Override
public void deleteNodeProperty(String path, QName name)
{
// TODO Auto-generated method stub
}
@Override
public void deleteNodeProperties(String path)
{
// TODO Auto-generated method stub
}
@Override
public void setStoreProperty(String store, QName name, PropertyValue value)
{
// TODO Auto-generated method stub
}
@Override
public void setStoreProperties(String store, Map<QName, PropertyValue> props)
{
// TODO Auto-generated method stub
}
@Override
public PropertyValue getStoreProperty(String store, QName name)
{
// TODO Auto-generated method stub
return null;
}
@Override
public Map<QName, PropertyValue> getStoreProperties(String store)
{
// TODO Auto-generated method stub
return null;
}
@Override
public Map<QName, PropertyValue> queryStorePropertyKey(String store,
QName keyPattern)
{
// TODO Auto-generated method stub
return null;
}
@Override
public void deleteStoreProperty(String store, QName name)
{
// TODO Auto-generated method stub
}
@Override
public void addAspect(String path, QName aspectName)
{
// TODO Auto-generated method stub
}
@Override
public Set<QName> getAspects(int version, String path)
{
// TODO Auto-generated method stub
return null;
}
@Override
public void removeAspect(String path, QName aspectName)
{
// TODO Auto-generated method stub
}
@Override
public boolean hasAspect(int version, String path, QName aspectName)
{
// TODO Auto-generated method stub
return false;
}
@Override
public void renameStore(String sourceName, String destName)
{
// TODO Auto-generated method stub
}
@Override
public void revert(String path, AVMNodeDescriptor toRevertTo)
{
// TODO Auto-generated method stub
}
@Override
public void setGuid(String path, String guid)
{
// TODO Auto-generated method stub
}
@Override
public void setMimeType(String path, String mimeType)
{
// TODO Auto-generated method stub
}
@Override
public void setEncoding(String path, String encoding)
{
// TODO Auto-generated method stub
}
@Override
public Map<String, Map<QName, PropertyValue>> queryStoresPropertyKeys(
QName keyPattern)
{
// TODO Auto-generated method stub
return null;
}
@Override
public void createDirectory(String path, String name, List<QName> aspects,
Map<QName, PropertyValue> properties)
{
// TODO Auto-generated method stub
}
@Override
public void createFile(String path, String name, InputStream in)
{
// TODO Auto-generated method stub
}
@Override
public void createFile(String path, String name, InputStream in,
List<QName> aspects, Map<QName, PropertyValue> properties)
{
// TODO Auto-generated method stub
}
@Override
public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(
AVMNodeDescriptor dir, boolean includeDeleted)
{
// TODO Auto-generated method stub
return null;
}
@Override
public AVMNodeDescriptor[] getDirectoryListingArray(AVMNodeDescriptor dir,
boolean includeDeleted)
{
// TODO Auto-generated method stub
return null;
}
@Override
public SortedMap<String, AVMNodeDescriptor> getDirectoryListingDirect(
int version, String path, boolean includeDeleted)
{
// TODO Auto-generated method stub
return null;
}
@Override
public AVMNodeDescriptor[] getDirectoryListingArray(int version,
String path, boolean includeDeleted)
{
// TODO Auto-generated method stub
return null;
}
@Override
public SortedMap<String, AVMNodeDescriptor> getDirectoryListingDirect(
AVMNodeDescriptor dir, boolean includeDeleted)
{
// TODO Auto-generated method stub
return null;
}
@Override
public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(
int version, String path, boolean includeDeleted)
{
// TODO Auto-generated method stub
return null;
}
@Override
public void removeNode(String path)
{
// TODO Auto-generated method stub
}
@Override
public void makeTransparent(String dirPath, String name)
{
// TODO Auto-generated method stub
}
@Override
public AVMStoreDescriptor getSystemStore()
{
// TODO Auto-generated method stub
return null;
}
@Override
public void setMetaDataFrom(String path, AVMNodeDescriptor from)
{
// TODO Auto-generated method stub
}
@Override
public void link(String parentPath, String name, AVMNodeDescriptor toLink)
{
// TODO Auto-generated method stub
}
@Override
public void updateLink(String parentPath, String name,
AVMNodeDescriptor toLink)
{
// TODO Auto-generated method stub
}
@Override
public AVMNodeDescriptor forceCopy(String path)
{
// TODO Auto-generated method stub
return null;
}
@Override
public void copy(int srcVersion, String srcPath, String dstPath, String name)
{
// TODO Auto-generated method stub
}
@Override
public List<Pair<Integer, String>> getPaths(AVMNodeDescriptor desc)
{
// TODO Auto-generated method stub
return null;
}
@Override
public List<Pair<Integer, String>> getHeadPaths(AVMNodeDescriptor desc)
{
// TODO Auto-generated method stub
return null;
}
@Override
public List<Pair<Integer, String>> getPathsInStoreHead(
AVMNodeDescriptor desc, String store)
{
// TODO Auto-generated method stub
return null;
}
@Override
public List<String> getPathsInStoreVersion(AVMNodeDescriptor desc,
String store, int version)
{
// TODO Auto-generated method stub
return null;
}
@Override
public Map<QName, PropertyValue> getNodeProperties(AVMNodeDescriptor desc)
{
// TODO Auto-generated method stub
return null;
}
@Override
public Set<QName> getAspects(AVMNodeDescriptor desc)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ContentReader getContentReader(int version, String path)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ContentWriter getContentWriter(String path, boolean update)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ContentData getContentDataForRead(int version, String path)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ContentData getContentDataForRead(AVMNodeDescriptor desc)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ContentData getContentDataForWrite(String path)
{
// TODO Auto-generated method stub
return null;
}
@Override
public void setContentData(String path, ContentData data)
{
// TODO Auto-generated method stub
}
@Override
public List<VersionDescriptor> getStoreVersionsFrom(String name, int version)
{
// TODO Auto-generated method stub
return null;
}
@Override
public List<VersionDescriptor> getStoreVersionsTo(String name, int version)
{
// TODO Auto-generated method stub
return null;
}
@Override
public List<VersionDescriptor> getStoreVersionsBetween(String name,
int startVersion, int endVersion)
{
// TODO Auto-generated method stub
return null;
}
}

View File

@@ -1,537 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.domain.permissions.Acl;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avm.VersionDescriptor;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.namespace.QName;
/**
* The store interface. Methods for filesystem like, versioning,
* and layering operations.
* @author britt
*/
public interface AVMStore
{
/**
* Get the primary key.
*/
public long getId();
/**
* This returns the next version in this store that will be snapshotted.
* @return The next version to be snapshotted.
*/
public int getNextVersionID();
/**
* This gets the last extant version id.
*/
public int getLastVersionID();
/**
* Set a new root for this store.
* @param root The root to set.
*/
public void setNewRoot(DirectoryNode root);
/**
* Get the Acl associated with this store.
* @return
*/
public Acl getStoreAcl();
/**
* Set the acl on this store.
* @param acl
*/
public void setStoreAcl(Acl acl);
/**
* Snapshots this store. This sets all nodes in the
* the store to the should be copied state, and creates
* a new version root.
* @param tag The short description.
* @param description The long description.
* @param snapShotMap Keeps track of snapshot ids for all stores that
* end up snapshotted, possibly recursively.
* @return The map of all implicitely and explicitely snapshotted stores.
*/
public Map<String, Integer> createSnapshot(String tag, String Description, Map<String, Integer> snapShotMap);
/**
* Create a new directory.
* @param path The path to the parent directory.
* @param name The name to give the new directory.
*/
public void createDirectory(String path, String name, List<QName> aspects, Map<QName, PropertyValue> properties);
/**
* Create a new layered directory.
* @param srcPath The path that the new layered directory will point at.
* @param dstPath The path to the directory to create the new layered directory in.
* @param name The name of the new layered directory.
*/
public void createLayeredDirectory(String srcPath, String dstPath,
String name);
/**
* Create a new file. The designated file cannot already exist.
* @param path The path to the directory to contain the new file.
* @param name The name to give the new file.
* @return An OutputStream.
*/
public OutputStream createFile(String path, String name);
/**
* Create a file with the given contents.
* @param path The path to the containing directory.
* @param name The name to give the file.
* @param data The contents of the file.
*/
public void createFile(String path, String name, File data, List<QName> aspects, Map<QName, PropertyValue> properties);
/**
* Create a new layered file.
* @param srcPath The target path for the new file.
* @param dstPath The path to the directory to make the new file in.
* @param name The name of the new file.
*/
public void createLayeredFile(String srcPath, String dstPath, String name);
/**
* Get an InputStream from a file.
* @param version The version to look under.
* @param path The path to the file.
* @return An InputStream
*/
public InputStream getInputStream(int version, String path);
/**
* Get a ContentReader from a file.
* @param version The version to look under.
* @param path The path to the file.
* @return A ContentReader
*/
public ContentReader getContentReader(int version, String path);
/**
* Get a listing of the designated directory.
* @param version The version to look under.
* @param path The path to the directory.
* @param includeDeleted Whether to see Deleted nodes.
* @return A listing.
*/
public SortedMap<String, AVMNodeDescriptor> getListing(int version, String path,
boolean includeDeleted);
/**
* Get the list of nodes directly contained in a directory.
* @param version The version to look under.
* @param path The path to the directory.
* @param includeDeleted Whether to see Deleted nodes.
* @return A Map of names to descriptors.
*/
public SortedMap<String, AVMNodeDescriptor> getListingDirect(int version, String path,
boolean includeDeleted);
/**
* Get the names of the deleted nodes in a directory.
* @param version The version to look under.
* @param path The path to the directory.
* @return A List of names.
*/
public List<String> getDeleted(int version, String path);
/**
* Get an output stream to a file.
* @param path The path to the file.
* @return An OutputStream
*/
public OutputStream getOutputStream(String path);
/**
* Get a ContentWriter to a file.
* @param path The path to the file.
* @param update true if the property must be updated atomically when the content write
* stream is closed (attaches a listener to the stream); false if the client code
* will perform the updates itself.
* @return A ContentWriter.
*/
public ContentWriter createContentWriter(String path, boolean update);
/**
* Remove a node and all of its contents.
* @param path The path to the node's parent directory.
* @param name The name of the node to remove.
*/
public void removeNode(String path, String name);
/**
* Uncover a whited out node.
* @param dirPath The path to the directory.
* @param name The name to uncover.
*/
public void uncover(String dirPath, String name);
// TODO This is problematic. As time goes on this returns
// larger and larger data sets. Perhaps what we should do is
// provide methods for getting versions by date range, n most
// recent etc.
/**
* Get all the version for this AVMStore.
* @return A Set of all versions.
*/
public List<VersionDescriptor> getVersions();
/**
* Get all the versions starting from the last until the version specified
* @param version - the version which which to end
* @return - the versions in descending order
*/
public List<VersionDescriptor> getVersionsFrom(int version);
/**
* Get all the versions after and including the one specified
* @param version - the version to start from
* @return - the versions in ascending order
*/
public List<VersionDescriptor> getVersionsTo(int version);
/**
* Get all versions from an including startVersion up to but NOT including endVersion
* @param startVersion
* @param endVersion
* @return - the versions in ascending order
*/
public List<VersionDescriptor> getVersionsBetween(int startVersion, int endVersion);
/**
* Get the versions from between the given dates. From or to
* may be null but not both.
* @param from The earliest date.
* @param to The latest date.
* @return The Set of matching version IDs.
*/
public List<VersionDescriptor> getVersions(Date from, Date to);
/**
* Get the AVMRepository.
* @return The AVMRepository.
*/
public AVMRepository getAVMRepository();
/**
* Lookup a node.
* @param version The version to look under.
* @param path The path to the node.
* @param write Whether this is in a write context.
* @param includeDeleted Whether to see Deleted nodes.
* @return A Lookup object.
*/
public Lookup lookup(int version, String path, boolean write, boolean includeDeleted);
/**
* Lookup a directory.
* @param version The version to look under.
* @param path The path to the directory.
* @param write Whether this is in a write context.
* @return A Lookup object.
*/
public Lookup lookupDirectory(int version, String path, boolean write);
/**
* For a layered node, get its indirection.
* @param version The version to look under.
* @param path The path to the node.
* @return The indirection.
*/
public String getIndirectionPath(int version, String path);
/**
* Make the indicated directory a primary indirection.
* @param path The AVMRepository relative path.
*/
public void makePrimary(String path);
/**
* Change the target of a layered directory.
* @param path The path to the layered directory.
* @param target The new target path.
*/
public void retargetLayeredDirectory(String path, String target);
/**
* Get the root directory of this AVMStore.
* @return The root directory.
*/
public DirectoryNode getRoot();
/**
* Get the specified root as a descriptor.
* @param version The version to get (-1 for head).
* @return The specified root or null.
*/
public AVMNodeDescriptor getRoot(int version);
/**
* Get the name of this store.
* @return The name.
*/
public String getName();
/**
* Set the name of the store.
* @param name To Set.
*/
public void setName(String name);
/**
* Purge all the nodes reachable only by the given version.
* @param version
*/
public void purgeVersion(int version);
/**
* Get the descriptor for this.
* @return The descriptor.
*/
public AVMStoreDescriptor getDescriptor();
/**
* Set the opacity of a layered directory. An opaque directory hides
* what is pointed at by its indirection.
* @param path The path to the layered directory.
* @param opacity True is opaque; false is not.
*/
public void setOpacity(String path, boolean opacity);
/**
* Set a property on a node.
* @param path The path to the node.
* @param name The name of the property.
* @param value The value to set.
*/
public void setNodeProperty(String path, QName name, PropertyValue value);
/**
* Set a collection of properties on a node.
* @param path The path to the node.
* @param properties The Map of QNames to PropertyValues.
*/
public void setNodeProperties(String path, Map<QName, PropertyValue> properties);
/**
* Get a property by name.
* @param version The version to look under.
* @param path The path to the node.
* @param name The name of the property.
* @return A PropertyValue or null if not found.
*/
public PropertyValue getNodeProperty(int version, String path, QName name);
/**
* Delete a single property from a node.
* @param path The path to the node.
* @param name The name of the property.
*/
public void deleteNodeProperty(String path, QName name);
/**
* Delete all properties from a node.
* @param path The path to the node.
*/
public void deleteNodeProperties(String path);
/**
* Get all the properties associated with a node.
* @param version The version to look under.
* @param path The path to the node.
* @return A Map of QNames to PropertyValues.
*/
public Map<QName, PropertyValue> getNodeProperties(int version, String path);
/**
* Set a property on this store. Replaces if property already exists.
* @param name The QName of the property.
* @param value The actual PropertyValue.
*/
public void setProperty(QName name, PropertyValue value);
/**
* Set a group of properties on this store. Replaces any property that exists.
* @param properties A Map of QNames to PropertyValues to set.
*/
public void setProperties(Map<QName, PropertyValue> properties);
/**
* Get a property by name.
* @param name The QName of the property to fetch.
* @return The PropertyValue or null if non-existent.
*/
public PropertyValue getProperty(QName name);
/**
* Get all the properties associated with this node.
* @return A Map of the properties.
*/
public Map<QName, PropertyValue> getProperties();
/**
* Delete a property.
* @param name The name of the property to delete.
*/
public void deleteProperty(QName name);
/**
* Get the ContentData on a file.
* @param version The version to look under.
* @param path The path to the file.
* @return The ContentData corresponding to the file.
*/
public ContentData getContentDataForRead(int version, String path);
/**
* Get the ContentData for writing.
* @param path The path to the file.
* @return The ContentData object.
*/
public ContentData getContentDataForWrite(String path);
/**
* Set the ContentData for a file.
* @param path The path to the file.
* @param data The ContentData to set.
*/
public void setContentData(String path, ContentData data);
/**
* Set meta data, aspects, properties, acls, from another node.
* @param path The path to the node to set metadata on.
* @param from The node to get the metadata from.
*/
public void setMetaDataFrom(String path, AVMNode from);
/**
* Add an aspect to a node.
* @param path The path to the node.
* @param aspectName The name of the aspect.
*/
public void addAspect(String path, QName aspectName);
/**
* Get all aspects on a given node.
* @param version The version to look under.
* @param path The path to the node.
* @return A List of the QNames of the aspects.
*/
public Set<QName> getAspects(int version, String path);
/**
* Remove an aspect and all its properties from a node.
* @param path The path to the node.
* @param aspectName The name of the aspect.
*/
public void removeAspect(String path, QName aspectName);
/**
* Does a given node have a given aspect.
* @param version The version to look under.
* @param path The path to the node.
* @param aspectName The name of the aspect.
* @return Whether the node has the aspect.
*/
public boolean hasAspect(int version, String path, QName aspectName);
/**
* Set the ACL on a node.
* @param path The path to the node.
* @param acl The ACL to set.
*/
public void setACL(String path, Acl acl);
/**
* Get the ACL on a node.
* @param version The version to look under.
* @param path The path to the node.
* @return The ACL.
*/
public Acl getACL(int version, String path);
/**
* Link a node into a directory, directly.
* @param parentPath The path to the directory.
* @param name The name to give the node.
* @param toLink The node to link.
*/
public void link(String parentPath, String name, AVMNodeDescriptor toLink);
/**
* Update a link to a node in a directory, directly.
* @param parentPath The path to the directory.
* @param name The name to give the node.
* @param toLink The node to link.
*/
public void updateLink(String parentPath, String name, AVMNodeDescriptor toLink);
/**
* Revert a head path to a given version. This works by cloning
* the version to revert to, and then linking that new version into head.
* The reverted version will have the previous head version as ancestor.
* @param path The path to the parent directory.
* @param name The name of the node to revert.
* @param toRevertTo The descriptor of the version to revert to.
*/
public void revert(String path, String name, AVMNodeDescriptor toRevertTo);
/**
* Set the GUID on a node.
* @param path
* @param guid
*/
public void setGuid(String path, String guid);
/**
* Set the encoding of a file.
* @param path
* @param encoding
*/
public void setEncoding(String path, String encoding);
/**
* Set the mime type of a file.
* @param path
* @param mimeType
*/
public void setMimeType(String path, String mimeType);
}

View File

@@ -1,78 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.util.List;
/**
* DAO for Repositories.
* @author britt
*/
public interface AVMStoreDAO
{
/**
* Save an AVMStore, never before saved.
* @param store The AVMStore
*/
public void save(AVMStore store);
/**
* Delete the given AVMStore.
* @param store The AVMStore.
*/
public void delete(AVMStore store);
/**
* Get all AVMStores.
* @return A List of all the AVMStores.
*/
public List<AVMStore> getAll();
/**
* Get an AVMStore by name.
* @param name The name of the AVMStore.
* @return The AVMStore or null if not found.
*/
public AVMStore getByName(String name);
/**
* Get the AVM Store that has the given root as HEAD.
* @param root The root to query.
* @return The matching store or null.
*/
public AVMStore getByRoot(AVMNode root);
/**
* Update the given AVMStore record.
* @param rep The dirty AVMStore.
*/
public void update(AVMStore rep);
/**
* Get A store by primary key.
* @param id The primary key.
* @return The store.
*/
public AVMStore getByID(long id);
/**
* Invalidate the by name lookup cache.
*/
public void invalidateCache();
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,67 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.namespace.QName;
/**
* Arbitrary properties associated with AVMStores.
* @author britt
*/
public interface AVMStoreProperty
{
/**
* Set the AVMStore.
* @param store The AVMStore to set.
*/
public void setStore(AVMStore store);
/**
* Get the AVMStore.
* @return The AVMStore this property belongs to.
*/
public AVMStore getStore();
/**
* Set the property type.
*
* @param qname the store property QName
*/
public void setQname(QName qname);
/**
* Get the property type.
*
* @return returns the store property QName
*/
public QName getQname();
/**
* Set the actual property value.
* @param value The PropertyValue to set.
*/
public void setValue(PropertyValue value);
/**
* Get the actual property value.
* @return The actual PropertyValue.
*/
public PropertyValue getValue();
}

View File

@@ -1,87 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.util.List;
import java.util.Map;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.namespace.QName;
/**
* The DAO interface for AVMStoreProperties.
* @author britt
*/
public interface AVMStorePropertyDAO
{
/**
* Persist a property.
* @param prop The AVMStoreProperty to persist.
*/
public void save(AVMStoreProperty prop);
/**
* Get a property by store and name.
* @param store The AVMStore.
* @param name The QName of the property.
* @return The given AVMStoreProperty or null if not found.
*/
public PropertyValue get(AVMStore store, QName name);
/**
* Get all the properties associated with a store.
* @param store The AVMStore whose properties should be fetched.
* @return A map of properties associated with the store.
*/
public Map<QName, PropertyValue> get(AVMStore store);
/**
* Query store properties by key pattern.
* @param store The store.
* @param keyPattern An sql 'like' pattern wrapped up in a QName
* @return A map of matching properties.
*/
public Map<QName, PropertyValue> queryByKeyPattern(AVMStore store, QName keyPattern);
/**
* Query all stores' properties by key pattern.
* @param keyPattern The sql 'like' pattern wrapped up in a QName
* @return A list of matching properties.
*/
public Map<String, Map<QName, PropertyValue>> queryByKeyPattern(QName keyPattern);
/**
* Update a modified property.
* @param prop The AVMStoreProperty to update.
*/
public void update(AVMStoreProperty prop);
/**
* Delete a property from a store by name.
* @param store The AVMStore to delete from.
* @param name The name of the property.
*/
public void delete(AVMStore store, QName name);
/**
* Delete all properties associated with a store.
* @param store The AVMStore whose properties are to be deleted.
*/
public void delete(AVMStore store);
}

View File

@@ -1,149 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.io.Serializable;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.namespace.QName;
/**
* Simple bean to hold properties attached to AVMStores.
* @author britt
*/
public class AVMStorePropertyImpl implements AVMStoreProperty, Serializable
{
private static final long serialVersionUID = -5419606158990318723L;
/**
* The Primary Key.
*/
private Long fID;
/**
* The store that owns this property.
*/
private AVMStore fStore;
/**
* The name of the property.
*/
private QName qname;
/**
* The actual PropertyValue.
*/
private PropertyValue fValue;
public AVMStorePropertyImpl()
{
}
/**
* {@inheritDoc}
*/
public QName getQname()
{
return qname;
}
/**
* {@inheritDoc}
*/
public void setQname(QName qname)
{
this.qname = qname;
}
/**
* Get the store this property belongs to.
* @return The AVMStore that owns this.
*/
public AVMStore getStore()
{
return fStore;
}
/**
* Set the store that this property belongs to.
* @param store The AVMStore.
*/
public void setStore(AVMStore store)
{
fStore = store;
}
/**
* Get the actual property value.
* @return A PropertyValue object.
*/
public PropertyValue getValue()
{
return fValue;
}
/**
* Set the actual property value.
* @param value The PropertyValue to set.
*/
public void setValue(PropertyValue value)
{
fValue = value;
}
/**
* Set the primary key. (For Hibernate)
* @param id The primary key.
*/
protected void setId(Long id)
{
fID = id;
}
/**
* Get the primary key. (For Hibernate)
* @return The primary key.
*/
protected Long getId()
{
return fID;
}
@Override
public boolean equals(Object other)
{
if (this == other)
{
return true;
}
if (!(other instanceof AVMStoreProperty))
{
return false;
}
AVMStoreProperty o = (AVMStoreProperty)other;
return fStore.equals(o.getStore()) && qname.equals(o.getQname());
}
@Override
public int hashCode()
{
return fStore.hashCode() + qname.hashCode();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,77 @@
/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.util.List;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.util.NameMatcher;
//Sparta: disable WCM/AVM - temporary (until WCM/AVM has been fully removed)
public class AVMSyncServiceNOOPImpl implements AVMSyncService
{
/**
* Basic constructor for the service.
*/
public AVMSyncServiceNOOPImpl()
{
}
@Override
public List<AVMDifference> compare(int srcVersion, String srcPath,
int dstVersion, String dstPath, NameMatcher excluder)
{
// TODO Auto-generated method stub
return null;
}
@Override
public List<AVMDifference> compare(int srcVersion, String srcPath,
int dstVersion, String dstPath, NameMatcher excluder,
boolean expandDirs)
{
// TODO Auto-generated method stub
return null;
}
@Override
public void update(List<AVMDifference> diffList, NameMatcher excluder,
boolean ignoreConflicts, boolean ignoreOlder,
boolean overrideConflicts, boolean overrideOlder, String tag,
String description)
{
// TODO Auto-generated method stub
}
@Override
public void flatten(String layerPath, String underlyingPath)
{
// TODO Auto-generated method stub
}
@Override
public void resetLayer(String layerPath)
{
// TODO Auto-generated method stub
}
}

View File

@@ -1,89 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm;
import java.util.List;
import org.alfresco.service.cmr.security.PermissionService;
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
import org.springframework.context.ApplicationEvent;
/**
* This component ensures that the AVM system is properly bootstrapped
* and that this is done in the correct order relative to other
* bootstrap components.
*
* @see #setIssuers(List)
* @see org.alfresco.repo.avm.Issuer
*
* @author Derek Hulley
*/
public class AvmBootstrap extends AbstractLifecycleBean
{
private AVMLockingAwareService avmLockingAwareService;
private AVMRepository avmRepository;
private PermissionService permissionService;
private AVMSyncServiceImpl avmSyncService;
public AvmBootstrap()
{
}
public void setAvmLockingAwareService(AVMLockingAwareService service)
{
avmLockingAwareService = service;
}
public void setAvmRepository(AVMRepository repository)
{
avmRepository = repository;
}
public void setPermissionService(PermissionService service)
{
permissionService = service;
}
public void setAvmSyncService(AVMSyncServiceImpl service)
{
avmSyncService = service;
}
/**
* Initialize the issuers.
*/
@Override
protected void onBootstrap(ApplicationEvent event)
{
avmLockingAwareService.init();
avmRepository.setPermissionService(permissionService);
avmSyncService.setPermissionService(permissionService);
}
/** NO-OP */
@Override
protected void onShutdown(ApplicationEvent event)
{
// Nothing
}
}

View File

@@ -1,50 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
/**
* This interface represents an entry in a directory.
* @author britt
*/
public interface ChildEntry
{
/**
* Set the key for this ChildEntry.
* @param key The ChildKey.
*/
public void setKey(ChildKey key);
/**
* Get the ChildKey for this ChildEntry.
* @return
*/
public ChildKey getKey();
/**
* Set the child in this entry.
* @param child
*/
public void setChild(AVMNode child);
/**
* Get the child in this entry.
* @return The child.
*/
public AVMNode getChild();
}

View File

@@ -1,91 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.util.List;
/**
* DAO for ChildEntries.
* @author britt
*/
public interface ChildEntryDAO
{
/**
* Save an unsaved ChildEntry.
* @param entry The entry to save.
*/
public void save(ChildEntry entry);
/**
* Get an entry by name and parent.
* @param name The name of the child to find.
* @param parent The parent to look in.
* @return The ChildEntry or null if not foun.
*/
public ChildEntry get(ChildKey key);
/**
* Get all the children of a given parent.
* @param parent The parent.
* @param childNamePattern - achild name pattern to match - null is supported for match all
* @return A List of ChildEntries.
*/
public List<ChildEntry> getByParent(DirectoryNode parent, String childNamePattern);
/**
* Does the entry exist for a given child in a given parent.
* @param parent The parent.
* @param child The child.
* @return True if it exists
*/
public boolean existsParentChild(DirectoryNode parent, AVMNode child);
/**
* Get all the ChildEntries corresponding to the given child.
* @param child The child for which to look up entries.
* @return The matching entries.
*/
public List<ChildEntry> getByChild(AVMNode child);
/**
* Rename a child entry (specific rename 'case' only)
* @param child The one to rename.
*/
public void rename(ChildKey key, String newName);
/**
* Delete one.
* @param child The one to delete.
*/
public void delete(ChildEntry child);
/**
* Delete all children of the given parent.
* @param parent The parent.
*/
public void deleteByParent(AVMNode parent);
/**
* Evict a child entry.
* @param entry
*
* @deprecated
*/
public void evict(ChildEntry entry);
}

View File

@@ -1,122 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
/**
* An entry in a directory. Contains a name, parent, and child.
* @author britt
*/
public class ChildEntryImpl implements ChildEntry
{
/**
* The key.
*/
private ChildKey fKey;
/**
* The child.
*/
private AVMNode fChild;
/**
* Default constructor for Hibernate.
*/
public ChildEntryImpl()
{
}
/**
* Make up a brand new entry.
* @param key The ChildKey.
* @param child The child.
*/
public ChildEntryImpl(ChildKey key,
AVMNode child)
{
fKey = key;
fChild = child;
}
/**
* Set the key for this ChildEntry.
* @param key The ChildKey.
*/
public void setKey(ChildKey key)
{
fKey = key;
}
/**
* Get the ChildKey for this ChildEntry.
* @return
*/
public ChildKey getKey()
{
return fKey;
}
/**
* Set the child in this entry.
* @param child
*/
public void setChild(AVMNode child)
{
fChild = child;
}
/**
* Get the child in this entry.
* @return The child.
*/
public AVMNode getChild()
{
return fChild;
}
/**
* Equals override.
* @param obj
* @return Equality.
*/
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (!(obj instanceof ChildEntry))
{
return false;
}
ChildEntry other = (ChildEntry)obj;
return fKey.equals(other.getKey());
}
/**
* Get the hash code.
* @return The hash code.
*/
@Override
public int hashCode()
{
return fKey.hashCode();
}
}

View File

@@ -1,117 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.io.Serializable;
/**
* The key to a ChildEntry, a Parent and a name.
* @author britt
*/
public class ChildKey implements Serializable
{
private static final long serialVersionUID = 2033634095972856432L;
/**
* The Parent.
*/
private DirectoryNode fParent;
/**
* The child's name.
*/
private String fName;
/**
* Construct one with parameters.
* @param parent The parent directory.
* @param name The name of the child.
*/
public ChildKey(DirectoryNode parent, String name)
{
fParent = parent;
fName = name;
}
/**
* A Default Constructor.
*/
public ChildKey()
{
}
/**
* Set the parent.
*/
public void setParent(DirectoryNode parent)
{
fParent = parent;
}
/**
* Get the parent.
* @return A DirectoryNode.
*/
public DirectoryNode getParent()
{
return fParent;
}
/**
* Set the name.
*/
public void setName(String name)
{
fName = name;
}
/**
* Get the name.
*/
public String getName()
{
return fName;
}
/**
* Override of equals.
*/
@Override
public boolean equals(Object other)
{
if (this == other)
{
return true;
}
if (!(other instanceof ChildKey))
{
return false;
}
ChildKey o = (ChildKey)other;
return fParent.equals(o.getParent()) &&
fName.equalsIgnoreCase(o.getName());
}
/**
* Override of hashCode.
*/
public int hashCode()
{
return fParent.hashCode() + fName.toLowerCase().hashCode();
}
}

View File

@@ -1,32 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
/**
* Represents a node that has been deleted.
* @author britt
*/
public interface DeletedNode extends AVMNode
{
/**
* Get the type of node that this is a deleted placeholder for
* @return The type of node that was deleted.
*/
public int getDeletedType();
}

View File

@@ -1,223 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import org.alfresco.repo.domain.permissions.Acl;
import org.alfresco.repo.security.permissions.ACLCopyMode;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
/**
* Place holder for a deleted node.
* @author britt
*/
public class DeletedNodeImpl extends AVMNodeImpl implements DeletedNode
{
private static final long serialVersionUID = 7283526790174482993L;
/**
* The type of node that this is a deleted node for.
*/
private int fDeletedType;
/**
* Default constructor.
*/
public DeletedNodeImpl()
{
}
/**
* Create a new one from scratch.
* @param store The store it's being created in.
*/
public DeletedNodeImpl(AVMStore store, Acl acl)
{
super(store);
this.setAcl(acl);
}
public DeletedNodeImpl(DeletedNode other,
AVMStore store, Long parentAcl, ACLCopyMode mode)
{
super(store);
setDeletedType(other.getDeletedType());
copyACLs(other, parentAcl, mode);
copyCreationAndOwnerBasicAttributes(other);
AVMDAOs.Instance().fAVMNodeDAO.save(this);
copyProperties(other);
copyAspects(other);
}
/**
* Setter.
*/
public void setDeletedType(int type)
{
fDeletedType = type;
}
/**
* Getter.
*/
public int getDeletedType()
{
return fDeletedType;
}
// TODO What happens when this is called? Does it muck anything up.
/**
* This is only called rarely.
*/
public AVMNode copy(Lookup lPath)
{
DirectoryNode dir = lPath.getCurrentNodeDirectory();
Long parentAclId = null;
if((dir != null) && (dir.getAcl() != null))
{
parentAclId = dir.getAcl().getId();
}
AVMNode newMe = new DeletedNodeImpl(this, lPath.getAVMStore(), parentAclId, ACLCopyMode.COPY);
newMe.setAncestor(this);
return newMe;
}
/**
* Get a descriptor.
* @param lPath The Lookup to this node's parent.
* @param name The name of this node.
* @return An AVMNodeDescriptor
*/
public AVMNodeDescriptor getDescriptor(Lookup lPath, String name)
{
BasicAttributes attrs = getBasicAttributes();
String path = lPath.getRepresentedPath();
if (path.endsWith("/"))
{
path = path + name;
}
else
{
path = path + "/" + name;
}
return new AVMNodeDescriptor(path,
name,
AVMNodeType.DELETED_NODE,
attrs.getCreator(),
attrs.getOwner(),
attrs.getLastModifier(),
attrs.getCreateDate(),
attrs.getModDate(),
attrs.getAccessDate(),
getId(),
getGuid(),
getVersionID(),
null,
-1,
false,
-1,
false,
-1,
getDeletedType());
}
/**
* Get a descriptor.
* @param lPath The full Lookup to this.
* @return An AVMNodeDescriptor.
*/
public AVMNodeDescriptor getDescriptor(Lookup lPath)
{
BasicAttributes attrs = getBasicAttributes();
String path = lPath.getRepresentedPath();
return new AVMNodeDescriptor(path,
path.substring(path.lastIndexOf("/") + 1),
AVMNodeType.DELETED_NODE,
attrs.getCreator(),
attrs.getOwner(),
attrs.getLastModifier(),
attrs.getCreateDate(),
attrs.getModDate(),
attrs.getAccessDate(),
getId(),
getGuid(),
getVersionID(),
null,
-1,
false,
-1,
false,
-1,
getDeletedType());
}
/**
* Get a descriptor.
* @param parentPath
* @param name
* @param parentIndirection Ignored.
* @return An AVMNodeDescriptor.
*/
public AVMNodeDescriptor getDescriptor(String parentPath, String name, String parentIndirection, int parentIndirectionVersion)
{
BasicAttributes attrs = getBasicAttributes();
String path = parentPath.endsWith("/") ? parentPath + name : parentPath + "/" + name;
return new AVMNodeDescriptor(path,
name,
AVMNodeType.DELETED_NODE,
attrs.getCreator(),
attrs.getOwner(),
attrs.getLastModifier(),
attrs.getCreateDate(),
attrs.getModDate(),
attrs.getAccessDate(),
getId(),
getGuid(),
getVersionID(),
null,
-1,
false,
-1,
false,
-1,
getDeletedType());
}
/**
* Get the type of this node.
* @return The AVMNodeType of this.
*/
public int getType()
{
return AVMNodeType.DELETED_NODE;
}
/**
* Get a descriptive string representation.
* @param lPath The lookup we've been found through.
* @return A String representation.
*/
public String toString(Lookup lPath)
{
return "[DN:" + getId() + "]";
}
}

View File

@@ -1,168 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.util.Pair;
/**
* The interface for Directory Nodes.
* @author britt
*/
public interface DirectoryNode extends AVMNode
{
/**
* Does this directory directly contain the specified node.
* @param node The node to check.
* @return Whether it does.
*/
public boolean directlyContains(AVMNode node);
/**
* Put child into this directory directly. No copy on write.
* @param name The name to give it.
* @param node The child.
*/
public void putChild(String name, AVMNode node);
/**
* Lookup a child node.
* @param lPath The Lookup so far.
* @param name The name of the child to lookup.
* @param includeDeleted Include deleted nodes or not.
*/
public Pair<AVMNode, Boolean> lookupChild(Lookup lPath, String name, boolean includeDeleted);
/**
* Lookup a child entry.
* @param lPath The Lookup so far.
* @param name The name of the child to lookup.
* @param includeDeleted Include deleted nodes or not.
*/
public Pair<ChildEntry, Boolean> lookupChildEntry(Lookup lPath, String name, boolean includeDeleted);
/**
* Lookup a child node using an AVMNodeDescriptor as context.
* @param mine The node descriptor for this.
* @param name The name of the child to lookup.
* @return The descriptor for the looked up child.
*/
public AVMNodeDescriptor lookupChild(AVMNodeDescriptor mine, String name, boolean includeDeleted);
/**
* Remove a child directly. No copy is possible.
* @param lPath The lookup through which this node was reached.
* @param name The name of the child to remove.
*/
public void removeChild(Lookup lPath, String name);
/**
* Get a directory listing.
* @param lPath The lookup context.
* @return A SortedMap of names to DirectoryEntries.
*/
public Map<String, AVMNode> getListing(Lookup lPath, boolean includeDeleted);
/**
* Get a directory listing.
* @param lPath The lookup context.
* @return A SortedMap of names to DirectoryEntries.
*/
public Map<String, AVMNode> getListing(Lookup lPath, String childNamePattern, boolean includeDeleted);
/**
* Get a listing of the nodes directly contained by a directory.
* @param lPath The Lookup to this directory.
* @return A Map of names to nodes.
*/
public Map<String, AVMNode> getListingDirect(Lookup lPath, boolean includeDeleted);
/**
* Get a listing of nodes directly contained by a directory.
* @param dir The descriptor for the directory.
* @param includeDeleted Whether to include deleted nodes.
* @return A Map of Strings to descriptors.
*/
public SortedMap<String, AVMNodeDescriptor> getListingDirect(AVMNodeDescriptor dir,
boolean includeDeleted);
/**
* Get a listing from a directory specified by an AVMNodeDescriptor.
* @param dir The directory to list.
* @return A Map of names to node descriptors
*/
public SortedMap<String, AVMNodeDescriptor> getListing(AVMNodeDescriptor dir,
boolean includeDeleted);
/**
* Get a listing from a directory specified by an AVMNodeDescriptor.
* @param dir The directory to list.
* @param childNamePattern - child name pattern to match
* @param includeDeleted = include deleted children
* @return A Map of names to node descriptors
*/
public SortedMap<String, AVMNodeDescriptor> getListing(AVMNodeDescriptor dir,
String childNamePattern,
boolean includeDeleted);
/**
* Get the names of nodes deleted in this directory.
* @return A List of names.
*/
public List<String> getDeletedNames();
/**
* Set the directory, which must be in a layer, into a primary
* indirection taking its indirection from the Lookup.
* @param lPath The Lookup.
*/
public void turnPrimary(Lookup lPath);
/**
* Retarget a layered directory.
* @param lPath The Lookup.
* @param target The target path.
*/
public void retarget(Lookup lPath, String target);
/**
* Set whether this node is a root node.
* @param isRoot
*/
public void setIsRoot(boolean isRoot);
/**
* Link a node with the given id into this directory.
* @param lPath The Lookup for this node.
* @param name The name to give the node.
* @param toLink The node to link in.
*/
public void link(Lookup lPath, String name, AVMNodeDescriptor toLink);
/**
* Dangerous version of link that assumes that a child node of
* the given name does not already exist.
* @param name The name to give the child.
* @param toLink The child to link in.
*/
public void link(String name, AVMNodeDescriptor toLink);
}

View File

@@ -1,100 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.util.Pair;
/**
* Base class for Directories.
* @author britt
*/
public abstract class DirectoryNodeImpl extends AVMNodeImpl implements DirectoryNode
{
/**
* Default constructor.
*/
protected DirectoryNodeImpl()
{
}
/**
* A pass through constructor. Called when a new concrete subclass
* instance is created.
* @param repo
*/
protected DirectoryNodeImpl(AVMStore repo)
{
super(repo);
}
/**
* Dangerous version of link.
* @param name The name to give the child.
* @param toLink The child to link in.
*/
public void link(String name, AVMNodeDescriptor toLink)
{
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(toLink.getId());
if (node == null)
{
throw new AVMNotFoundException("Child node not found.");
}
if (node.getType() == AVMNodeType.LAYERED_DIRECTORY &&
!((LayeredDirectoryNode)node).getPrimaryIndirection())
{
throw new AVMBadArgumentException("Non primary layered directories cannot be linked.");
}
// Make the new ChildEntry and save.
ChildKey key = new ChildKey(this, name);
ChildEntry newChild = new ChildEntryImpl(key, node);
AVMDAOs.Instance().fChildEntryDAO.save(newChild);
}
/**
* Does this node directly contain the indicated node.
*
* @param node
* The node we are checking.
* @return Whether node is directly contained.
*/
public boolean directlyContains(AVMNode node)
{
return AVMDAOs.Instance().fChildEntryDAO.existsParentChild(this, node);
}
/**
* Lookup a child node by name.
* @param lPath The lookup path so far.
* @param name The name to lookup.
* @param includeDeleted Whether to lookup deleted nodes.
* @return The child node or null.
*/
public Pair<AVMNode, Boolean> lookupChild(Lookup lPath, String name, boolean includeDeleted)
{
Pair<ChildEntry, Boolean> result = lookupChildEntry(lPath, name, includeDeleted);
if (result == null)
{
return null;
}
return new Pair<AVMNode, Boolean>(result.getFirst().getChild(), result.getSecond());
}
}

View File

@@ -1,40 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import org.alfresco.service.cmr.repository.ContentData;
/**
* Interface for the generic idea of a file.
* @author britt
*/
public interface FileNode extends AVMNode
{
/**
* Set the ContentData for this file.
* @param contentData The value to set.
*/
public void setContentData(ContentData contentData);
/**
* Get the ContentData for this file.
* @param lPath The Lookup used to get here.
* @return The ContentData object for this file.
*/
public ContentData getContentData(Lookup lPath);
}

View File

@@ -1,43 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
/**
* Base class for file objects.
* @author britt
*/
abstract class FileNodeImpl extends AVMNodeImpl implements FileNode
{
/**
* Default constructor.
*/
protected FileNodeImpl()
{
}
/**
* Pass through constructor.
* @param store The AVMStore we belong to.
*/
public FileNodeImpl(AVMStore store)
{
super(store);
}
}

View File

@@ -1,54 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
/**
* Layered nodes share these methods.
* @author britt
*/
public interface Layered extends AVMNode
{
/**
* Get the indirection, or underlying path that this
* node points to.
* @param lookup The lookup path. Needed for most nodes to determine
* underlying path.
* @return The underlying indirection.
*/
public String getUnderlying(Lookup lookup);
/**
* Get the indirection version.
* @param lookup The lookup path.
* @return The underlying indirection version.
*/
public int getUnderlyingVersion(Lookup lookup);
/**
* Get the raw indirection of a layered node.
* @return The raw indirection, which will be null for
* LayeredDirectoryNodes that are not primary indirections.
*/
public String getIndirection();
/**
* Set the indirection version for this layered node.
* @param version The indirection version to set.
*/
public void setIndirectionVersion(Integer version);
}

View File

@@ -1,114 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm;
import org.alfresco.repo.domain.permissions.Acl;
/**
* Interface for Layered Directories.
* @author britt
*/
public interface LayeredDirectoryNode extends DirectoryNode, Layered
{
/**
* Does this node have a primary indirection.
* @return Whether this is a primary indirection.
*/
public boolean getPrimaryIndirection();
/**
* Set whether this has a primary indirection.
* @param has Whether this has a primary indirection.
*/
public void setPrimaryIndirection(boolean has);
/**
* Get the layer id for this node.
* @return The layer id.
*/
public long getLayerID();
/**
* Set the layer id for this node.
* @param id The id to set.
*/
public void setLayerID(long id);
/**
* Set this to be a primary indirection from the path
* passed in.
* @param path The indirection path.
*/
public void rawSetPrimary(Lookup lPath, String path);
/**
* Turn this node into a primary indirection node with the indirection
* taken from the Lookup passed in.
* Performs a copy on write.
* @param lPath
*/
public void turnPrimary(Lookup lPath);
/**
* Retarget this directory.
* @param lPath The Lookup.
* @param target The new target path.
*/
public void retarget(Lookup lPath, String target);
/**
* Make visible a node deleted in a layer.
* @param lPath The Lookup.
* @param name The name to make visible.
*/
public void uncover(Lookup lPath, String name);
/**
* Remove name without leaving behind a deleted node.
* @param name The name of the child to flatten.
*/
public void flatten(String name);
/**
* Set the indirection.
* @param indirection
*/
public void setIndirection(String indirection);
/**
* Get the indirection version.
* @return The indirection version.
*/
public Integer getIndirectionVersion();
/**
* Set the opacity of this.
* @param opacity Whether this should be opaque, i.e. not see the things it
* in its indirection.
*/
public void setOpacity(boolean opacity);
/**
* Get the opacity of this.
* @return The opacity.
*/
public boolean getOpacity();
public void setAclAndInherit(LayeredDirectoryNode layeredDirectory, Acl acl, String name);
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,38 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
/**
* Interface for a layered file node.
* @author britt
*/
public interface LayeredFileNode extends FileNode, Layered
{
/**
* Get the indirection version.
* @return The indirection version.
*/
public Integer getIndirectionVersion();
/**
* Make a copy of this node that is a LayeredFileNode.
* @param lookup The context.
* @return The copy.
*/
public LayeredFileNode copyLiterally(Lookup lookup);
}

View File

@@ -1,367 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import org.alfresco.repo.domain.permissions.Acl;
import org.alfresco.repo.security.permissions.ACLCopyMode;
import org.alfresco.service.cmr.avm.AVMException;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.repository.ContentData;
/**
* A LayeredFileNode behaves like a copy on write symlink.
*
* @author britt
*/
public class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
{
static final long serialVersionUID = 9208423010479156363L;
/**
* The indirection.
*/
private String fIndirection;
/**
* The indirection version.
*/
private int fIndirectionVersion;
/**
* Default constructor.
*/
public LayeredFileNodeImpl()
{
}
/**
* Basically a copy constructor. Used when a branch is created from a layered file.
*
* @param other
* The file to make a copy of.
* @param store
* The store that contains us.
*/
public LayeredFileNodeImpl(LayeredFileNode other, AVMStore store, Long parentAcl, ACLCopyMode mode)
{
super(store);
setIndirection(other.getIndirection());
setIndirectionVersion(-1);
setVersionID(other.getVersionID() + 1);
copyACLs(other, parentAcl, mode);
copyCreationAndOwnerBasicAttributes(other);
AVMDAOs.Instance().fAVMNodeDAO.save(this);
copyProperties(other);
copyAspects(other);
}
/**
* Make a brand new layered file node.
*
* @param indirection
* The thing we point to.
* @param store
* The store we belong to.
*/
public LayeredFileNodeImpl(String indirection, AVMStore store, Acl acl)
{
super(store);
setIndirection(indirection);
setIndirectionVersion(-1);
setVersionID(1);
if (acl != null)
{
setAcl(acl);
}
else
{
if (indirection != null)
{
Lookup lookup = AVMRepository.GetInstance().lookup(-1, indirection, false);
if (lookup != null)
{
AVMNode node = lookup.getCurrentNode();
if (node.getAcl() != null)
{
setAcl(AVMDAOs.Instance().fAclDAO.createLayeredAcl(node.getAcl().getId()));
}
else
{
setAcl(AVMDAOs.Instance().fAclDAO.createLayeredAcl(null));
}
}
else
{
setAcl(AVMDAOs.Instance().fAclDAO.createLayeredAcl(null));
}
}
else
{
setAcl(AVMDAOs.Instance().fAclDAO.createLayeredAcl(null));
}
}
}
/**
* Copy on write logic.
*
* @param lPath
* The path by which this was found.
*/
public AVMNode copy(Lookup lPath)
{
// LayeredFileNodes are always copied.
Lookup lookup = AVMRepository.GetInstance().lookup(-1, getIndirection(), false);
if (lookup == null)
{
throw new AVMException("Unbacked layered file node.");
}
AVMNode indirect = lookup.getCurrentNode();
if (indirect.getType() != AVMNodeType.LAYERED_FILE && indirect.getType() != AVMNodeType.PLAIN_FILE)
{
throw new AVMException("Unbacked layered file node.");
}
DirectoryNode dir = lPath.getCurrentNodeDirectory();
Acl parentAcl = null;
if ((dir != null) && (dir.getAcl() != null))
{
parentAcl = dir.getAcl();
}
// TODO This doesn't look quite right.
PlainFileNodeImpl newMe = new PlainFileNodeImpl(lPath.getAVMStore(), getBasicAttributes(), getContentData(lPath), indirect.getProperties(), indirect.getAspects(), indirect
.getAcl(), getVersionID(), parentAcl, ACLCopyMode.COPY);
newMe.setAncestor(this);
return newMe;
}
/**
* Get the type of this node.
*
* @return The type.
*/
public int getType()
{
return AVMNodeType.LAYERED_FILE;
}
/**
* Get the underlying path.
*
* @param lookup
* The Lookup. (Unused here.)
* @return The underlying path.
*/
public String getUnderlying(Lookup lookup)
{
return getIndirection();
}
/**
* Get a diagnostic String representation.
*
* @param lPath
* The Lookup.
* @return A diagnostic String representation.
*/
public String toString(Lookup lPath)
{
return "[LF:" + getId() + ":" + getIndirection() + "]";
}
/**
* Get the descriptor for this node.
*
* @param lPath
* The Lookup.
* @return A descriptor.
*/
public AVMNodeDescriptor getDescriptor(Lookup lPath, String name)
{
BasicAttributes attrs = getBasicAttributes();
String path = lPath.getRepresentedPath();
if (path.endsWith("/"))
{
path = path + name;
}
else
{
path = path + "/" + name;
}
return new AVMNodeDescriptor(path, name, AVMNodeType.LAYERED_FILE, attrs.getCreator(), attrs.getOwner(), attrs.getLastModifier(), attrs.getCreateDate(),
attrs.getModDate(), attrs.getAccessDate(), getId(), getGuid(), getVersionID(), getUnderlying(lPath), getUnderlyingVersion(lPath), false, -1, false, 0, -1);
}
/**
* Get the descriptor for this node.
*
* @param lPath
* The Lookup.
* @return A descriptor.
*/
public AVMNodeDescriptor getDescriptor(Lookup lPath)
{
BasicAttributes attrs = getBasicAttributes();
String path = lPath.getRepresentedPath();
return new AVMNodeDescriptor(path, path.substring(path.lastIndexOf("/") + 1), AVMNodeType.LAYERED_FILE, attrs.getCreator(), attrs.getOwner(), attrs.getLastModifier(),
attrs.getCreateDate(), attrs.getModDate(), attrs.getAccessDate(), getId(), getGuid(), getVersionID(), getUnderlying(lPath), getUnderlyingVersion(lPath), false, -1,
false, 0, -1);
}
/**
* Get the descriptor for this node.
*
* @param parentPath
* The parent path.
* @param name
* The name this was looked up with.
* @param parentIndirection
* The parent indirection.
* @return The descriptor.
*/
public AVMNodeDescriptor getDescriptor(String parentPath, String name, String parentIndirection, int parentIndirectionVersion)
{
BasicAttributes attrs = getBasicAttributes();
String path = parentPath.endsWith("/") ? parentPath + name : parentPath + "/" + name;
return new AVMNodeDescriptor(path, name, AVMNodeType.LAYERED_FILE, attrs.getCreator(), attrs.getOwner(), attrs.getLastModifier(), attrs.getCreateDate(),
attrs.getModDate(), attrs.getAccessDate(), getId(), getGuid(), getVersionID(), getIndirection(), getIndirectionVersion(), false, -1, false, 0, -1);
}
/**
* Get the indirection.
*
* @return The indirection.
*/
public String getIndirection()
{
return fIndirection;
}
/**
* Set the indirection.
*
* @param indirection
*/
public void setIndirection(String indirection)
{
fIndirection = indirection;
}
/**
* Set the ContentData for this file.
*
* @param contentData
* The value to set.
*/
public void setContentData(ContentData contentData)
{
throw new AVMException("Should not be called.");
}
// TODO The lPath argument is unnecessary.
/**
* Get the ContentData for this file.
*
* @return The ContentData object for this file.
*/
public ContentData getContentData(Lookup lPath)
{
Lookup lookup = null;
if (lPath != null)
{
lookup = lPath.getAVMStore().getAVMRepository().lookup(getUnderlyingVersion(lPath), getIndirection(), false);
}
else
{
lookup = AVMRepository.GetInstance().lookup(getUnderlyingVersion(null), getIndirection(), false);
}
if (lookup == null)
{
throw new AVMException("Invalid target.");
}
AVMNode node = lookup.getCurrentNode();
if (!(node instanceof FileNode))
{
throw new AVMException("Invalid target.");
}
FileNode file = (FileNode) node;
return file.getContentData(lookup);
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.avm.Layered#getUnderlyingVersion(org.alfresco.repo.avm.Lookup)
*/
public int getUnderlyingVersion(Lookup lookup)
{
if ((lookup != null) && (lookup.getVersion() == -1))
{
return -1;
}
return getIndirectionVersion();
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.avm.LayeredFileNode#getIndirectionVersion()
*/
public Integer getIndirectionVersion()
{
return fIndirectionVersion;
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.avm.LayeredFileNode#setIndirectionVersion(int)
*/
public void setIndirectionVersion(Integer version)
{
if (version == null)
{
fIndirectionVersion = -1;
}
else
{
fIndirectionVersion = version;
}
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.avm.LayeredFileNode#copyLiterally(org.alfresco.repo.avm.Lookup)
*/
public LayeredFileNode copyLiterally(Lookup lookup)
{
DirectoryNode dir = lookup.getCurrentNodeDirectory();
Long parentAclId = null;
if ((dir != null) && (dir.getAcl() != null))
{
parentAclId = dir.getAcl().getId();
}
return new LayeredFileNodeImpl(this, lookup.getAVMStore(), parentAclId, ACLCopyMode.COPY);
}
}

View File

@@ -1,580 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.repo.avm.util.AVMUtil;
import org.alfresco.util.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* This holds all the information necessary to perform operations
* on AVMNodes, and is structured internally as a list of path components
* from the root directory of a repository.
* @author britt
*/
class Lookup implements Serializable
{
private static final long serialVersionUID = -2844833688622561L;
private static Log logger = LogFactory.getLog(Lookup.class);
/**
* Is this lookup valid?
*/
private boolean fValid;
/**
* The AVMStore.
*/
private AVMStore fAVMStore;
/**
* The name of the AVMStore.
*/
private String fStoreName;
/**
* The components that make up this path.
*/
private List<LookupComponent> fComponents;
/**
* The final store in resolving layers.
*/
private AVMStore fFinalStore;
/**
* Whether, at this point, a layered node has been hit.
* Used while building a Lookup.
*/
private boolean fLayeredYet;
/**
* Whether we are directly contained at this point.
*/
private boolean fDirectlyContained;
/**
* The first LayeredDirectoryNode in the path.
*/
private LayeredDirectoryNode fTopLayer;
/**
* The path index of the top LayeredDirectoryNode in the path.
*/
private int fTopLayerIndex;
/**
* The lowest layered directory node's index seen so far.
*/
private int fLowestLayerIndex;
/**
* The current component being looked at by this lookup.
*/
private int fPosition;
/**
* Whether a needs-to-be-copied component has been seen.
*/
private boolean fNeedsCopying;
/**
* The version that is being looked up.
*/
private int fVersion;
public Lookup(Lookup other, AVMNodeDAO nodeDAO, AVMStoreDAO storeDAO)
{
fValid = true;
fAVMStore = storeDAO.getByID(other.fAVMStore.getId());
fVersion = other.fVersion;
if (fAVMStore == null)
{
fValid = false;
return;
}
fStoreName = fAVMStore.getName();
fComponents = new ArrayList<LookupComponent>();
fLayeredYet = other.fLayeredYet;
if (other.fTopLayer != null)
{
fTopLayer = (LayeredDirectoryNode)nodeDAO.getByID(other.fTopLayer.getId());
if (fTopLayer == null)
{
fValid = false;
return;
}
}
fPosition = other.fPosition;
fTopLayerIndex = other.fTopLayerIndex;
fLowestLayerIndex = other.fLowestLayerIndex;
fNeedsCopying = other.fNeedsCopying;
fDirectlyContained = other.fDirectlyContained;
if (fLayeredYet)
{
for (LookupComponent comp : other.fComponents)
{
LookupComponent newComp = new LookupComponent();
newComp.setName(comp.getName());
newComp.setIndirection(comp.getIndirection());
newComp.setIndirectionVersion(comp.getIndirectionVersion());
newComp.setNode(nodeDAO.getByID(comp.getNode().getId()));
if (newComp.getNode() == null)
{
fValid = false;
return;
}
fComponents.add(newComp);
}
}
else
{
// If this is not a layered lookup then we do not
// need to reload any of the actual nodes except for
// the last.
int i = 0;
for (; i < fPosition; ++i)
{
LookupComponent comp = other.fComponents.get(i);
LookupComponent newComp = new LookupComponent();
newComp.setName(comp.getName());
fComponents.add(newComp);
}
LookupComponent comp = other.fComponents.get(i);
LookupComponent newComp = new LookupComponent();
newComp.setName(comp.getName());
newComp.setNode(nodeDAO.getByID(comp.getNode().getId()));
if (newComp.getNode() == null)
{
fValid = false;
return;
}
fComponents.add(newComp);
}
fFinalStore = storeDAO.getByID(other.fFinalStore.getId());
if (fFinalStore == null)
{
fValid = false;
}
}
/**
* Create a new one.
* @param store The AVMStore that's being looked in.
* @param storeName The name of that AVMStore.
*/
public Lookup(AVMStore store, String storeName, int version)
{
fValid = true;
fAVMStore = store;
fStoreName = storeName;
fVersion = version;
fComponents = new ArrayList<LookupComponent>();
fLayeredYet = false;
fTopLayer = null;
fPosition = -1;
fTopLayerIndex = -1;
fLowestLayerIndex = -1;
fNeedsCopying = false;
fDirectlyContained = true;
fFinalStore = store;
}
/**
* Is this a valid lookup?
*/
public boolean isValid()
{
return fValid;
}
// TODO This is badly in need of cleanup.
/**
* Add a new node to the lookup.
* @param node The node to add.
* @param name The name of the node in the path.
* @param write Whether this is in the context of
* a write operation.
*/
public void add(AVMNode node, String name, boolean directlyContained, boolean write)
{
LookupComponent comp = new LookupComponent();
comp.setName(name);
comp.setNode(node);
if (fPosition >= 0 && fDirectlyContained &&
getCurrentNode().getType() == AVMNodeType.LAYERED_DIRECTORY)
{
// if (directlyContained != ((DirectoryNode)fComponents.get(fPosition).getNode()).directlyContains(node))
// {
// System.err.println("Bloody Murder!");
// }
fDirectlyContained = directlyContained;
if (logger.isTraceEnabled())
{
logger.trace("add: fDirectlyContained = "+directlyContained);
}
}
if (!write)
{
if (node.getType() == AVMNodeType.LAYERED_DIRECTORY)
{
LayeredDirectoryNode oNode = (LayeredDirectoryNode)node;
if (oNode.getPrimaryIndirection())
{
comp.setIndirection(oNode.getIndirection());
comp.setIndirectionVersion(oNode.getIndirectionVersion());
}
else
{
Pair<String, Integer> ind = computeIndirection(name);
comp.setIndirection(ind.getFirst());
comp.setIndirectionVersion(ind.getSecond());
}
fLayeredYet = true;
// Record the first layer seen.
if (fTopLayer == null)
{
fTopLayer = oNode;
fTopLayerIndex = fPosition + 1;
}
fLowestLayerIndex = fPosition + 1;
}
fComponents.add(comp);
fPosition++;
return;
}
if (!node.getIsNew())
{
fNeedsCopying = true;
if (logger.isTraceEnabled())
{
logger.trace("add-cow: "+this+" ("+fPosition+") (not new)");
}
}
else
{
if (fPosition >= 0 && !fDirectlyContained)
{
fNeedsCopying = true;
if (logger.isTraceEnabled())
{
logger.trace("add: COW: "+this+" ("+fPosition+") (new, not directly contained)");
}
}
}
// Record various things if this is layered.
if (node.getType() == AVMNodeType.LAYERED_DIRECTORY)
{
LayeredDirectoryNode oNode = (LayeredDirectoryNode)node;
// Record the indirection path that should be used.
if (oNode.getPrimaryIndirection())
{
comp.setIndirection(oNode.getIndirection());
comp.setIndirectionVersion(-1);
}
else
{
Pair<String, Integer> ind = computeIndirection(name);
comp.setIndirection(ind.getFirst());
comp.setIndirectionVersion(-1);
}
fLayeredYet = true;
// Record the first layer seen.
if (fTopLayer == null)
{
fTopLayer = oNode;
fTopLayerIndex = fPosition + 1;
}
fLowestLayerIndex = fPosition + 1;
}
// In a write context a plain directory contained in a layer will
// be copied so we will need to compute an indirection path.
else if (fLayeredYet)
{
Pair<String, Integer> ind = computeIndirection(name);
comp.setIndirection(ind.getFirst());
comp.setIndirectionVersion(-1);
}
fComponents.add(comp);
fPosition++;
// If we are in a write context do copy on write.
if (fNeedsCopying)
{
node = node.copy(this);
getCurrentLookupComponent().setNode(node);
if (fPosition == 0)
{
// Inform the store of a new root.
fAVMStore.setNewRoot((DirectoryNode)node);
((DirectoryNode)node).setIsRoot(true);
AVMDAOs.Instance().fAVMNodeDAO.update(((DirectoryNode)node));
AVMDAOs.Instance().fAVMStoreDAO.update(fAVMStore);
return;
}
// Not the root. Check if we are the top layer and insert this into it's parent.
if (fPosition == fTopLayerIndex)
{
fTopLayer = (LayeredDirectoryNode)node;
}
((DirectoryNode)fComponents.get(fPosition - 1).getNode()).putChild(name, node);
}
}
/**
* A helper for keeping track of indirection.
* @param name The name of the being added node.
* @return The indirection for the being added node.
*/
private Pair<String, Integer> computeIndirection(String name)
{
String parentIndirection = getCurrentIndirection();
int parentIndirectionVersion = getCurrentIndirectionVersion();
if (parentIndirection.endsWith("/"))
{
return new Pair<String, Integer>(parentIndirection + name, parentIndirectionVersion);
}
else
{
return new Pair<String, Integer>(parentIndirection + "/" + name, parentIndirectionVersion);
}
}
/**
* Return the parent node of the current node in the look up context or null if there is not one yet
* @return
*/
public DirectoryNode getCurrentNodeDirectory()
{
int position = fPosition -1;
if( (position >= 0) && (position < fComponents.size()))
{
return ((DirectoryNode)fComponents.get(fPosition - 1).getNode());
}
else
{
return null;
}
}
private LookupComponent getCurrentLookupComponent()
{
return fComponents.get(fPosition);
}
/**
* Get the current node we're looking at.
* @return The current node.
*/
public AVMNode getCurrentNode()
{
return getCurrentLookupComponent().getNode();
}
/**
* Is the current path layered.
* @return Whether the current position in the path is layered.
*/
public boolean isLayered()
{
return fLayeredYet;
}
/**
* Determine if a node is directly in this layer.
* @return Whether this node is directly in this layer.
*/
public boolean isInThisLayer()
{
return fLayeredYet && fDirectlyContained;
}
/**
* Get the number of nodes.
* @return The number of nodes.
*/
public int size()
{
return fComponents.size();
}
/**
* Calculate the indirection path at this node.
* @return The indirection path all the way down to the current node.
*/
public String getIndirectionPath()
{
// The path is the underlying path of the lowest layer (in the path sense)
// that is directly contained by the top layer and is a primary indirection node.
int pos = fLowestLayerIndex;
AVMNode node = fComponents.get(pos).getNode();
LayeredDirectoryNode oNode = null;
while (pos >= fTopLayerIndex && (node.getType() != AVMNodeType.LAYERED_DIRECTORY ||
(oNode = (LayeredDirectoryNode)node).getLayerID() != fTopLayer.getLayerID() ||
!oNode.getPrimaryIndirection()))
{
pos--;
node = fComponents.get(pos).getNode();
}
oNode = (LayeredDirectoryNode)node;
// We've found it.
StringBuilder builder = new StringBuilder();
builder.append(oNode.getIndirection());
for (int i = pos + 1; i <= fPosition; i++)
{
builder.append("/");
builder.append(fComponents.get(i).getName());
}
return builder.toString();
}
/**
* Get the computed indirection for the current node.
* @return The indirection.
*/
public String getCurrentIndirection()
{
return getCurrentLookupComponent().getIndirection();
}
/**
* Get the computed indirection version for the current node.
* @return The indirection version.
*/
public int getCurrentIndirectionVersion()
{
return getCurrentLookupComponent().getIndirectionVersion();
}
/**
* Get the topmost Layered directory node. Topmost in the
* path lookup sense.
* @return The topmost layered directory node.
*/
public LayeredDirectoryNode getTopLayer()
{
return fTopLayer;
}
/**
* Get the store that this path is in.
* @return The store.
*/
public AVMStore getAVMStore()
{
return fAVMStore;
}
/**
* Get the path represented by this lookup.
* @return The canonical path for this lookup.
*/
public String getRepresentedPath()
{
if (fComponents.size() == 1)
{
return AVMUtil.buildAVMPath(fStoreName, AVMUtil.AVM_PATH_SEPARATOR); // root;
}
StringBuilder builder = new StringBuilder();
builder.append(fStoreName);
builder.append(AVMUtil.AVM_STORE_SEPARATOR_CHAR);
int count = fComponents.size();
for (int i = 1; i < count; i++)
{
builder.append(AVMUtil.AVM_PATH_SEPARATOR_CHAR);
builder.append(fComponents.get(i).getName());
}
return builder.toString();
}
/**
* Gets the final name in the lookup.
* @return The final name in the lookup.
*/
public String getBaseName()
{
return getCurrentLookupComponent().getName();
}
/**
* Set the final store the lookup occurred in.
* @param store The store to set.
*/
public void setFinalStore(AVMStore store)
{
fFinalStore = store;
}
/**
* Get the final store traversed during lookup.
* @return The final store traversed.
*/
public AVMStore getFinalStore()
{
return fFinalStore;
}
/**
* Get whether the node looked up is directly contained from the
* original root.
* @return Whether the node looked up is directly contained.
*/
public boolean getDirectlyContained()
{
return fDirectlyContained;
}
/**
* Get the version id that this is a lookup for.
* @return The version id.
*/
public int getVersion()
{
return fVersion;
}
// for debug
@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append(getRepresentedPath());
builder.append(" [");
for (int i = 0; i < fComponents.size(); i++)
{
builder.append(AVMUtil.AVM_PATH_SEPARATOR_CHAR);
builder.append(fComponents.get(i).toString());
}
builder.append("]");
return builder.toString();
}
}

View File

@@ -1,56 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm;
import org.alfresco.repo.avm.util.SimplePath;
/**
* All lookup traffic goes through here.
*/
public interface LookupCache
{
public Lookup lookup(AVMStore store, int version, SimplePath path, boolean write, boolean includeDeleted);
// Following are the cache invalidation calls.
/**
* Called when a simple write operation occurs. This
* invalidates all read lookups and all layered lookups.
*/
public void onWrite(String storeName);
/**
* Called when a delete has occurred in a store. This invalidates both
* reads and write lookups in that store.
*/
public void onDelete(String storeName);
/**
* Called when a snapshot occurs in a store. This invalidates write
* lookups. Read lookups stay untouched.
*/
public void onSnapshot(String storeName);
/**
* Full reset of cache.
*/
public void reset();
}

View File

@@ -1,131 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
/**
* Represents a path component in a lookup.
* @author britt
*/
class LookupComponent
{
/**
* The name of this component.
*/
private String fName;
/**
* The node of this component.
*/
private AVMNode fNode;
/**
* The indirection path (if any) for this node.
*/
private String fIndirection;
/**
* The indirection version for this node (if any).
*/
private int fIndirectionVersion;
/**
* Create a new empty lookup component.
*/
public LookupComponent()
{
}
/**
* Get the indirection.
* @return the indirection
*/
public String getIndirection()
{
return fIndirection;
}
/**
* Get the indirection version for this component.
* @return The indirection version.
*/
public int getIndirectionVersion()
{
return fIndirectionVersion;
}
/**
* Set the indirection.
* @param indirection the indirection to set
*/
public void setIndirection(String indirection)
{
fIndirection = indirection;
}
/**
* Set the indirection version for this component.
* @param version The version to set.
*/
public void setIndirectionVersion(int version)
{
fIndirectionVersion = version;
}
/**
* Get the path component name.
* @return the name
*/
public String getName()
{
return fName;
}
/**
* Set the path component name.
* @param name the name to set
*/
public void setName(String name)
{
fName = name;
}
/**
* Get the looked up node for this component.
* @return the node
*/
public AVMNode getNode()
{
return fNode;
}
/**
* Set the node for this component.
* @param node the node to set
*/
public void setNode(AVMNode node)
{
fNode = node;
}
// for debug
public String toString()
{
return (fNode != null ? fNode.toString(null) : "");
}
}

View File

@@ -1,176 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm;
import org.alfresco.repo.avm.util.SimplePath;
import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.util.Pair;
/**
* A NO-OP implementation of AVM path lookup cache
*/
public class NOOPLookupCache implements LookupCache
{
/**
* Make one up.
*/
public NOOPLookupCache()
{
}
/**
* Lookup a path.
*
* @param store The AVMStore.
* @param version The versions.
* @param path The path we are looking up.
* @param write Whether this is a write lookup.
* @param includeDeleted
* @return
*/
public Lookup lookup(AVMStore store, int version, SimplePath path,
boolean write, boolean includeDeleted)
{
// Make up a Lookup to hold the results.
if (path.size() == 0)
{
return null;
}
Lookup result = new Lookup(store, store.getName(), version);
// Grab the root node to start the lookup.
DirectoryNode dir = null;
// Versions less than 0 mean get current.
if (version < 0)
{
dir = store.getRoot();
}
else
{
VersionRoot vRoot = AVMDAOs.Instance().fVersionRootDAO.getByVersionID(store, version);
if (vRoot != null)
{
dir = vRoot.getRoot();
}
// dir = fAVMNodeDAO.getAVMStoreRoot(store, version);
}
if (dir == null)
{
return null;
}
// Add an entry for the root.
result.add(dir, "", true, write);
dir = (DirectoryNode)result.getCurrentNode();
if (path.size() == 1 && path.get(0).equals(""))
{
return result;
}
// Now look up each path element in sequence up to one
// before the end.
DirectoryNode prevDir = null;
for (int i = 0; i < path.size() - 1; i++)
{
if (!AVMRepository.GetInstance().can(null, dir, PermissionService.READ_CHILDREN, result.getDirectlyContained()))
{
throw new AccessDeniedException("Not allowed to read children: " + path.get(i) + " ("+store.getName()+")");
}
Pair<ChildEntry, Boolean> childEntryResult = dir.lookupChildEntry(result, path.get(i), includeDeleted);
if (childEntryResult == null)
{
return null;
}
AVMNode child = childEntryResult.getFirst().getChild();
// Every element that is not the last needs to be a directory.
if (child.getType() != AVMNodeType.PLAIN_DIRECTORY &&
child.getType() != AVMNodeType.LAYERED_DIRECTORY)
{
return null;
}
prevDir = (DirectoryNode)child;
String lookupPathElementName = childEntryResult.getFirst().getKey().getName();
result.add(child, lookupPathElementName, childEntryResult.getSecond(), write);
dir = (DirectoryNode)result.getCurrentNode();
}
// Now look up the last element.
if (!AVMRepository.GetInstance().can(null, dir, PermissionService.READ_CHILDREN, result.getDirectlyContained()))
{
throw new AccessDeniedException("Not allowed to read children: " + path.get(path.size() - 1) + " ("+store.getName()+")");
}
Pair<ChildEntry, Boolean> childEntryResult = dir.lookupChildEntry(result, path.get(path.size() - 1), includeDeleted);
if (childEntryResult == null)
{
if (write && (dir.getType() == AVMNodeType.LAYERED_DIRECTORY))
{
// stale ?
ChildKey key = new ChildKey(prevDir, path.get(path.size() - 1));
ChildEntry entry = AVMDAOs.Instance().fChildEntryDAO.get(key);
if (entry != null)
{
if (!includeDeleted && entry.getChild().getType() == AVMNodeType.DELETED_NODE)
{
return null;
}
childEntryResult = new Pair<ChildEntry, Boolean>(entry, true);
}
else
{
return null;
}
}
else
{
return null;
}
}
AVMNode child = childEntryResult.getFirst().getChild();
String lookupPathElementName = childEntryResult.getFirst().getKey().getName();
result.add(child, lookupPathElementName, childEntryResult.getSecond(), write);
return result;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.LookupCache#onWrite(java.lang.String)
*/
public void onWrite(String storeName)
{
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.LookupCache#onDelete(java.lang.String)
*/
public void onDelete(String storeName)
{
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.LookupCache#onSnapshot(java.lang.String)
*/
public void onSnapshot(String storeName)
{
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.LookupCache#reset()
*/
public void reset()
{
}
}

View File

@@ -1,531 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.alfresco.repo.domain.avm.AVMHistoryLinkEntity;
import org.alfresco.repo.domain.avm.AVMMergeLinkEntity;
import org.alfresco.repo.domain.permissions.Acl;
import org.alfresco.repo.lock.JobLockService;
import org.alfresco.repo.lock.JobLockService.JobLockRefreshCallback;
import org.alfresco.repo.lock.LockAcquisitionException;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* This is the background thread for reaping no longer referenced nodes in the AVM repository. These orphans arise from
* purge operations.
*
* @author britt
*/
public class OrphanReaper
{
public void execute()
{
synchronized (this)
{
if (fRunning.get())
{
if (fgLogger.isDebugEnabled())
{
fgLogger.debug("OrphanReaper is already running - just return");
}
return;
}
fRunning.set(true);
if (fgLogger.isTraceEnabled())
{
fgLogger.trace("Start running OrphanReaper ...");
}
}
try
{
do
{
doBatch();
if (fDone.get())
{
if (fgLogger.isTraceEnabled())
{
fgLogger.trace("OrphanReaper is done - just return");
}
return;
}
try
{
if (fgLogger.isTraceEnabled())
{
fgLogger.trace("OrphanReaper is not done - sleep for "+fActiveBaseSleep+" ms");
}
Thread.sleep(fActiveBaseSleep);
}
catch (InterruptedException e)
{
fgLogger.warn("OrphanReaper was interrupted - do nothing: "+e);
// Do nothing.
}
}
while (fActive.get());
}
finally
{
synchronized (this)
{
fRunning.set(false);
if (fgLogger.isTraceEnabled())
{
fgLogger.trace("... finish running OrphanReaper");
}
}
}
}
private Log fgLogger = LogFactory.getLog(OrphanReaper.class);
private static final QName LOCK = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "OrphanReaper");
private JobLockService jobLockService;
/**
* The Transaction Service
*/
private TransactionService fTransactionService;
/**
* How many ms before refreshing the lock?
*/
private long lockRefreshTime = 60000;
/**
* How long in ms to keep the lock in total before giving up, just in case there is a dead lock.
*/
private long lockTimeOut = 3600000;
/**
* Active base sleep interval.
*/
private long fActiveBaseSleep = 1000;
/**
* Batch size.
*/
private int fBatchSize = 50;
/**
* Whether we are currently active, ie have work queued up.
* Using Atomics so that the memory model is synchronized between threads.
*/
private AtomicBoolean fActive = new AtomicBoolean(false);
private AtomicBoolean fDone = new AtomicBoolean(false);
private AtomicBoolean fRunning = new AtomicBoolean(false);
/**
* Create one with default parameters.
*/
public OrphanReaper()
{
}
// Setters for configuration.
/**
* Set the active base sleep interval.
*
* @param interval
* The interval to set in ms.
*/
public void setActiveBaseSleep(long interval)
{
fActiveBaseSleep = interval;
}
/**
* Set the batch size.
*
* @param size
* The batch size to set.
*/
public void setBatchSize(int size)
{
fBatchSize = size;
}
/**
* Set the transaction service.
*
* @param transactionService
* The service.
*/
public void setTransactionService(TransactionService transactionService)
{
fTransactionService = transactionService;
}
/**
* @param jobLockService service used to ensure that reaper runs are not duplicated
*/
public void setJobLockService(JobLockService jobLockService)
{
this.jobLockService = jobLockService;
}
public void setLockRefreshTime(long lockRefreshTime)
{
this.lockRefreshTime = lockRefreshTime;
}
public long getLockRefreshTime()
{
return lockRefreshTime;
}
public long getTimeToLive()
{
return getLockRefreshTime() * 2;
}
public void setLockTimeOut(long lockTimeOut)
{
this.lockTimeOut = lockTimeOut;
}
public long getLockTimeOut()
{
return lockTimeOut;
}
/**
* Shutdown the reaper. This needs to be called when the application shuts down.
*/
public void shutDown()
{
fDone.set(true);
}
/**
* Attempts to get the lock. If the lock couldn't be taken, then <tt>null</tt> is returned.
*
* @return Returns the lock token or <tt>null</tt>
*/
private String getLock()
{
try
{
return jobLockService.getLock(LOCK, getTimeToLive());
}
catch (LockAcquisitionException e)
{
return null;
}
}
/**
* Creates a callback to refresh the lock if we are still doing work.
* @param lockToken to refresh
* @param lockHeld flag to indicate if the lock is needed/held.
* @param start when processing started.
*/
private void createLockRefreshCallback(final String lockToken, final AtomicBoolean lockHeld, final long start)
{
if (lockToken == null)
{
throw new IllegalArgumentException("Must provide existing lockToken");
}
JobLockRefreshCallback callback = new JobLockRefreshCallback()
{
@Override
public boolean isActive()
{
boolean active = lockHeld.get();
if (active)
{
// Check for deadlock
if (System.currentTimeMillis() >= start + getLockTimeOut())
{
active = false;
lockHeld.set(false); // if not deadlocked this stop processing in the main thread
fgLogger.error("Lock held too long. Do we have a deadlock? Restart process.");
}
}
return active;
}
@Override
public void lockReleased()
{
lockHeld.set(false);
}
};
jobLockService.refreshLock(lockToken, LOCK, getTimeToLive(), callback);
}
/**
* This is really for debugging and testing. Allows another thread to mark the orphan reaper busy so that it can
* monitor for it's being done.
*/
public void activate()
{
fActive.set(true);
}
/**
* See if the reaper is actively reaping.
*
* @return Whether this is actively reaping.
*/
public boolean isActive()
{
return fActive.get();
}
/**
* Do a batch of cleanup work.
*/
public void doBatch()
{
class TxnWork implements RetryingTransactionCallback<Object>
{
public Object execute() throws Exception
{
final long start = System.currentTimeMillis();
int reapCnt = 0;
String lockToken = getLock();
if (lockToken == null)
{
fgLogger.info("Can't get lock. Assume multiple reapers ...");
fActive.set(false);
return null;
}
AtomicBoolean lockHeld = new AtomicBoolean(true);
try
{
// Creates a callback that refreshes the lock as long the code in this try block is
// still running. If the JVM crashes, the lock will time out. Just in case the lock
// still times out, we check at several points in processing and have an overall
// timeout in case of deadlock.
createLockRefreshCallback(lockToken, lockHeld, start);
if (fgLogger.isTraceEnabled())
{
fgLogger.trace("Orphan reaper doBatch: batchSize="+fBatchSize+", fActiveBaseSleep="+fActiveBaseSleep);
}
List<AVMNode> nodes = AVMDAOs.Instance().fAVMNodeDAO.getOrphans(fBatchSize);
if (nodes.size() == 0)
{
if (fgLogger.isTraceEnabled())
{
fgLogger.trace("Nothing to purge (set fActive = false)");
}
fActive.set(false);
return null;
}
if (!lockHeld.get())
{
throw new LockAcquisitionException("Lock lost. Finding orphans to reap.");
}
LinkedList<Long> fPurgeQueue = new LinkedList<Long>();
for (AVMNode node : nodes)
{
fPurgeQueue.add(node.getId());
}
if (fgLogger.isDebugEnabled())
{
fgLogger.debug("Queue was empty so got more orphans from DB. Orphan queue size = "+fPurgeQueue.size());
}
fActive.set(true);
for (int i = 0; i < fBatchSize; i++)
{
if (fPurgeQueue.size() == 0)
{
if (fgLogger.isTraceEnabled())
{
fgLogger.trace("Purge queue is empty (fpurgeQueue size = "
+ fPurgeQueue.size() + ")");
}
fPurgeQueue = null;
break;
}
if (!lockHeld.get())
{
throw new LockAcquisitionException("Lock lost. Orphan reap loop: "+i);
}
Long nodeId = fPurgeQueue.removeFirst();
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(nodeId);
// Save away the ancestor and merged from fields from
// this node.
AVMNode ancestor = null;
AVMHistoryLinkEntity hlEntity = AVMDAOs.Instance().newAVMNodeLinksDAO
.getHistoryLinkByDescendent(node.getId());
if (hlEntity != null)
{
ancestor = AVMDAOs.Instance().fAVMNodeDAO.getByID(hlEntity
.getAncestorNodeId());
AVMDAOs.Instance().newAVMNodeLinksDAO.deleteHistoryLink(
hlEntity.getAncestorNodeId(), hlEntity.getDescendentNodeId());
}
AVMNode mergedFrom = null;
AVMMergeLinkEntity mlEntity = AVMDAOs.Instance().newAVMNodeLinksDAO
.getMergeLinkByTo(node.getId());
if (mlEntity != null)
{
mergedFrom = AVMDAOs.Instance().fAVMNodeDAO.getByID(mlEntity
.getMergeFromNodeId());
AVMDAOs.Instance().newAVMNodeLinksDAO.deleteMergeLink(
mlEntity.getMergeFromNodeId(), mlEntity.getMergeToNodeId());
}
// Get all the nodes that have this node as ancestor.
List<AVMHistoryLinkEntity> hlEntities = AVMDAOs.Instance().newAVMNodeLinksDAO
.getHistoryLinksByAncestor(node.getId());
for (AVMHistoryLinkEntity link : hlEntities)
{
AVMNode desc = AVMDAOs.Instance().fAVMNodeDAO.getByID(link
.getDescendentNodeId());
if (desc != null)
{
desc.setAncestor(ancestor);
if (desc.getMergedFrom() == null)
{
desc.setMergedFrom(mergedFrom);
}
}
AVMDAOs.Instance().newAVMNodeLinksDAO.deleteHistoryLink(
link.getAncestorNodeId(), link.getDescendentNodeId());
}
// Get all the nodes that have this node as mergedFrom
List<AVMMergeLinkEntity> mlEntities = AVMDAOs.Instance().newAVMNodeLinksDAO
.getMergeLinksByFrom(node.getId());
for (AVMMergeLinkEntity link : mlEntities)
{
AVMNode mto = AVMDAOs.Instance().fAVMNodeDAO.getByID(link
.getMergeToNodeId());
if (mto != null)
{
mto.setMergedFrom(ancestor);
}
AVMDAOs.Instance().newAVMNodeLinksDAO.deleteMergeLink(
link.getMergeFromNodeId(), link.getMergeToNodeId());
}
// Get rid of all properties belonging to this node.
AVMDAOs.Instance().fAVMNodeDAO.deleteProperties(node.getId());
// Get rid of all aspects belonging to this node.
AVMDAOs.Instance().fAVMNodeDAO.deleteAspects(node.getId());
// Get rid of ACL.
@SuppressWarnings("unused")
Acl acl = node.getAcl();
node.setAcl(null);
// Unused acls will be garbage collected
// Many acls will be shared
// Extra work for directories.
if (node.getType() == AVMNodeType.PLAIN_DIRECTORY
|| node.getType() == AVMNodeType.LAYERED_DIRECTORY)
{
// First get rid of all child entries for the node.
AVMDAOs.Instance().fChildEntryDAO.deleteByParent(node);
}
else if (node.getType() == AVMNodeType.PLAIN_FILE)
{
PlainFileNode file = (PlainFileNode) node;
if (file.isLegacyContentData())
{
// We quickly convert the old ContentData to the
// new storage
ContentData contentData = file.getContentData();
file.setContentData(contentData);
}
Long contentDataId = file.getContentDataId();
if (contentDataId != null)
{
// The ContentDataDAO will take care of
// dereferencing and cleanup
AVMDAOs.Instance().contentDataDAO.deleteContentData(contentDataId);
}
}
// Finally, delete it
AVMDAOs.Instance().fAVMNodeDAO.delete(node);
if (fgLogger.isTraceEnabled())
{
fgLogger.trace("Deleted Node [" + node.getId() + "]");
}
reapCnt++;
}
// Check we still have the lock at the end
if (!lockHeld.get())
{
throw new LockAcquisitionException("Lock lost at the end of processing");
}
}
finally
{
lockHeld.set(false);
jobLockService.releaseLock(lockToken, LOCK);
if (fgLogger.isDebugEnabled())
{
fgLogger.debug("Reaped "+reapCnt+" nodes in "+(System.currentTimeMillis()-start)+" ms");
}
}
return null;
}
}
try
{
if (!fTransactionService.isReadOnly())
{
fTransactionService.getRetryingTransactionHelper().doInTransaction(new TxnWork());
}
}
catch (Exception e)
{
fgLogger.warn("Garbage collector error. Restarting process", e);
}
}
}

View File

@@ -1,40 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
/**
* Quartz wrapper for OrphanReaper.
* @author britt
*/
public class OrphanReaperJob implements Job
{
/* (non-Javadoc)
* @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
*/
public void execute(JobExecutionContext context) throws JobExecutionException
{
OrphanReaper reaper = (OrphanReaper)context.getJobDetail().getJobDataMap().get("orphanReaper");
reaper.execute();
}
}

View File

@@ -1,28 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm;
/**
* Interface for PlainDirectoryNodes.
* @author britt
*/
public interface PlainDirectoryNode extends DirectoryNode
{
}

View File

@@ -1,530 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import org.alfresco.repo.security.permissions.ACLCopyMode;
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
import org.alfresco.service.cmr.avm.AVMExistsException;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.util.Pair;
/**
* A plain directory. No monkey tricks except for possiblyCopy.
* @author britt
*/
public class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectoryNode
{
static final long serialVersionUID = 9423813734583003L;
/**
* Make up a new directory with nothing in it.
* @param store
*/
public PlainDirectoryNodeImpl(AVMStore store)
{
super(store);
setVersionID(1);
}
/**
* Default constructor.
*/
public PlainDirectoryNodeImpl()
{
}
/**
* Copy like constructor.
* @param other The other directory.
* @param repos The AVMStore Object that will own us.
*/
public PlainDirectoryNodeImpl(PlainDirectoryNode other,
AVMStore store, Long parentAcl, ACLCopyMode mode)
{
super(store);
setVersionID(other.getVersionID() + 1);
copyACLs(other, parentAcl, mode);
copyCreationAndOwnerBasicAttributes(other);
AVMDAOs.Instance().fAVMNodeDAO.save(this);
for (ChildEntry child : AVMDAOs.Instance().fChildEntryDAO.getByParent(other, null))
{
ChildKey key = new ChildKey(this, child.getKey().getName());
ChildEntry newChild = new ChildEntryImpl(key,
child.getChild());
AVMDAOs.Instance().fChildEntryDAO.save(newChild);
}
copyProperties(other);
copyAspects(other);
}
/**
* Get a directory listing.
* @param lPath The lookup path.
* @return The listing.
*/
public Map<String, AVMNode> getListing(Lookup lPath, boolean includeDeleted)
{
return getListing(lPath, null, includeDeleted);
}
/**
* Get a directory listing.
* @param lPath The lookup path.
* @param childNamePattern A child name pattern.
* @param includeDeleted Include deleted nodes.
* @return The listing.
*/
public Map<String, AVMNode> getListing(Lookup lPath, String childNamePattern, boolean includeDeleted)
{
Map<String, AVMNode> result = new HashMap<String, AVMNode>();
List<ChildEntry> children = AVMDAOs.Instance().fChildEntryDAO.getByParent(this, childNamePattern);
for (ChildEntry child : children)
{
if (child.getChild().getType() == AVMNodeType.LAYERED_DIRECTORY ||
child.getChild().getType() == AVMNodeType.PLAIN_DIRECTORY)
{
if (!AVMRepository.GetInstance().can(lPath.getAVMStore(), child.getChild(), PermissionService.READ_CHILDREN, lPath.getDirectlyContained()))
{
continue;
}
}
if (!includeDeleted && child.getChild().getType() == AVMNodeType.DELETED_NODE)
{
continue;
}
result.put(child.getKey().getName(), child.getChild());
}
return result;
}
/**
* Get a listing of the nodes directly contained by a directory.
* @param lPath The Lookup to this directory.
* @return A Map of names to nodes.
*/
public Map<String, AVMNode> getListingDirect(Lookup lPath, boolean includeDeleted)
{
return getListing(lPath, includeDeleted);
}
/**
* Get a listing of the nodes directly contained by a directory.
* @param dir The node's descriptor.
* @param includeDeleted Whether to include deleted nodes.
* @return A Map of Strings to descriptors.
*/
public SortedMap<String, AVMNodeDescriptor> getListingDirect(AVMNodeDescriptor dir,
boolean includeDeleted)
{
return getListing(dir, includeDeleted);
}
/**
* Get a listing of from a directory node descriptor.
* @param dir The directory node descriptor.
* @return A Map of names to node descriptors.
*/
public SortedMap<String, AVMNodeDescriptor> getListing(AVMNodeDescriptor dir, boolean includeDeleted)
{
return getListing(dir, null, includeDeleted);
}
/**
* Get a listing of from a directory node descriptor.
* @param dir The directory node descriptor.
* @param childNamePattern - pattern to match for child names - may be null
* @return A Map of names to node descriptors.
*/
public SortedMap<String, AVMNodeDescriptor> getListing(AVMNodeDescriptor dir, String childNamePattern, boolean includeDeleted)
{
if (dir.getPath() == null)
{
throw new AVMBadArgumentException("Path is null.");
}
SortedMap<String, AVMNodeDescriptor> result = new TreeMap<String, AVMNodeDescriptor>(String.CASE_INSENSITIVE_ORDER);
List<ChildEntry> children = AVMDAOs.Instance().fChildEntryDAO.getByParent(this, childNamePattern);
for (ChildEntry child : children)
{
if (child.getChild().getType() == AVMNodeType.LAYERED_DIRECTORY ||
child.getChild().getType() == AVMNodeType.PLAIN_DIRECTORY)
{
if (!AVMRepository.GetInstance().can(null, child.getChild(), PermissionService.READ_CHILDREN, false))
{
continue;
}
}
if (!includeDeleted && child.getChild().getType() == AVMNodeType.DELETED_NODE)
{
continue;
}
result.put(child.getKey().getName(),
child.getChild().getDescriptor(dir.getPath(),
child.getKey().getName(),
dir.getIndirection(),
dir.getIndirectionVersion()));
}
return result;
}
/**
* Get the names of nodes deleted in this directory.
* @return A List of names.
*/
public List<String> getDeletedNames()
{
return new ArrayList<String>();
}
/**
* Lookup a child entry by name.
* @param lPath The lookup path so far.
* @param name The name to lookup.
* @param includeDeleted Whether to lookup deleted nodes.
* @return The child entry or null.
*/
public Pair<ChildEntry, Boolean> lookupChildEntry(Lookup lPath, String name, boolean includeDeleted)
{
ChildKey key = new ChildKey(this, name);
ChildEntry entry = AVMDAOs.Instance().fChildEntryDAO.get(key);
if (entry == null)
{
return null;
}
if (!includeDeleted && entry.getChild().getType() == AVMNodeType.DELETED_NODE)
{
return null;
}
Pair<ChildEntry, Boolean> result = new Pair<ChildEntry, Boolean>(entry, true);
return result;
}
/**
* Lookup a child using a node descriptor as context.
* @param mine The node descriptor for this.
* @param name The name of the child to lookup.
* @return A node descriptor for the child.
*/
public AVMNodeDescriptor lookupChild(AVMNodeDescriptor mine, String name, boolean includeDeleted)
{
if (mine.getPath() == null)
{
throw new AVMBadArgumentException("Path is null.");
}
ChildKey key = new ChildKey(this, name);
ChildEntry entry = AVMDAOs.Instance().fChildEntryDAO.get(key);
if (entry == null ||
(!includeDeleted && entry.getChild().getType() == AVMNodeType.DELETED_NODE))
{
return null;
}
AVMNodeDescriptor desc = entry.getChild().getDescriptor(mine.getPath(), name, (String)null, -1);
return desc;
}
/**
* Remove a child, no copying.
* @param lPath The path by which this was found.
* @param name The name of the child to remove.
*/
public void removeChild(Lookup lPath, String name)
{
if (DEBUG)
{
checkReadOnly();
}
ChildKey key = new ChildKey(this, name);
ChildEntry entry = AVMDAOs.Instance().fChildEntryDAO.get(key);
if (entry != null)
{
AVMNode child = entry.getChild();
if (child.getType() == AVMNodeType.DELETED_NODE)
{
return;
}
AVMDAOs.Instance().fChildEntryDAO.delete(entry);
if (child.getStoreNew() == null || child.getAncestor() != null)
{
DeletedNodeImpl ghost = new DeletedNodeImpl(lPath.getAVMStore(), child.getAcl());
AVMDAOs.Instance().fAVMNodeDAO.save(ghost);
ghost.setAncestor(child);
ghost.setDeletedType(child.getType());
ghost.copyCreationAndOwnerBasicAttributes(child);
ghost.copyAspects(child);
ghost.copyProperties(child);
AVMDAOs.Instance().fAVMNodeDAO.update(ghost);
putChild(name, ghost);
}
}
}
/**
* Put a new child node into this directory. No copy.
* @param name The name of the child.
* @param node The node to add.
*/
public void putChild(String name, AVMNode node)
{
if (DEBUG)
{
checkReadOnly();
}
ChildKey key = new ChildKey(this, name);
ChildEntry existing = AVMDAOs.Instance().fChildEntryDAO.get(key);
if (existing != null)
{
AVMDAOs.Instance().fChildEntryDAO.delete(existing);
}
ChildEntry entry = new ChildEntryImpl(key, node);
AVMDAOs.Instance().fChildEntryDAO.save(entry);
}
/**
* Copy on write logic.
* @param lPath The lookup path.
* @return A brand new copied version.
*/
public AVMNode copy(Lookup lPath)
{
DirectoryNode newMe = null;
DirectoryNode dir = lPath.getCurrentNodeDirectory();
Long parentAclId = null;
if((dir != null) && (dir.getAcl() != null))
{
parentAclId = dir.getAcl().getId();
}
// In a layered context a copy on write creates a new
// layered directory.
if (lPath.isLayered())
{
// Subtlety warning: This distinguishes the case of a
// Directory that was branched into the layer and one
// that is indirectly seen in this layer.
newMe = new LayeredDirectoryNodeImpl(this, lPath.getAVMStore(), lPath,
lPath.isInThisLayer(), parentAclId, ACLCopyMode.COPY);
((LayeredDirectoryNodeImpl)newMe).setLayerID(lPath.getTopLayer().getLayerID());
AVMDAOs.Instance().fAVMNodeDAO.update(newMe);
}
else
{
newMe = new PlainDirectoryNodeImpl(this, lPath.getAVMStore(), parentAclId, ACLCopyMode.COW);
}
newMe.setAncestor(this);
return newMe;
}
/**
* Get the type of this node.
* @return The type of this node.
*/
public int getType()
{
return AVMNodeType.PLAIN_DIRECTORY;
}
/**
* Get a diagnostic String representation.
* @param lPath The Lookup.
* @return A diagnostic String representation.
*/
public String toString(Lookup lPath)
{
return "[PD:" + getId() + "]";
}
/**
* Turn this into a primary indirection. This must be in a
* layered context.
* @param lPath The Lookup.
*/
public void turnPrimary(Lookup lPath)
{
assert false : "Should never happen.";
}
/**
* Retarget this directory. lPath must be in a layered context.
* @param lPath The Lookup.
* @param target The target path.
*/
public void retarget(Lookup lPath, String target)
{
assert false : "Should never happen.";
}
/**
* Get the descriptor for this node.
* @param lPath The Lookup.
* @param name The name of this node in this context.
* @return A descriptor.
*/
public AVMNodeDescriptor getDescriptor(Lookup lPath, String name)
{
BasicAttributes attrs = getBasicAttributes();
String path = lPath.getRepresentedPath();
if (path.endsWith("/"))
{
path = path + name;
}
else
{
path = path + "/" + name;
}
return new AVMNodeDescriptor(path,
name,
AVMNodeType.PLAIN_DIRECTORY,
attrs.getCreator(),
attrs.getOwner(),
attrs.getLastModifier(),
attrs.getCreateDate(),
attrs.getModDate(),
attrs.getAccessDate(),
getId(),
getGuid(),
getVersionID(),
null,
-1,
false,
-1,
false,
-1,
-1);
}
/**
* Get the descriptor for this node.
* @param lPath The Lookup.
* @return A descriptor.
*/
public AVMNodeDescriptor getDescriptor(Lookup lPath)
{
BasicAttributes attrs = getBasicAttributes();
String path = lPath.getRepresentedPath();
return new AVMNodeDescriptor(path,
path.substring(path.lastIndexOf("/") + 1),
AVMNodeType.PLAIN_DIRECTORY,
attrs.getCreator(),
attrs.getOwner(),
attrs.getLastModifier(),
attrs.getCreateDate(),
attrs.getModDate(),
attrs.getAccessDate(),
getId(),
getGuid(),
getVersionID(),
null,
-1,
false,
-1,
false,
-1,
-1);
}
/**
* Get this node's descriptor.
* @param parentPath The parent path.
* @param name The name that we were looked up under.
* @param parentIndirection The parent indirection.
* @return This node's node descriptor
*/
public AVMNodeDescriptor getDescriptor(String parentPath, String name, String parentIndirection, int parentIndirectionVersion)
{
BasicAttributes attrs = getBasicAttributes();
String path = parentPath.endsWith("/") ? parentPath + name : parentPath + "/" + name;
return new AVMNodeDescriptor(path,
name,
AVMNodeType.PLAIN_DIRECTORY,
attrs.getCreator(),
attrs.getOwner(),
attrs.getLastModifier(),
attrs.getCreateDate(),
attrs.getModDate(),
attrs.getAccessDate(),
getId(),
getGuid(),
getVersionID(),
null,
-1,
false,
-1,
false,
-1,
-1);
}
/**
* Link a node with the given id into this directory.
* @param lPath The Lookup for this directory.
* @param name The name to give the node.
* @param toLink The node to link in.
*/
public void link(Lookup lPath, String name, AVMNodeDescriptor toLink)
{
if (DEBUG)
{
checkReadOnly();
}
// Assure that the incoming node exists.
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(toLink.getId());
if (node == null)
{
throw new AVMNotFoundException("Node not found: " + toLink.getId());
}
if (node.getType() == AVMNodeType.LAYERED_DIRECTORY &&
!((LayeredDirectoryNode)node).getPrimaryIndirection())
{
throw new AVMBadArgumentException("Non primary layered directories cannot be linked.");
}
// Check for an existing child by the given name.
ChildKey key = new ChildKey(this, name);
ChildEntry child = AVMDAOs.Instance().fChildEntryDAO.get(key);
if (child != null)
{
if (child.getChild().getType() != AVMNodeType.DELETED_NODE)
{
// It's an error if there is a non DELETED_NODE child.
throw new AVMExistsException(name + " exists.");
}
// Get rid of the DELETED_NODE child.
AVMDAOs.Instance().fChildEntryDAO.delete(child);
}
// Make the new entry and save.
ChildEntry newChild = new ChildEntryImpl(key, node);
AVMDAOs.Instance().fChildEntryDAO.save(newChild);
}
}

View File

@@ -1,51 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm;
import org.alfresco.service.cmr.repository.ContentData;
/**
* Interface for Plain file nodes.
* @author britt
*/
public interface PlainFileNode extends FileNode
{
public ContentData getContentData();
public void setContentData(ContentData contentData);
public boolean isLegacyContentData();
public Long getContentDataId();
/**
* DAO accessor only. <b>DO NOT USE</b> in code.
*/
public String getContentURL();
/**
* DAO accessor only. <b>DO NOT USE</b> in code.
*/
public String getMimeType();
/**
* DAO accessor only. <b>DO NOT USE</b> in code.
*/
public String getEncoding();
/**
* DAO accessor only. <b>DO NOT USE</b> in code.
*/
public long getLength();
}

View File

@@ -1,472 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.domain.contentdata.ContentDataDAO;
import org.alfresco.repo.domain.permissions.Acl;
import org.alfresco.repo.security.permissions.ACLCopyMode;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.namespace.QName;
/**
* A plain old file. Contains a Content object.
* @author britt
*/
public class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
{
static final long serialVersionUID = 8720376837929735294L;
private static final String PREFIX_CONTENT_DATA_ID = "id:";
private static final String SUFFIX_CONTENT_DATA_NULL = "null";
/**
* The content URL <b>OR</b> the ID of the ContentData entity
*/
private String contentURL;
/**
* The Mime type.
*/
private String mimeType;
/**
* The character encoding.
*/
private String encoding;
/**
* The length of the file.
*/
private long length;
/**
* Default constructor.
*/
public PlainFileNodeImpl()
{
}
/**
* Make one from just an AVMStore.
* This is the constructor used when a brand new plain file is being made.
* @param store An AVMStore.
*/
public PlainFileNodeImpl(AVMStore store)
{
super(store);
setVersionID(1);
}
/**
* Copy on write constructor.
* @param other The node we are being copied from.
* @param store The AVMStore.
*/
public PlainFileNodeImpl(PlainFileNode other,
AVMStore store, Long parentAcl, ACLCopyMode mode)
{
super(store);
// The null is OK because the Lookup argument is only use by
// layered files.
setContentData(other.getContentData(null));
setVersionID(other.getVersionID() + 1);
copyACLs(other, parentAcl, mode);
copyCreationAndOwnerBasicAttributes(other);
AVMDAOs.Instance().fAVMNodeDAO.save(this);
copyProperties(other);
copyAspects(other);
}
// TODO Is there a reason for passing all these parameters instead
// of just the LayeredFileNode?
/**
* Construct a new one. This is called when a LayeredFileNode
* is copied.
* @param store
* @param attrs
* @param content
*/
public PlainFileNodeImpl(AVMStore store,
BasicAttributes attrs,
ContentData content,
Map<QName, PropertyValue> props,
Set<QName> aspects,
Acl acl,
int versionID,
Acl parentAcl,
ACLCopyMode mode)
{
super(store);
setContentData(content);
setBasicAttributes(attrs);
setVersionID(versionID + 1);
copyACLs(acl, parentAcl, mode);
AVMDAOs.Instance().fAVMNodeDAO.save(this);
addProperties(props);
setAspects(new HashSet<QName>(aspects));
}
/**
* Copy on write logic.
* @param lPath The lookup path.
*/
public AVMNode copy(Lookup lPath)
{
DirectoryNode dir = lPath.getCurrentNodeDirectory();
Long parentAclId = null;
if((dir != null) && (dir.getAcl() != null))
{
parentAclId = dir.getAcl().getId();
}
PlainFileNodeImpl newMe = new PlainFileNodeImpl(this, lPath.getAVMStore(), parentAclId, ACLCopyMode.COW);
newMe.setAncestor(this);
return newMe;
}
/**
* Get the type of this node.
* @return The type.
*/
public int getType()
{
return AVMNodeType.PLAIN_FILE;
}
/**
* Get a diagnostic string representation.
* @param lPath The Lookup.
* @return A diagnostic String representation.
*/
public String toString(Lookup lPath)
{
return "[PF:" + getId() + "]";
}
/**
* Get the descriptor for this node.
* @param lPath The Lookup.
* @return A descriptor.
*/
public AVMNodeDescriptor getDescriptor(Lookup lPath, String name)
{
BasicAttributes attrs = getBasicAttributes();
String path = lPath.getRepresentedPath();
if (path.endsWith("/"))
{
path = path + name;
}
else
{
path = path + "/" + name;
}
ContentData contentData = getContentData();
return new AVMNodeDescriptor(path,
name,
AVMNodeType.PLAIN_FILE,
attrs.getCreator(),
attrs.getOwner(),
attrs.getLastModifier(),
attrs.getCreateDate(),
attrs.getModDate(),
attrs.getAccessDate(),
getId(),
getGuid(),
getVersionID(),
null,
-1,
false,
-1,
false,
contentData == null ? 0L : contentData.getSize(),
-1);
}
/**
* Get the descriptor for this node.
* @param lPath The Lookup.
* @return A descriptor.
*/
public AVMNodeDescriptor getDescriptor(Lookup lPath)
{
BasicAttributes attrs = getBasicAttributes();
String path = lPath.getRepresentedPath();
ContentData contentData = getContentData();
return new AVMNodeDescriptor(path,
path.substring(path.lastIndexOf("/") + 1),
AVMNodeType.PLAIN_FILE,
attrs.getCreator(),
attrs.getOwner(),
attrs.getLastModifier(),
attrs.getCreateDate(),
attrs.getModDate(),
attrs.getAccessDate(),
getId(),
getGuid(),
getVersionID(),
null,
-1,
false,
-1,
false,
contentData == null ? 0L : contentData.getSize(),
-1);
}
/**
* Get the descriptor for this.
* @param parentPath The parent path.
* @param name The name this was looked up with.
* @param parentIndirection The parent indirection.
* @return The descriptor for this.
*/
public AVMNodeDescriptor getDescriptor(String parentPath, String name, String parentIndirection, int parentIndirectionVersion)
{
BasicAttributes attrs = getBasicAttributes();
String path = parentPath.endsWith("/") ? parentPath + name : parentPath + "/" + name;
ContentData contentData = getContentData();
return new AVMNodeDescriptor(path,
name,
AVMNodeType.PLAIN_FILE,
attrs.getCreator(),
attrs.getOwner(),
attrs.getLastModifier(),
attrs.getCreateDate(),
attrs.getModDate(),
attrs.getAccessDate(),
getId(),
getGuid(),
getVersionID(),
null,
-1,
false,
-1,
false,
contentData == null ? 0L : contentData.getSize(),
-1);
}
/**
* DAO accessor only. <b>DO NOT USE</b> in code.
*/
public String getContentURL()
{
return contentURL;
}
/**
* DAO accessor only. <b>DO NOT USE</b> in code.
*/
public void setContentURL(String contentURL)
{
this.contentURL = contentURL;
}
/**
* DAO accessor only. <b>DO NOT USE</b> in code.
*/
public String getMimeType()
{
return mimeType;
}
/**
* DAO accessor only. <b>DO NOT USE</b> in code.
*/
public void setMimeType(String mimeType)
{
this.mimeType = mimeType;
}
/**
* DAO accessor only. <b>DO NOT USE</b> in code.
*/
public String getEncoding()
{
return encoding;
}
/**
* DAO accessor only. <b>DO NOT USE</b> in code.
*/
public void setEncoding(String encoding)
{
this.encoding = encoding;
}
/**
* DAO accessor only. <b>DO NOT USE</b> in code.
*/
public long getLength()
{
return length;
}
/**
* DAO accessor only. <b>DO NOT USE</b> in code.
*/
public void setLength(long length)
{
this.length = length;
}
/**
* Set the ContentData for this file.
* @param contentData The value to set.
*/
public void setContentData(ContentData contentData)
{
// Remove any legacy-stored attributes to avoid confusion
if (isLegacyContentData())
{
// Wipe over the old values
contentURL = PREFIX_CONTENT_DATA_ID + SUFFIX_CONTENT_DATA_NULL;
encoding = null;
length = 0L;
mimeType = null;
}
Long oldContentDataId = getContentDataId();
Long newContentDataId = null;
if (oldContentDataId == null)
{
if (contentData != null)
{
// There was no reference before, so just create a new one
newContentDataId = AVMDAOs.Instance().contentDataDAO.createContentData(contentData).getFirst();
}
}
else
{
if (contentData != null)
{
// Update it. The ID will remain the same.
AVMDAOs.Instance().contentDataDAO.updateContentData(oldContentDataId, contentData);
newContentDataId = oldContentDataId;
}
else
{
// Delete the old instance
AVMDAOs.Instance().contentDataDAO.deleteContentData(oldContentDataId);
newContentDataId = null;
}
}
// Set the pointer to the ContentData instance
if (newContentDataId == null)
{
contentURL = PREFIX_CONTENT_DATA_ID + SUFFIX_CONTENT_DATA_NULL;
}
else
{
contentURL = PREFIX_CONTENT_DATA_ID + newContentDataId;
}
}
/**
* Get the ContentData for this file.
* @param lPath The lookup path used to get here. Unused here.
* @return The ContentData object for this file.
*/
public ContentData getContentData(Lookup lPath)
{
return getContentData();
}
/**
* {@inheritDoc}
* <p/>
* If the content URL contains the special prefix, <b>{@link PREFIX_CONTENT_DATA_ID}</b>,
* then the data is pulled directly from the {@link ContentDataDAO}.
*/
public ContentData getContentData()
{
if (contentURL != null && contentURL.startsWith(PREFIX_CONTENT_DATA_ID))
{
Long contentDataId = getContentDataId();
try
{
if (contentDataId == null)
{
return new ContentData(null, null, 0L, null);
}
else
{
return AVMDAOs.Instance().contentDataDAO.getContentData(contentDataId).getSecond();
}
}
catch (Throwable e)
{
throw new AlfrescoRuntimeException(
"AVM File node " + getId() + " has invalid ContentData id reference " + contentDataId,
e);
}
}
else
{
// This deals with legacy data
return new ContentData(contentURL, mimeType, length, encoding);
}
}
/**
* Checks the content URL and if it contains the {@link #PREFIX_CONTENT_DATA_ID prefix}
* indicating the an new ContentData storage ID, returns <tt>true</tt>.
*/
public boolean isLegacyContentData()
{
return (contentURL == null || !contentURL.startsWith(PREFIX_CONTENT_DATA_ID));
}
/**
* Get the ID of the ContentData as given by the string in the ContentURL of
* form <b>ID:12345</b>
*/
public Long getContentDataId()
{
String idStr = contentURL.substring(3);
if (idStr.equals(SUFFIX_CONTENT_DATA_NULL))
{
// Nothing has been stored against this file
return null;
}
try
{
return Long.parseLong(idStr);
}
catch (Throwable e)
{
throw new AlfrescoRuntimeException(
"AVM File node " + getId() + " has malformed ContentData id reference " + idStr,
e);
}
}
}

View File

@@ -1,334 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.repo.avm.util.SimplePath;
import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.util.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
/**
* A Transactional? implementation of AVM path lookup cache
*
* @author britt
*
* @deprecated
*/
public class TransactionalLookupCache implements LookupCache, InitializingBean
{
private static Log fgLogger = LogFactory.getLog(TransactionalLookupCache.class);
private static Log fgLoggerInit = LogFactory.getLog(TransactionalLookupCache.class.getName() + ".init");
/**
* The Map of of keys to lookups.
*/
private SimpleCache<LookupKey, Lookup> fCache;
/**
* Reference to the Node DAO.
*/
private AVMNodeDAO fAVMNodeDAO;
/**
* Reference to the Store DAO.
*/
private AVMStoreDAO fAVMStoreDAO;
/**
* Make one up.
*/
public TransactionalLookupCache()
{
}
/**
* Set up the node dao.
* @param dao The dao to set.
*/
public void setAvmNodeDAO(AVMNodeDAO dao)
{
fAVMNodeDAO = dao;
}
/**
* Set the store dao.
* @param dao The dao to set.
*/
public void setAvmStoreDAO(AVMStoreDAO dao)
{
fAVMStoreDAO = dao;
}
public void setTransactionalCache(SimpleCache<LookupKey, Lookup> cache)
{
fCache = cache;
}
/* (non-Javadoc)
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
public void afterPropertiesSet() throws Exception
{
if (fgLoggerInit.isDebugEnabled())
fgLoggerInit.debug("Transactional AVM lookup cache initialised");
}
/**
* Lookup a path. Try to fulfill the request from the cache.
* @param store The AVMStore.
* @param version The versions.
* @param path The path we are looking up.
* @param write Whether this is a write lookup.
* @param includeDeleted
* @return
*/
public Lookup lookup(AVMStore store, int version, SimplePath path,
boolean write, boolean includeDeleted)
{
// Create a key object.
LookupKey key = new LookupKey(version, path, store.getName(), write, includeDeleted);
// Is it in the cache?
Lookup found = findInCache(key);
// TODO Testing.
// found = null;
if (found != null)
{
if (fgLogger.isDebugEnabled())
{
fgLogger.debug("Cache Hit: " + key + ", " + found.getCurrentNode().getId());
}
return found;
}
// Make up a Lookup to hold the results.
if (path.size() == 0)
{
return null;
}
Lookup result = new Lookup(store, store.getName(), version);
// Grab the root node to start the lookup.
DirectoryNode dir = null;
// Versions less than 0 mean get current.
if (version < 0)
{
dir = store.getRoot();
}
else
{
VersionRoot vRoot = AVMDAOs.Instance().fVersionRootDAO.getByVersionID(store, version);
if (vRoot != null)
{
dir = vRoot.getRoot();
}
// dir = fAVMNodeDAO.getAVMStoreRoot(store, version);
}
if (dir == null)
{
return null;
}
// Add an entry for the root.
result.add(dir, "", true, write);
dir = (DirectoryNode)result.getCurrentNode();
if (path.size() == 1 && path.get(0).equals(""))
{
fCache.put(key, result);
return result;
}
// Now look up each path element in sequence up to one
// before the end.
for (int i = 0; i < path.size() - 1; i++)
{
if (!AVMRepository.GetInstance().can(null, dir, PermissionService.READ_CHILDREN, result.getDirectlyContained()))
{
throw new AccessDeniedException("Not allowed to read children: " + path.get(i));
}
Pair<AVMNode, Boolean> child = dir.lookupChild(result, path.get(i), includeDeleted);
if (child == null)
{
return null;
}
// Every element that is not the last needs to be a directory.
if (child.getFirst().getType() != AVMNodeType.PLAIN_DIRECTORY &&
child.getFirst().getType() != AVMNodeType.LAYERED_DIRECTORY)
{
return null;
}
result.add(child.getFirst(), path.get(i), child.getSecond(), write);
dir = (DirectoryNode)result.getCurrentNode();
}
// Now look up the last element.
if (!AVMRepository.GetInstance().can(null, dir, PermissionService.READ_CHILDREN, result.getDirectlyContained()))
{
throw new AccessDeniedException("Not allowed to read children: " + path.get(path.size() - 1));
}
Pair<AVMNode, Boolean> child = dir.lookupChild(result, path.get(path.size() - 1),
includeDeleted);
if (child == null)
{
return null;
}
result.add(child.getFirst(), path.get(path.size() - 1), child.getSecond(), write);
fCache.put(key, result);
return result;
}
/**
* Try to find a match in the cache.
* @param key The lookup key.
* @return A valid for this session Lookup or null if not found.
*/
private synchronized Lookup findInCache(LookupKey key)
{
Lookup found = fCache.get(key);
if (found != null)
{
// Get a freshened Lookup.
Lookup result = new Lookup(found, fAVMNodeDAO, fAVMStoreDAO);
// Check that nothing horrible is wrong. This should
// be assertible, but I'll leave the check in for now.
if (!result.isValid())
{
fgLogger.error("Invalid entry in cache: " + key);
return null;
}
return result;
}
// Alternatively for a read lookup a write can match.
if (!key.isWrite())
{
// Make a copy of the key and set it to 'write'
LookupKey newKey = new LookupKey(key);
newKey.setWrite(true);
found = fCache.get(newKey);
if (found != null)
{
// We found it. Make a freshened copy of the Lookup.
Lookup result = new Lookup(found, fAVMNodeDAO, fAVMStoreDAO);
// Check for badness. This should be assertible but I'll
// leave the check in for now.
if (!result.isValid())
{
fgLogger.error("Invalid entry in cache: " + newKey);
return null;
}
return result;
}
}
return null;
}
// Following are the cache invalidation calls.
/**
* Called when a simple write operation occurs. This
* invalidates all read lookups and all layered lookups.
*/
public synchronized void onWrite(String storeName)
{
// Invalidate if it's a read lookup in the store, or
// any read lookup is it's layered.
List<LookupKey> keys = new ArrayList<LookupKey>();
for (LookupKey key : fCache.getKeys())
{
keys.add(key);
}
for (LookupKey key : keys)
{
Lookup value = fCache.get(key);
if ((key.getStoreName().equals(storeName) &&
!key.isWrite()) || value == null ||
(!key.isWrite() && value.isLayered()))
{
if (fgLogger.isDebugEnabled())
{
fgLogger.debug("Invalidating: " + key + ", " + (value != null ? value.getCurrentNode().getId() : -2));
}
fCache.remove(key);
}
}
}
/**
* Called when a delete has occurred in a store. This invalidates both
* reads and write lookups in that store.
*/
public synchronized void onDelete(String storeName)
{
// Invalidate any entries that are in the store or are layered lookups.
List<LookupKey> keys = new ArrayList<LookupKey>();
for (LookupKey key : fCache.getKeys())
{
keys.add(key);
}
for (LookupKey key : keys)
{
Lookup value = fCache.get(key);
if (key.getStoreName().equals(storeName) ||
value == null || value.isLayered())
{
if (fgLogger.isDebugEnabled())
{
fgLogger.debug("Invalidating: " + key + ", " + (value != null ? value.getCurrentNode().getId() : -2));
}
fCache.remove(key);
}
}
}
/**
* Called when a snapshot occurs in a store. This invalidates write
* lookups. Read lookups stay untouched.
*/
public synchronized void onSnapshot(String storeName)
{
// Invalidate any entries that in the store and writes or
// any layered lookups.
List<LookupKey> keys = new ArrayList<LookupKey>();
for (LookupKey key : fCache.getKeys())
{
keys.add(key);
}
for (LookupKey key : keys)
{
Lookup value = fCache.get(key);
if ((key.getStoreName().equals(storeName) &&
key.isWrite()) ||
value == null || value.isLayered())
{
if (fgLogger.isDebugEnabled())
{
fgLogger.debug("Invalidating: " + key + ", " + (value != null ? value.getCurrentNode().getId() : -2));
}
fCache.remove(key);
}
}
}
public synchronized void reset()
{
fCache.clear();
}
}

View File

@@ -1,48 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm;
/**
* When a snapshot is created we stow away all of the layered
* nodes that were frozen by the snapshot so that subsequent
* snapshots can find them and force copies.
* @author britt
*/
public interface VersionLayeredNodeEntry
{
/**
* Get the VersionRoot for this entry.
* @return The VersionRoot for this entry.
*/
public VersionRoot getVersion();
/**
* Get the path to this entries Layered Node. This
* is a store relative path.
* @return The path.
*/
public String getPath();
/**
* Get the MD5 sum of the path.
* @return
*/
public String getMd5Sum();
}

View File

@@ -1,48 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm;
import java.util.List;
/**
* DAO interface for VersionLayeredNodeEntries.
* @author britt
*/
public interface VersionLayeredNodeEntryDAO
{
/**
* Save a newly created one.
* @param entry
*/
public void save(VersionLayeredNodeEntry entry);
/**
* Get all entries for a given version.
* @param version
* @return
*/
public List<VersionLayeredNodeEntry> get(VersionRoot version);
/**
* Delete all entries for the given version.
* @param version
*/
public void delete(VersionRoot version);
}

View File

@@ -1,134 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm;
import java.io.Serializable;
import org.alfresco.util.MD5;
/**
* Implementation of entry for tracking layered nodes which were
* snapshotted in a particular Version.
* @author britt
*/
public class VersionLayeredNodeEntryImpl implements VersionLayeredNodeEntry, Serializable
{
private static final long serialVersionUID = -5222079271680056311L;
private VersionRoot fVersion;
private String fMD5Sum;
private String fPath;
public VersionLayeredNodeEntryImpl()
{
}
public VersionLayeredNodeEntryImpl(VersionRoot version,
String path)
{
fVersion = version;
fMD5Sum = MD5.Digest(path.getBytes());
fPath = path;
}
public void setPath(String path)
{
fPath = path;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.VersionLayeredNodeEntry#getPath()
*/
public String getPath()
{
return fPath;
}
public void setVersion(VersionRoot version)
{
fVersion = version;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.VersionLayeredNodeEntry#getVersion()
*/
public VersionRoot getVersion()
{
return fVersion;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (!(obj instanceof VersionLayeredNodeEntry))
{
return false;
}
VersionLayeredNodeEntry other = (VersionLayeredNodeEntry)obj;
return fVersion.equals(other.getVersion()) &&
fMD5Sum.equals(other.getMd5Sum());
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode()
{
return fVersion.hashCode() + fMD5Sum.hashCode();
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("[VersionLayeredNodeEntry:");
builder.append(fVersion.toString());
builder.append(':');
builder.append(fPath);
builder.append(']');
return builder.toString();
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.VersionLayeredNodeEntry#getMd5Sum()
*/
public String getMd5Sum()
{
return fMD5Sum;
}
public void setMd5Sum(String sum)
{
fMD5Sum = sum;
}
}

View File

@@ -1,111 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
/**
* Represents a single version root.
* @author britt
*/
public interface VersionRoot
{
/**
* @return the createDate
*/
public long getCreateDate();
/**
* @param createDate the createDate to set
*/
public void setCreateDate(long createDate);
/**
* @return the creator
*/
public String getCreator();
/**
* @param creator the creator to set
*/
public void setCreator(String creator);
/**
* @return the id
*/
public Long getId();
/**
* @param id the id to set
*/
public void setId(long id);
/**
* @return the AVMStore
*/
public AVMStore getAvmStore();
/**
* @param store the store to set
*/
public void setAvmStore(AVMStore store);
/**
* @return the root
*/
public DirectoryNode getRoot();
/**
* @param root the root to set
*/
public void setRoot(DirectoryNode root);
/**
* Set the version id.
* @param versionID
*/
public void setVersionID(int versionID);
/**
* Get the version id.
* @return The version id.
*/
public int getVersionID();
/**
* Get the tag (short description).
* @return The tag.
*/
public String getTag();
/**
* Get the thick description.
* @return The thick description.
*/
public String getDescription();
/**
* Set the tag.
* @param tag
*/
public void setTag(String tag);
/**
* Set the description.
* @param description
*/
public void setDescription(String description);
}

View File

@@ -1,110 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.util.Date;
import java.util.List;
/**
* DAO for VersionRoot objects.
* @author britt
*/
public interface VersionRootDAO
{
/**
* Save an unsaved VersionRoot.
* @param vr The VersionRoot to save.
*/
public void save(VersionRoot vr);
public void update(VersionRoot vr);
/**
* Delete a VersionRoot.
* @param vr The VersionRoot to delete.
*/
public void delete(VersionRoot vr);
/**
* Get all the version roots in a given store.
* @param store The store.
* @return A List of VersionRoots. In id order.
*/
public List<VersionRoot> getAllInAVMStore(AVMStore store);
/**
* Get the VersionRoot corresponding to the given id.
* @param store The store
* @param id The version id.
* @return The VersionRoot or null if not found.
*/
public VersionRoot getByVersionID(AVMStore store, int id);
/**
* Get one from its root.
* @param root The root to match.
* @return The version root or null.
*/
public VersionRoot getByRoot(AVMNode root);
/**
* Get the version of a store by dates.
* @param store The store.
* @param from The starting date. May be null but not with to null also.
* @param to The ending date. May be null but not with from null also.
* @return A List of VersionRoots.
*/
public List<VersionRoot> getByDates(AVMStore store, Date from, Date to);
/**
* Get the highest numbered version in a store.
* @param store The store.
* @return The highest numbered version.
*/
public VersionRoot getMaxVersion(AVMStore store);
/**
* Get the highest numbered id from all the versions in a store.
* @param store The store.
* @return The highest numbered id.
*/
public Integer getMaxVersionID(AVMStore store);
/**
* @param store
* @param version
* @return
*/
public List<VersionRoot> getByVersionsTo(AVMStore store, int version);
/**
* @param store
* @param version
* @return
*/
public List<VersionRoot> getByVersionsFrom(AVMStore store, int version);
/**
* @param store
* @param startVersion
* @param endVersion
* @return
*/
public List<VersionRoot> getByVersionsBetween(AVMStore store, int startVersion, int endVersion);
}

View File

@@ -1,254 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm;
import java.io.Serializable;
/**
* Hold a single version root.
* @author britt
*/
public class VersionRootImpl implements VersionRoot, Serializable
{
static final long serialVersionUID = 8826954538210455917L;
/**
* The object id
*/
private Long fID;
/**
* The version id.
*/
private int fVersionID;
/**
* The creation date.
*/
private long fCreateDate;
/**
* The creator.
*/
private String fCreator;
/**
* The AVMStore.
*/
private AVMStore fAVMStore;
/**
* The root node.
*/
private DirectoryNode fRoot;
/**
* The short description.
*/
private String fTag;
/**
* The thick description.
*/
private String fDescription;
/**
* A default constructor.
*/
public VersionRootImpl()
{
}
/**
* Rich constructor.
* @param store
* @param root
* @param versionID
* @param createDate
* @param creator
*/
public VersionRootImpl(AVMStore store,
DirectoryNode root,
int versionID,
long createDate,
String creator,
String tag,
String description)
{
fAVMStore = store;
fRoot = root;
fVersionID = versionID;
fCreateDate = createDate;
fCreator = creator;
fTag = tag;
fDescription = description;
}
public long getCreateDate()
{
return fCreateDate;
}
public void setCreateDate(long createDate)
{
fCreateDate = createDate;
}
public String getCreator()
{
return fCreator;
}
public void setCreator(String creator)
{
fCreator = creator;
}
public Long getId()
{
return fID;
}
public void setId(long id)
{
fID = id;
}
public AVMStore getAvmStore()
{
return fAVMStore;
}
public void setAvmStore(AVMStore store)
{
fAVMStore = store;
}
public DirectoryNode getRoot()
{
return fRoot;
}
public void setRoot(DirectoryNode root)
{
fRoot = root;
}
/**
* Set the versionID.
* @param versionID
*/
public void setVersionID(int versionID)
{
fVersionID = versionID;
}
/**
* Get the version id.
* @return The version id.
*/
public int getVersionID()
{
return fVersionID;
}
/**
* Check equality. Based on AVMStore equality and version id equality.
* @param obj
* @return Equality.
*/
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (!(obj instanceof VersionRoot))
{
return false;
}
VersionRoot other = (VersionRoot)obj;
return fAVMStore.equals(other.getAvmStore())
&& fVersionID == other.getVersionID();
}
/**
* Generate a hash code.
* @return The hash code.
*/
@Override
public int hashCode()
{
return fAVMStore.hashCode() + fVersionID;
}
/**
* Get the tag (short description).
* @return The tag.
*/
public String getTag()
{
return fTag;
}
/**
* Set the tag (short description).
* @param tag The short description.
*/
public void setTag(String tag)
{
fTag = tag;
}
/**
* Get the thick description.
* @return The thick description.
*/
public String getDescription()
{
return fDescription;
}
/**
* Set the thick description.
* @param description The thick discription.
*/
public void setDescription(String description)
{
fDescription = description;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("[VersionRoot:");
builder.append(fAVMStore.getName());
builder.append(':');
builder.append(fVersionID);
builder.append(']');
return builder.toString();
}
}

View File

@@ -1,155 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm.actions;
import java.util.List;
import org.alfresco.config.JNDIConstants;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.repo.avm.AVMDAOs;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.wcm.sandbox.SandboxConstants;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncException;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.NameMatcher;
import org.alfresco.util.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* This action submits all the newer changes in the passed in NodeRef
* to its corresponding staging area. It ignores conflicts and older nodes.
* @author britt
*
* @deprecated see org.alfresco.wcm.actions.WCMSandboxSubmitAction or org.alfresco.wcm.SandboxService.submit
*/
public class SimpleAVMSubmitAction extends ActionExecuterAbstractBase
{
private static Log fgLogger = LogFactory.getLog(SimpleAVMSubmitAction.class);
public static String NAME = "simple-avm-submit";
/**
* The AVMService instance.
*/
private AVMService fAVMService;
/**
* The AVMSyncService instance.
*/
private AVMSyncService fAVMSyncService;
/**
* The Excluding NameMatcher.
*/
private NameMatcher fExcluder;
/**
* Default constructor.
*/
public SimpleAVMSubmitAction()
{
super();
}
/**
* Set the AVMService.
* @param avmService The instance.
*/
public void setAvmService(AVMService avmService)
{
fAVMService = avmService;
}
/**
* Set the AVMSyncService.
* @param avmSyncService The instance.
*/
public void setAvmSyncService(AVMSyncService avmSyncService)
{
fAVMSyncService = avmSyncService;
}
// TODO This should be a parameter of the action execution really.
/**
* Set the excluder.
* @param excluder
*/
public void setExcluder(NameMatcher excluder)
{
fExcluder = excluder;
}
/**
* Perform the action. The NodeRef must be an AVM NodeRef.
* @param action Don't actually need anything from this here.
* @param actionedUponNodeRef The AVM NodeRef.
*/
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
// Crack the NodeRef.
Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef);
int version = avmVersionPath.getFirst();
String path = avmVersionPath.getSecond();
// Get store name and path parts.
String [] storePath = path.split(":");
if (storePath.length != 2)
{
throw new AVMSyncException("Malformed source path " + path);
}
// Get the .website.name property.
PropertyValue wsProp =
fAVMService.getStoreProperty(storePath[0], SandboxConstants.PROP_WEBSITE_NAME);
if (wsProp == null)
{
fgLogger.warn(SandboxConstants.PROP_WEBSITE_NAME.toString()+" property not found.");
return;
}
// And the actual web-site name.
String websiteName = wsProp.getStringValue();
// Construct the submit destination path.
String avmDest = websiteName + ":" + storePath[1]; // note: it is implied that the website name is the same as staging name
// Get the difference between source and destination.
List<AVMDifference> diffs =
fAVMSyncService.compare(version, path, -1, avmDest, fExcluder);
// TODO fix update comments at some point.
// Do the update.
fAVMSyncService.update(diffs, fExcluder, false, false, true, true,
"Submit of item: " + AVMNodeConverter.SplitBase(path)[1], null);
// Cleanup by flattening the source relative to the destination.
fAVMSyncService.flatten(storePath[0] + ":/" + JNDIConstants.DIR_DEFAULT_WWW, websiteName + ":/" + JNDIConstants.DIR_DEFAULT_WWW);
}
/**
* This action takes no parameters.
* @param paramList The List to add nothing to.
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
// No parameters for this action.
}
}

View File

@@ -1,483 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm.ibatis;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.avm.AVMDAOs;
import org.alfresco.repo.avm.AVMNode;
import org.alfresco.repo.avm.AVMNodeDAO;
import org.alfresco.repo.avm.AVMNodeImpl;
import org.alfresco.repo.avm.AVMNodeType;
import org.alfresco.repo.avm.AVMStore;
import org.alfresco.repo.avm.BasicAttributes;
import org.alfresco.repo.avm.BasicAttributesImpl;
import org.alfresco.repo.avm.DeletedNode;
import org.alfresco.repo.avm.DeletedNodeImpl;
import org.alfresco.repo.avm.DirectoryNode;
import org.alfresco.repo.avm.Layered;
import org.alfresco.repo.avm.LayeredDirectoryNode;
import org.alfresco.repo.avm.LayeredDirectoryNodeImpl;
import org.alfresco.repo.avm.LayeredFileNode;
import org.alfresco.repo.avm.LayeredFileNodeImpl;
import org.alfresco.repo.avm.PlainDirectoryNode;
import org.alfresco.repo.avm.PlainDirectoryNodeImpl;
import org.alfresco.repo.avm.PlainFileNode;
import org.alfresco.repo.avm.PlainFileNodeImpl;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.domain.avm.AVMHistoryLinkEntity;
import org.alfresco.repo.domain.avm.AVMMergeLinkEntity;
import org.alfresco.repo.domain.avm.AVMNodeEntity;
import org.alfresco.repo.domain.avm.AVMVersionRootEntity;
import org.alfresco.repo.domain.permissions.Acl;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* iBATIS DAO wrapper for AVMNode
*
* @author janv
*
*/
class AVMNodeDAOIbatis implements AVMNodeDAO
{
private static Log logger = LogFactory.getLog(AVMNodeDAO.class);
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#save(org.alfresco.repo.avm.AVMNode)
*/
public void save(AVMNode node)
{
AVMNodeEntity nodeEntity = AVMDAOs.Instance().newAVMNodeDAO.createNode(convertNodeToNodeEntity(node));
((AVMNodeImpl)node).setId(nodeEntity.getId());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#delete(org.alfresco.repo.avm.AVMNode)
*/
public void delete(AVMNode node)
{
AVMDAOs.Instance().newAVMNodeDAO.deleteNode(node.getId());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#createAspect(long, long)
*/
public void createAspect(long nodeId, QName aspectQName)
{
AVMDAOs.Instance().newAVMNodeDAO.createAspect(nodeId, aspectQName);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#deleteAspect(long, long)
*/
public void deleteAspect(long nodeId, QName aspectQName)
{
AVMDAOs.Instance().newAVMNodeDAO.deleteAspect(nodeId, aspectQName);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#deleteAspects(long)
*/
public void deleteAspects(long nodeId)
{
AVMDAOs.Instance().newAVMNodeDAO.deleteAspects(nodeId);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#getAspects(long)
*/
public Set<QName> getAspects(long nodeId)
{
return AVMDAOs.Instance().newAVMNodeDAO.getAspects(nodeId);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#createOrUpdateProperty(long, QName, org.alfresco.repo.domain.PropertyValue)
*/
public void createOrUpdateProperty(long nodeId, QName qname, PropertyValue value)
{
AVMDAOs.Instance().newAVMNodeDAO.createOrUpdateNodeProperty(nodeId, qname, value);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#deleteProperty(long, QName)
*/
public void deleteProperty(long nodeId, QName propQName)
{
AVMDAOs.Instance().newAVMNodeDAO.deleteNodeProperty(nodeId, propQName);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#deleteProperties(long)
*/
public void deleteProperties(long nodeId)
{
AVMDAOs.Instance().newAVMNodeDAO.deleteNodeProperties(nodeId);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#getProperties(long)
*/
public Map<QName, PropertyValue> getProperties(long nodeId)
{
return AVMDAOs.Instance().newAVMNodeDAO.getNodeProperties(nodeId);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#getByID(long)
*/
public AVMNode getByID(long id)
{
return convertNodeEntityToNode(AVMDAOs.Instance().newAVMNodeDAO.getNode(id));
}
/* package */ AVMNode getRootNodeByID(AVMStore store, long rootNodeId)
{
AVMNodeEntity rootNodeEntity = null;
try
{
rootNodeEntity = AVMDAOs.Instance().newAVMNodeDAO.getNode(rootNodeId);
}
catch (RuntimeException re)
{
if (logger.isWarnEnabled())
{
logger.warn("Root node ("+rootNodeId+") not found for store: "+store);
}
throw re;
}
AVMNode rootNode = null;
if (rootNodeEntity.getStoreNewId() != null)
{
rootNode = convertNodeEntityToNode(rootNodeEntity, false);
rootNode.setStoreNew(store);
}
else
{
rootNode = convertNodeEntityToNode(rootNodeEntity);
}
return rootNode;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#update(org.alfresco.repo.avm.AVMNode)
*/
public void update(AVMNode node)
{
AVMNodeEntity nodeEntity = convertNodeToNodeEntity(node);
AVMDAOs.Instance().newAVMNodeDAO.updateNode(nodeEntity);
((AVMNodeImpl)node).setVers(nodeEntity.getVers());
}
/**
* TODO review
*
* @deprecated
*/
public void updateModTimeAndGuid(AVMNode node)
{
AVMNodeEntity nodeEntity = convertNodeToNodeEntity(node);
AVMDAOs.Instance().newAVMNodeDAO.updateNodeModTimeAndGuid(nodeEntity);
((AVMNodeImpl)node).setVers(nodeEntity.getVers());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#getAVMStoreRoot(org.alfresco.repo.avm.AVMStore, int)
*/
public DirectoryNode getAVMStoreRoot(AVMStore store, int version)
{
AVMVersionRootEntity vrEntity = AVMDAOs.Instance().newAVMVersionRootDAO.getByVersionID(store.getId(), version);
if (vrEntity == null)
{
return null;
}
return (DirectoryNode) getByID(vrEntity.getRootNodeId());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#getAncestor(org.alfresco.repo.avm.AVMNode)
*/
public AVMNode getAncestor(AVMNode descendent)
{
AVMHistoryLinkEntity hlEntity = AVMDAOs.Instance().newAVMNodeLinksDAO.getHistoryLinkByDescendent(descendent.getId());
if (hlEntity == null)
{
return null;
}
return AVMDAOs.Instance().fAVMNodeDAO.getByID(hlEntity.getAncestorNodeId());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#getMergedFrom(org.alfresco.repo.avm.AVMNode)
*/
public AVMNode getMergedFrom(AVMNode mTo)
{
AVMMergeLinkEntity mlEntity = AVMDAOs.Instance().newAVMNodeLinksDAO.getMergeLinkByTo(mTo.getId());
if (mlEntity == null)
{
return null;
}
return AVMDAOs.Instance().fAVMNodeDAO.getByID(mlEntity.getMergeFromNodeId());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#getOrphans(int)
*/
public List<AVMNode> getOrphans(int batchSize)
{
List<AVMNodeEntity> nodeEntities = AVMDAOs.Instance().newAVMNodeDAO.getNodeOrphans(batchSize);
if (nodeEntities == null)
{
return new ArrayList<AVMNode>(0);
}
List<AVMNode> nodes = new ArrayList<AVMNode>(nodeEntities.size());
for (AVMNodeEntity nodeEntity : nodeEntities)
{
nodes.add(convertNodeEntityToNode(nodeEntity));
}
return nodes;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#getNewInStore(org.alfresco.repo.avm.AVMStore)
*/
public List<AVMNode> getNewInStore(AVMStore store)
{
List<AVMNodeEntity> nodeEntities = AVMDAOs.Instance().newAVMNodeDAO.getNodesNewInStore(store.getId());
if (nodeEntities == null)
{
return new ArrayList<AVMNode>(0);
}
List<AVMNode> nodes = new ArrayList<AVMNode>(nodeEntities.size());
for (AVMNodeEntity nodeEntity : nodeEntities)
{
nodes.add(convertNodeEntityToNode(nodeEntity));
}
return nodes;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#clear()
*/
public void clear()
{
AVMDAOs.Instance().newAVMNodeDAO.clearNodeEntityCache();
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#clearNewInStore(org.alfresco.repo.avm.AVMStore)
*/
public void clearNewInStore(AVMStore store)
{
AVMDAOs.Instance().newAVMNodeDAO.updateNodesClearNewInStore(store.getId());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#getNewLayeredInStoreIDs(org.alfresco.repo.avm.AVMStore)
*/
public List<Long> getNewLayeredInStoreIDs(AVMStore store)
{
return AVMDAOs.Instance().newAVMNodeDAO.getLayeredNodesNewInStoreIDs(store.getId());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMNodeDAO#getNewLayeredInStore(org.alfresco.repo.avm.AVMStore)
*/
public List<Layered> getNewLayeredInStore(AVMStore store)
{
List<AVMNodeEntity> nodeEntities = AVMDAOs.Instance().newAVMNodeDAO.getLayeredNodesNewInStore(store.getId());
if (nodeEntities == null)
{
return new ArrayList<Layered>(0);
}
List<Layered> nodes = new ArrayList<Layered>(nodeEntities.size());
for (AVMNodeEntity nodeEntity : nodeEntities)
{
nodes.add((Layered)convertNodeEntityToNode(nodeEntity));
}
return nodes;
}
private AVMNodeEntity convertNodeToNodeEntity(AVMNode node)
{
AVMNodeEntity nodeEntity = new AVMNodeEntity();
nodeEntity.setId(node.getId());
nodeEntity.setAccessDate(node.getBasicAttributes().getAccessDate());
nodeEntity.setOwner(node.getBasicAttributes().getOwner());
nodeEntity.setCreator(node.getBasicAttributes().getCreator());
nodeEntity.setCreatedDate(node.getBasicAttributes().getCreateDate());
nodeEntity.setModifier(node.getBasicAttributes().getLastModifier());
nodeEntity.setModifiedDate(node.getBasicAttributes().getModDate());
nodeEntity.setType(node.getType());
nodeEntity.setVersion(new Long(node.getVersionID()));
nodeEntity.setVers(((AVMNodeImpl)node).getVers());
nodeEntity.setAclId((node.getAcl() == null ? null : node.getAcl().getId()));
nodeEntity.setGuid(node.getGuid());
nodeEntity.setStoreNewId(node.getStoreNew() == null ? null : node.getStoreNew().getId());
nodeEntity.setRoot(node.getIsRoot());
if (node instanceof PlainFileNode)
{
PlainFileNode pfNode = (PlainFileNode)node;
nodeEntity.setEncoding(pfNode.getEncoding());
nodeEntity.setLength(pfNode.getLength());
nodeEntity.setMimetype(pfNode.getMimeType());
nodeEntity.setContentUrl(pfNode.getContentURL());
}
else if (node instanceof LayeredFileNode)
{
LayeredFileNode lfNode = (LayeredFileNode)node;
nodeEntity.setIndirection(lfNode.getIndirection());
nodeEntity.setIndirectionVersion(lfNode.getIndirectionVersion());
}
else if (node instanceof PlainDirectoryNode)
{
// no additional
}
else if (node instanceof LayeredDirectoryNode)
{
LayeredDirectoryNode ldNode = (LayeredDirectoryNode)node;
nodeEntity.setIndirection(ldNode.getIndirection());
nodeEntity.setIndirectionVersion(ldNode.getIndirectionVersion());
nodeEntity.setLayerId(ldNode.getLayerID());
nodeEntity.setPrimaryIndirection(ldNode.getPrimaryIndirection());
nodeEntity.setOpacity(ldNode.getOpacity());
}
else if (node instanceof DeletedNode)
{
DeletedNode dNode = (DeletedNode)node;
nodeEntity.setDeletedType(dNode.getDeletedType());
}
return nodeEntity;
}
private AVMNode convertNodeEntityToNode(AVMNodeEntity nodeEntity)
{
return convertNodeEntityToNode(nodeEntity, true);
}
private AVMNode convertNodeEntityToNode(AVMNodeEntity nodeEntity, boolean withStore)
{
if (nodeEntity == null)
{
return null;
}
AVMNodeImpl node = null;
if (nodeEntity.getType() == AVMNodeType.PLAIN_FILE)
{
node = new PlainFileNodeImpl();
PlainFileNodeImpl pfNode = (PlainFileNodeImpl) node;
pfNode.setMimeType(nodeEntity.getMimetype());
pfNode.setEncoding(nodeEntity.getEncoding());
pfNode.setLength(nodeEntity.getLength());
pfNode.setContentURL(nodeEntity.getContentUrl());
}
else if (nodeEntity.getType() == AVMNodeType.PLAIN_DIRECTORY)
{
node = new PlainDirectoryNodeImpl();
// no additional
}
else if (nodeEntity.getType() == AVMNodeType.LAYERED_FILE)
{
node = new LayeredFileNodeImpl();
((LayeredFileNodeImpl)node).setIndirection(nodeEntity.getIndirection());
((LayeredFileNodeImpl)node).setIndirectionVersion(nodeEntity.getIndirectionVersion());
}
else if (nodeEntity.getType() == AVMNodeType.LAYERED_DIRECTORY)
{
node = new LayeredDirectoryNodeImpl();
((LayeredDirectoryNodeImpl)node).setIndirection(nodeEntity.getIndirection());
((LayeredDirectoryNodeImpl)node).setIndirectionVersion(nodeEntity.getIndirectionVersion());
((LayeredDirectoryNodeImpl)node).setPrimaryIndirection(nodeEntity.isPrimaryIndirection());
((LayeredDirectoryNodeImpl)node).setLayerID(nodeEntity.getLayerId());
((LayeredDirectoryNodeImpl)node).setOpacity(nodeEntity.getOpacity());
}
else if (nodeEntity.getType() == AVMNodeType.DELETED_NODE)
{
node = new DeletedNodeImpl();
((DeletedNodeImpl)node).setDeletedType(nodeEntity.getDeletedType());
}
else
{
// belts-and-braces
throw new AlfrescoRuntimeException("Unexpected node type: "+nodeEntity.getType());
}
node.setId(nodeEntity.getId());
node.setIsRoot(nodeEntity.isRoot());
node.setGuid(nodeEntity.getGuid());
node.setVersionID(nodeEntity.getVersion().intValue());
node.setVers(nodeEntity.getVers());
BasicAttributes ba = new BasicAttributesImpl();
ba.setAccessDate(nodeEntity.getAccessDate());
ba.setModDate(nodeEntity.getModifiedDate());
ba.setCreateDate(nodeEntity.getCreatedDate());
ba.setLastModifier(nodeEntity.getModifier());
ba.setCreator(nodeEntity.getCreator());
ba.setOwner(nodeEntity.getOwner());
node.setBasicAttributes(ba);
AVMStore store = null;
if (withStore)
{
if (nodeEntity.getStoreNewId() != null)
{
store = AVMDAOs.Instance().fAVMStoreDAO.getByID(nodeEntity.getStoreNewId());
}
}
node.setStoreNew(store);
Acl acl = null;
if (nodeEntity.getAclId() != null)
{
acl = AVMDAOs.Instance().fAclDAO.getAcl(nodeEntity.getAclId());
}
node.setAcl(acl);
return node;
}
}

View File

@@ -1,181 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm.ibatis;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.repo.avm.AVMDAOs;
import org.alfresco.repo.avm.AVMNode;
import org.alfresco.repo.avm.AVMStore;
import org.alfresco.repo.avm.AVMStoreDAO;
import org.alfresco.repo.avm.AVMStoreImpl;
import org.alfresco.repo.avm.DirectoryNode;
import org.alfresco.repo.domain.avm.AVMStoreEntity;
import org.alfresco.repo.domain.permissions.Acl;
import org.alfresco.service.cmr.avm.AVMException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* iBATIS DAO wrapper for AVMStore
*
* @author janv
*/
class AVMStoreDAOIbatis implements AVMStoreDAO
{
private static Log logger = LogFactory.getLog(AVMStoreDAOIbatis.class);
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMStoreDAO#save(org.alfresco.repo.avm.AVMStore)
*/
public void save(AVMStore store)
{
AVMStoreEntity storeEntity = AVMDAOs.Instance().newAVMStoreDAO.createStore(store.getName());
((AVMStoreImpl)store).setId(storeEntity.getId());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMStoreDAO#delete(org.alfresco.repo.avm.AVMStore)
*/
public void delete(AVMStore store)
{
AVMDAOs.Instance().newAVMStoreDAO.deleteStore(store.getId());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMStoreDAO#getAll()
*/
public List<AVMStore> getAll()
{
List<AVMStoreEntity> storeEntities = AVMDAOs.Instance().newAVMStoreDAO.getAllStores();
List<AVMStore> result = new ArrayList<AVMStore>(storeEntities.size());
for (AVMStoreEntity storeEntity : storeEntities)
{
result.add(getByID(storeEntity.getId()));
}
return result;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMStoreDAO#getByName(java.lang.String)
*/
public AVMStore getByName(String name)
{
AVMStoreEntity storeEntity = AVMDAOs.Instance().newAVMStoreDAO.getStore(name);
return convertStoreEntityToStore(storeEntity);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMStoreDAO#getByRoot(org.alfresco.repo.avm.AVMNode)
*/
public AVMStore getByRoot(AVMNode root)
{
AVMStoreEntity storeEntity = AVMDAOs.Instance().newAVMStoreDAO.getStoreByRoot(root.getId());
return convertStoreEntityToStore(storeEntity);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMStoreDAO#update(org.alfresco.repo.avm.AVMStore)
*/
public void update(AVMStore store)
{
AVMStoreEntity storeEntity = convertStoreToStoreEntity(store);
AVMDAOs.Instance().newAVMStoreDAO.updateStore(storeEntity);
((AVMStoreImpl)store).setVers(storeEntity.getVers());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMStoreDAO#getByID(long)
*/
public AVMStore getByID(long id)
{
AVMStoreEntity storeEntity = AVMDAOs.Instance().newAVMStoreDAO.getStore(id);
return convertStoreEntityToStore(storeEntity);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMStoreDAO#invalidateCache()
*/
public void invalidateCache()
{
AVMDAOs.Instance().newAVMStoreDAO.clearStoreEntityCache();
}
private AVMStore convertStoreEntityToStore(AVMStoreEntity storeEntity)
{
if (storeEntity == null)
{
return null;
}
AVMStoreImpl store = new AVMStoreImpl();
store.setId(storeEntity.getId());
store.setName(storeEntity.getName());
store.setNextVersionID(storeEntity.getVersion().intValue());
store.setVers(storeEntity.getVers());
Acl acl = null;
if (storeEntity.getAclId() != null)
{
acl = AVMDAOs.Instance().fAclDAO.getAcl(storeEntity.getAclId());
}
store.setStoreAcl(acl);
Long rootNodeId = storeEntity.getRootNodeId();
if (rootNodeId == null)
{
if (logger.isWarnEnabled())
{
logger.warn("Root node id is null for store: "+storeEntity);
}
throw new AVMException(storeEntity.toString());
}
DirectoryNode rootNode = (DirectoryNode) ((AVMNodeDAOIbatis)AVMDAOs.Instance().fAVMNodeDAO).getRootNodeByID(store, rootNodeId);
if (rootNode == null)
{
// belts-and-braces
if (logger.isWarnEnabled())
{
logger.warn("Root node ("+rootNodeId+") not found for store: "+storeEntity);
}
throw new AVMException(storeEntity.toString());
}
store.setRoot(rootNode);
return store;
}
private AVMStoreEntity convertStoreToStoreEntity(AVMStore store)
{
AVMStoreEntity storeEntity = new AVMStoreEntity();
storeEntity.setId(store.getId());
storeEntity.setName(store.getName());
storeEntity.setRootNodeId(store.getRoot().getId());
storeEntity.setVersion(new Long(store.getNextVersionID()));
storeEntity.setVers(((AVMStoreImpl)store).getVers());
storeEntity.setAclId((store.getStoreAcl() == null ? null : store.getStoreAcl().getId()));
return storeEntity;
}
}

View File

@@ -1,130 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm.ibatis;
import java.util.Map;
import org.alfresco.repo.avm.AVMDAOs;
import org.alfresco.repo.avm.AVMStore;
import org.alfresco.repo.avm.AVMStoreProperty;
import org.alfresco.repo.avm.AVMStorePropertyDAO;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.namespace.QName;
/**
* iBATIS DAO wrapper for AVMStoreProperty
*
* @author janv
*/
class AVMStorePropertyDAOIbatis implements AVMStorePropertyDAO
{
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMStorePropertyDAO#save(org.alfresco.repo.avm.AVMStoreProperty)
*/
public void save(AVMStoreProperty prop)
{
AVMDAOs.Instance().newAVMStoreDAO.createOrUpdateStoreProperty(prop.getStore().getId(), prop.getQname(), prop.getValue());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMStorePropertyDAO#get(org.alfresco.repo.avm.AVMStore, org.alfresco.service.namespace.QName)
*/
public PropertyValue get(AVMStore store, QName name)
{
return AVMDAOs.Instance().newAVMStoreDAO.getStoreProperty(store.getId(), name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMStorePropertyDAO#get(org.alfresco.repo.avm.AVMStore)
*/
public Map<QName, PropertyValue> get(AVMStore store)
{
return AVMDAOs.Instance().newAVMStoreDAO.getStoreProperties(store.getId());
}
/**
* Query store properties by key pattern.
* @param store The store.
* @param keyPattern An sql 'like' pattern wrapped up in a QName
* @return A List of matching AVMStoreProperties.
*/
public Map<QName, PropertyValue> queryByKeyPattern(AVMStore store, QName keyPattern)
{
// Get the URI and LocalName parts
String uri = keyPattern.getNamespaceURI();
if (uri == null || uri.length() == 0)
{
uri = "%";
}
String localName = keyPattern.getLocalName();
if (localName == null || localName.length() == 0)
{
localName = "%";
}
return AVMDAOs.Instance().newAVMStoreDAO.getStorePropertiesByStoreAndKeyPattern(store.getId(), uri, localName);
}
/**
* Query all stores' properties by key pattern.
* @param keyPattern The sql 'like' pattern wrapped up in a QName
* @return A List of match AVMStoreProperties.
*/
public Map<String, Map<QName, PropertyValue>> queryByKeyPattern(QName keyPattern)
{
// Get the URI and LocalName parts
String uri = keyPattern.getNamespaceURI();
if (uri == null || uri.length() == 0)
{
uri = "%";
}
String localName = keyPattern.getLocalName();
if (localName == null || localName.length() == 0)
{
localName = "%";
}
return AVMDAOs.Instance().newAVMStoreDAO.getStorePropertiesByKeyPattern(uri, localName);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMStorePropertyDAO#update(org.alfresco.repo.avm.AVMStoreProperty)
*/
public void update(AVMStoreProperty prop)
{
// NOOP
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMStorePropertyDAO#delete(org.alfresco.repo.avm.AVMStore, org.alfresco.service.namespace.QName)
*/
public void delete(AVMStore store, QName name)
{
AVMDAOs.Instance().newAVMStoreDAO.deleteStoreProperty(store.getId(), name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMStorePropertyDAO#delete(org.alfresco.repo.avm.AVMStore)
*/
public void delete(AVMStore store)
{
AVMDAOs.Instance().newAVMStoreDAO.deleteStoreProperties(store.getId());
}
}

View File

@@ -1,183 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm.ibatis;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.avm.AVMDAOs;
import org.alfresco.repo.avm.AVMNode;
import org.alfresco.repo.avm.ChildEntry;
import org.alfresco.repo.avm.ChildEntryDAO;
import org.alfresco.repo.avm.ChildEntryImpl;
import org.alfresco.repo.avm.ChildKey;
import org.alfresco.repo.avm.DirectoryNode;
import org.alfresco.repo.domain.avm.AVMChildEntryEntity;
import org.springframework.dao.ConcurrencyFailureException;
/**
* iBATIS DAO wrapper for ChildEntry
*
* @author jan
*/
class ChildEntryDAOIbatis implements ChildEntryDAO
{
/* (non-Javadoc)
* @see org.alfresco.repo.avm.ChildEntryDAO#save(org.alfresco.repo.avm.ChildEntry)
*/
public void save(ChildEntry entry)
{
AVMDAOs.Instance().newAVMNodeLinksDAO.createChildEntry(entry.getKey().getParent().getId(), entry.getKey().getName(), entry.getChild().getId());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.ChildEntryDAO#get(org.alfresco.repo.avm.ChildKey)
*/
public ChildEntry get(ChildKey key)
{
AVMChildEntryEntity childEntryEntity = AVMDAOs.Instance().newAVMNodeLinksDAO.getChildEntry(key.getParent().getId(), key.getName());
return getChildEntryForParent(key.getParent(), childEntryEntity);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.ChildEntryDAO#getByParent(org.alfresco.repo.avm.DirectoryNode, java.lang.String)
*/
public List<ChildEntry> getByParent(DirectoryNode parent, String childNamePattern)
{
List<AVMChildEntryEntity> childEntryEntities = AVMDAOs.Instance().newAVMNodeLinksDAO.getChildEntriesByParent(parent.getId(), childNamePattern);
List<ChildEntry> result = new ArrayList<ChildEntry>(childEntryEntities.size());
for (AVMChildEntryEntity childEntryEntity : childEntryEntities)
{
result.add(getChildEntryForParent(parent, childEntryEntity));
}
return result;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.ChildEntryDAO#getByParentChild(org.alfresco.repo.avm.DirectoryNode, org.alfresco.repo.avm.AVMNode)
*/
public boolean existsParentChild(DirectoryNode parent, AVMNode child)
{
AVMChildEntryEntity childEntryEntity = AVMDAOs.Instance().newAVMNodeLinksDAO.getChildEntry(parent.getId(), child.getId());
return (childEntryEntity != null);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.ChildEntryDAO#getByChild(org.alfresco.repo.avm.AVMNode)
*/
public List<ChildEntry> getByChild(AVMNode child)
{
List<AVMChildEntryEntity> childEntryEntities = AVMDAOs.Instance().newAVMNodeLinksDAO.getChildEntriesByChild(child.getId());
List<ChildEntry> result = new ArrayList<ChildEntry>(childEntryEntities.size());
for (AVMChildEntryEntity childEntryEntity : childEntryEntities)
{
result.add(getChildEntryForChild(child, childEntryEntity));
}
return result;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.ChildEntryDAO#rename(org.alfresco.repo.avm.ChildKey, String)
*/
public void rename(ChildKey key, String newName)
{
// direct rename should only be used if changing case
if (! key.getName().equalsIgnoreCase(newName))
{
throw new AlfrescoRuntimeException("Invalid rename (can only change case");
}
AVMChildEntryEntity childEntryEntity = AVMDAOs.Instance().newAVMNodeLinksDAO.getChildEntry(key.getParent().getId(), key.getName());
childEntryEntity.setName(newName);
AVMDAOs.Instance().newAVMNodeLinksDAO.updateChildEntry(childEntryEntity);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.ChildEntryDAO#delete(org.alfresco.repo.avm.ChildEntry)
*/
public void delete(ChildEntry child)
{
AVMChildEntryEntity childEntryEntity = new AVMChildEntryEntity();
childEntryEntity.setParentNodeId(child.getKey().getParent().getId());
childEntryEntity.setName(child.getKey().getName());
childEntryEntity.setChildNodeId(child.getChild().getId());
AVMDAOs.Instance().newAVMNodeLinksDAO.deleteChildEntry(childEntryEntity);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.ChildEntryDAO#deleteByParent(org.alfresco.repo.avm.AVMNode)
*/
public void deleteByParent(AVMNode parent)
{
AVMDAOs.Instance().newAVMNodeLinksDAO.deleteChildEntriesByParent(parent.getId());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.ChildEntryDAO#evict(org.alfresco.repo.avm.ChildEntry)
*/
public void evict(ChildEntry entry)
{
// NOOP
}
private ChildEntry getChildEntryForParent(DirectoryNode parentNode, AVMChildEntryEntity childEntryEntity)
{
if (childEntryEntity == null)
{
return null;
}
AVMNode childNode = AVMDAOs.Instance().fAVMNodeDAO.getByID(childEntryEntity.getChildId());
if (childNode == null)
{
throw new ConcurrencyFailureException("Child node (" + childEntryEntity.getParentNodeId() + ", " + childEntryEntity.getChildId() + ") no longer exists");
}
ChildEntry ce = new ChildEntryImpl(new ChildKey(parentNode, childEntryEntity.getName()), childNode);
return ce;
}
private ChildEntry getChildEntryForChild(AVMNode childNode, AVMChildEntryEntity childEntryEntity)
{
if (childEntryEntity == null)
{
return null;
}
DirectoryNode parentNode = (DirectoryNode)AVMDAOs.Instance().fAVMNodeDAO.getByID(childEntryEntity.getParentNodeId());
if (parentNode == null)
{
throw new ConcurrencyFailureException("Parent node (" + childEntryEntity.getParentNodeId() + ", " + childEntryEntity.getChildId() + ") no longer exists");
}
ChildEntry ce = new ChildEntryImpl(new ChildKey(parentNode, childEntryEntity.getName()), childNode);
return ce;
}
}

View File

@@ -1,75 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm.ibatis;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.repo.avm.AVMDAOs;
import org.alfresco.repo.avm.VersionLayeredNodeEntry;
import org.alfresco.repo.avm.VersionLayeredNodeEntryDAO;
import org.alfresco.repo.avm.VersionLayeredNodeEntryImpl;
import org.alfresco.repo.avm.VersionRoot;
import org.alfresco.repo.domain.avm.AVMVersionLayeredNodeEntryEntity;
/**
* iBATIS DAO wrapper for VersionLayeredNodeEntry
*
* @author janv
*/
class VersionLayeredNodeEntryDAOIbatis implements VersionLayeredNodeEntryDAO
{
/* (non-Javadoc)
* @see org.alfresco.repo.avm.VersionLayeredNodeEntryDAO#delete(org.alfresco.repo.avm.VersionRoot)
*/
public void delete(VersionRoot version)
{
AVMDAOs.Instance().newAVMVersionRootDAO.deleteVersionLayeredNodeEntries(version.getId());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.VersionLayeredNodeEntryDAO#get(org.alfresco.repo.avm.VersionRoot)
*/
public List<VersionLayeredNodeEntry> get(VersionRoot version)
{
List<AVMVersionLayeredNodeEntryEntity> vlneEntities = AVMDAOs.Instance().newAVMVersionRootDAO.getVersionLayeredNodeEntries(version.getId());
List<VersionLayeredNodeEntry> vlnes = new ArrayList<VersionLayeredNodeEntry>(vlneEntities.size());
for(AVMVersionLayeredNodeEntryEntity vlneEntity : vlneEntities)
{
VersionLayeredNodeEntryImpl vlne = new VersionLayeredNodeEntryImpl();
vlne.setVersion(version);
vlne.setMd5Sum(vlneEntity.getMd5sum());
vlne.setPath(vlneEntity.getPath());
vlnes.add(vlne);
}
return vlnes;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.VersionLayeredNodeEntryDAO#save(org.alfresco.repo.avm.VersionLayeredNodeEntry)
*/
public void save(VersionLayeredNodeEntry entry)
{
AVMDAOs.Instance().newAVMVersionRootDAO.createVersionLayeredNodeEntry(entry.getVersion().getId(), entry.getMd5Sum(), entry.getPath());
}
}

View File

@@ -1,223 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm.ibatis;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.alfresco.repo.avm.AVMDAOs;
import org.alfresco.repo.avm.AVMNode;
import org.alfresco.repo.avm.AVMStore;
import org.alfresco.repo.avm.DirectoryNode;
import org.alfresco.repo.avm.VersionRoot;
import org.alfresco.repo.avm.VersionRootDAO;
import org.alfresco.repo.avm.VersionRootImpl;
import org.alfresco.repo.domain.avm.AVMVersionRootEntity;
/**
* iBATIS DAO wrapper for VersionRoot
*
* @author janv
*/
class VersionRootDAOIbatis implements VersionRootDAO
{
/* (non-Javadoc)
* @see org.alfresco.repo.avm.VersionRootDAO#save(org.alfresco.repo.avm.VersionRoot)
*/
public void save(VersionRoot vr)
{
AVMVersionRootEntity vrEntity = AVMDAOs.Instance().newAVMVersionRootDAO.createVersionRoot(
vr.getAvmStore().getId(),
vr.getRoot().getId(),
vr.getVersionID(),
vr.getCreator(),
vr.getTag(),
vr.getDescription());
((VersionRootImpl)vr).setId(vrEntity.getId());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.VersionRootDAO#update(org.alfresco.repo.avm.VersionRoot)
*/
public void update(VersionRoot vr)
{
// note: tag and description only
AVMDAOs.Instance().newAVMVersionRootDAO.updateVersionRoot(convertVersionRootToVersionRootEntity(vr));
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.VersionRootDAO#delete(org.alfresco.repo.avm.VersionRoot)
*/
public void delete(VersionRoot vr)
{
AVMDAOs.Instance().newAVMVersionRootDAO.deleteVersionRoot(vr.getId());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.VersionRootDAO#getAllInAVMStore(org.alfresco.repo.avm.AVMStore)
*/
public List<VersionRoot> getAllInAVMStore(AVMStore store)
{
List<AVMVersionRootEntity> vrEntities = AVMDAOs.Instance().newAVMVersionRootDAO.getAllInStore(store.getId());
List<VersionRoot> vrs = new ArrayList<VersionRoot>(vrEntities.size());
for (AVMVersionRootEntity vrEntity : vrEntities)
{
vrs.add(convertVersionRootEntityToVersionRoot(vrEntity));
}
return vrs;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.VersionRootDAO#getByDates(org.alfresco.repo.avm.AVMStore, java.util.Date, java.util.Date)
*/
public List<VersionRoot> getByDates(AVMStore store, Date from, Date to)
{
List<AVMVersionRootEntity> vrEntities = AVMDAOs.Instance().newAVMVersionRootDAO.getByDates(store.getId(), from, to);
List<VersionRoot> vrs = new ArrayList<VersionRoot>(vrEntities.size());
for (AVMVersionRootEntity vrEntity : vrEntities)
{
vrs.add(convertVersionRootEntityToVersionRoot(vrEntity));
}
return vrs;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.VersionRootDAO#getByVersionID(org.alfresco.repo.avm.AVMStore, int)
*/
public synchronized VersionRoot getByVersionID(AVMStore store, int id)
{
AVMVersionRootEntity vrEntity = AVMDAOs.Instance().newAVMVersionRootDAO.getByVersionID(store.getId(), id);
return convertVersionRootEntityToVersionRoot(vrEntity);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.VersionRootDAO#getByRoot(org.alfresco.repo.avm.AVMNode)
*/
public VersionRoot getByRoot(AVMNode root)
{
AVMVersionRootEntity vrEntity = AVMDAOs.Instance().newAVMVersionRootDAO.getByRoot(root.getId());
return convertVersionRootEntityToVersionRoot(vrEntity);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.VersionRootDAO#getMaxVersion(org.alfresco.repo.avm.AVMStore)
*/
public VersionRoot getMaxVersion(AVMStore rep)
{
AVMVersionRootEntity vrEntity = AVMDAOs.Instance().newAVMVersionRootDAO.getMaxVersion(rep.getId());
return convertVersionRootEntityToVersionRoot(vrEntity);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.VersionRootDAO#getMaxVersionID(org.alfresco.repo.avm.AVMStore)
*/
public Integer getMaxVersionID(AVMStore store)
{
Long maxVersionId = AVMDAOs.Instance().newAVMVersionRootDAO.getMaxVersionID(store.getId());
if (maxVersionId == null)
{
return null;
}
return new Integer(maxVersionId.intValue());
}
public List<VersionRoot> getByVersionsTo(AVMStore store, int version)
{
List<AVMVersionRootEntity> vrEntities = AVMDAOs.Instance().newAVMVersionRootDAO.getByVersionsTo(store.getId(), version);
List<VersionRoot> vrs = new ArrayList<VersionRoot>(vrEntities.size());
for (AVMVersionRootEntity vrEntity : vrEntities)
{
vrs.add(convertVersionRootEntityToVersionRoot(vrEntity));
}
return vrs;
}
public List<VersionRoot> getByVersionsFrom(AVMStore store, int version)
{
List<AVMVersionRootEntity> vrEntities = AVMDAOs.Instance().newAVMVersionRootDAO.getByVersionsFrom(store.getId(), version);
List<VersionRoot> vrs = new ArrayList<VersionRoot>(vrEntities.size());
for (AVMVersionRootEntity vrEntity : vrEntities)
{
vrs.add(convertVersionRootEntityToVersionRoot(vrEntity));
}
return vrs;
}
public List<VersionRoot> getByVersionsBetween(AVMStore store, int startVersion, int endVersion)
{
List<AVMVersionRootEntity> vrEntities = AVMDAOs.Instance().newAVMVersionRootDAO.getByVersionsBetween(store.getId(), startVersion, endVersion);
List<VersionRoot> vrs = new ArrayList<VersionRoot>(vrEntities.size());
for (AVMVersionRootEntity vrEntity : vrEntities)
{
vrs.add(convertVersionRootEntityToVersionRoot(vrEntity));
}
return vrs;
}
private AVMVersionRootEntity convertVersionRootToVersionRootEntity(VersionRoot vr)
{
if (vr == null)
{
return null;
}
AVMVersionRootEntity vrEntity = new AVMVersionRootEntity();
vrEntity.setCreatedDate(vr.getCreateDate());
vrEntity.setCreator(vr.getCreator());
vrEntity.setDescription(vr.getDescription());
vrEntity.setId(vr.getId());
vrEntity.setRootNodeId(vr.getRoot().getId());
vrEntity.setStoreId(vr.getAvmStore().getId());
vrEntity.setTag(vr.getTag());
vrEntity.setVersion(vr.getVersionID());
return vrEntity;
}
private VersionRoot convertVersionRootEntityToVersionRoot(AVMVersionRootEntity vrEntity)
{
if (vrEntity == null)
{
return null;
}
AVMStore store = AVMDAOs.Instance().fAVMStoreDAO.getByID(vrEntity.getStoreId());
AVMNode rootNode = AVMDAOs.Instance().fAVMNodeDAO.getByID(vrEntity.getRootNodeId());
VersionRootImpl vr = new VersionRootImpl(
store,
(DirectoryNode)rootNode,
vrEntity.getVersion().intValue(),
vrEntity.getCreatedDate(),
vrEntity.getCreator(),
vrEntity.getTag(),
vrEntity.getDescription());
vr.setId(vrEntity.getId());
return vr;
}
}

View File

@@ -1,173 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm.util;
import org.alfresco.repo.avm.LookupCache;
import org.alfresco.repo.content.ContentStore;
import org.alfresco.repo.security.authentication.AuthenticationContext;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.MimetypeService;
import org.alfresco.service.cmr.security.AuthorityService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* Simple access to Raw versions of service singletons.
* @author britt
*/
public class RawServices implements ApplicationContextAware
{
/**
* The instance of RawServices
*/
private static RawServices fgInstance;
/**
* The Application Context.
*/
private ApplicationContext fContext;
/**
* The AuthenticationContext.
*/
private AuthenticationContext fAuthenticationContext;
/**
* The Content Service.
*/
private ContentService fContentService;
/**
* The Mimetype Service.
*/
private MimetypeService fMimetypeService;
/**
* The Dictionary Service.
*/
private DictionaryService fDictionaryService;
/**
* The Content Store.
*/
private ContentStore fContentStore;
/**
* The LookupCache.
*/
private LookupCache fLookupCache;
/**
* The Authority Service.
*/
private AuthorityService fAuthorityService;
/**
* Default constructor.
*/
public RawServices()
{
fgInstance = this;
}
public static RawServices Instance()
{
return fgInstance;
}
public void setApplicationContext(ApplicationContext applicationContext)
{
fContext = applicationContext;
}
public AuthenticationContext getAuthenticationContext()
{
if (fAuthenticationContext == null)
{
fAuthenticationContext =
(AuthenticationContext)fContext.getBean("authenticationContext");
}
return fAuthenticationContext;
}
public ContentService getContentService()
{
if (fContentService == null)
{
fContentService =
(ContentService)fContext.getBean("contentService");
}
return fContentService;
}
public MimetypeService getMimetypeService()
{
if (fMimetypeService == null)
{
fMimetypeService =
(MimetypeService)fContext.getBean("mimetypeService");
}
return fMimetypeService;
}
public DictionaryService getDictionaryService()
{
if (fDictionaryService == null)
{
fDictionaryService =
(DictionaryService)fContext.getBean("dictionaryService");
}
return fDictionaryService;
}
public ContentStore getContentStore()
{
if (fContentStore == null)
{
fContentStore =
(ContentStore)fContext.getBean("fileContentStore");
}
return fContentStore;
}
public LookupCache getLookupCache()
{
if (fLookupCache == null)
{
fLookupCache = (LookupCache)fContext.getBean("lookupCache");
}
return fLookupCache;
}
public AuthorityService getAuthorityService()
{
if (fAuthorityService == null)
{
// TODO change this back to the unwrapped bean before production.
fAuthorityService = (AuthorityService)fContext.getBean("AuthorityService");
}
return fAuthorityService;
}
public ApplicationContext getContext()
{
return fContext;
}
}

View File

@@ -1,49 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm.wf;
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
import org.springframework.beans.factory.BeanFactory;
/**
* No-op stub for the no longer used AVMSubmittedApsect.
*/
public class AVMClearSubmittedHandler extends JBPMSpringActionHandler
{
private static final long serialVersionUID = 4113360751217684995L;
/**
* Initialize service references.
* @param factory The BeanFactory to get references from.
*/
@Override
protected void initialiseHandler(BeanFactory factory)
{
}
/**
* Do the actual work.
* @param executionContext The context to get stuff from.
*/
public void execute(ExecutionContext executionContext) throws Exception
{
}
}

View File

@@ -1,198 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm.wf;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.config.JNDIConstants;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.actions.AVMDeployWebsiteAction;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.workflow.jbpm.JBPMNode;
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
import org.alfresco.service.cmr.avm.deploy.DeploymentService;
import org.alfresco.wcm.sandbox.SandboxConstants;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
import org.alfresco.util.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jbpm.graph.exe.ExecutionContext;
import org.springframework.beans.factory.BeanFactory;
/**
* Deploys the latest snapshot of the staging area the submission was for.
*
* @author Gavin Cornwell
*/
public class AVMDeployHandler extends JBPMSpringActionHandler
{
private DeploymentService deploymentService;
private AVMService avmService;
private ActionService actionService;
private NodeService unprotectedNodeService;
private PermissionService unprotectedPermissionService;
private static final String BEAN_DEPLOYMENT_SERVICE = "deploymentService";
private static final String BEAN_AVM_SERVICE = "AVMService";
private static final String BEAN_ACTION_SERVICE = "actionService";
private static final String BEAN_NODE_SERVICE = "nodeService";
private static final String BEAN_PERMISSION_SERVICE = "permissionService";
private static final long serialVersionUID = 5590265401983087178L;
private static final Log logger = LogFactory.getLog(AVMDeployHandler.class);
/**
* Initialize service references.
* @param factory The BeanFactory to get references from.
*/
@Override
protected void initialiseHandler(BeanFactory factory)
{
this.deploymentService = (DeploymentService)factory.getBean(BEAN_DEPLOYMENT_SERVICE);
this.avmService = (AVMService)factory.getBean(BEAN_AVM_SERVICE);
this.actionService = (ActionService)factory.getBean(BEAN_ACTION_SERVICE);
this.unprotectedNodeService = (NodeService)factory.getBean(BEAN_NODE_SERVICE);
this.unprotectedPermissionService = (PermissionService)factory.getBean(BEAN_PERMISSION_SERVICE);
}
/**
* Do the actual work.
* @param executionContext The context to get stuff from.
*/
public void execute(ExecutionContext executionContext) throws Exception
{
// determine if the auto deploy needs to be executed
Boolean autoDeploy = (Boolean)executionContext.getContextInstance().getVariable("wcmwf_autoDeploy");
if (logger.isDebugEnabled())
{
String label = (String)executionContext.getContextInstance().getVariable("wcmwf_label");
long workflowId = executionContext.getProcessInstance().getId();
logger.debug("autoDeploy state for submission (workflowid: jbpm$" + workflowId +
", label: " + label + ") is: " + autoDeploy);
}
if (autoDeploy != null && autoDeploy.booleanValue())
{
// get the web project node for the submission
JBPMNode webProjNode = (JBPMNode)executionContext.getContextInstance().getVariable("wcmwf_webproject");
NodeRef webProjectRef = webProjNode.getNodeRef();
// get the list of live servers for the project that have the auto deploy flag turned on
List<NodeRef> servers = deploymentService.findLiveDeploymentServers(webProjectRef);
// if there are servers do the deploy
if (servers.size() > 0)
{
// Get the staging store name
NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef();
Pair<Integer, String> pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg);
String [] workflowStorePath = pkgPath.getSecond().split(":");
String workflowStoreName = workflowStorePath[0];
PropertyValue propVal = this.avmService.getStoreProperty(workflowStoreName,
SandboxConstants.PROP_WEBSITE_NAME);
String store = propVal.getStringValue();
if (logger.isDebugEnabled())
logger.debug("Attempting auto deploy to store: " + store);
// retrieve the latest snapshot number for the store
int snapshotVersionToDeploy = this.avmService.getLatestSnapshotID(store);
// work out the path of the store that needs deploying
String pathToDeploy = store + ":/" + JNDIConstants.DIR_DEFAULT_WWW +
'/' + JNDIConstants.DIR_DEFAULT_APPBASE;
NodeRef websiteRef = AVMNodeConverter.ToNodeRef(snapshotVersionToDeploy, pathToDeploy);
// create a deploymentattempt node to represent this deployment
String attemptId = GUID.generate();
Map<QName, Serializable> props = new HashMap<QName, Serializable>(8, 1.0f);
props.put(WCMAppModel.PROP_DEPLOYATTEMPTID, attemptId);
props.put(WCMAppModel.PROP_DEPLOYATTEMPTTYPE, WCMAppModel.CONSTRAINT_LIVESERVER);
props.put(WCMAppModel.PROP_DEPLOYATTEMPTSTORE, store);
props.put(WCMAppModel.PROP_DEPLOYATTEMPTVERSION, snapshotVersionToDeploy);
props.put(WCMAppModel.PROP_DEPLOYATTEMPTTIME, new Date());
NodeRef attempt = unprotectedNodeService.createNode(webProjectRef,
WCMAppModel.ASSOC_DEPLOYMENTATTEMPT, WCMAppModel.ASSOC_DEPLOYMENTATTEMPT,
WCMAppModel.TYPE_DEPLOYMENTATTEMPT, props).getChildRef();
// allow anyone to add child nodes to the deploymentattempt node
unprotectedPermissionService.setPermission(attempt, PermissionService.ALL_AUTHORITIES,
PermissionService.ADD_CHILDREN, true);
// iterate round each server and fire off a deplyoment action
List<String> selectedDeployToNames = new ArrayList<String>();
for (NodeRef serverRef: servers)
{
if (unprotectedNodeService.exists(serverRef))
{
// get all properties of the target server
Map<QName, Serializable> serverProps = unprotectedNodeService.getProperties(serverRef);
String serverUri = AVMDeployWebsiteAction.calculateServerUri(serverProps);
String serverName = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERNAME);
if (serverName == null || serverName.length() == 0)
{
serverName = serverUri;
}
// remember the servers deployed to
selectedDeployToNames.add(serverName);
if (logger.isDebugEnabled())
logger.debug("Auto deploying '" + websiteRef.toString() + "' to server: " + serverName);
// create and execute the action asynchronously
Map<String, Serializable> args = new HashMap<String, Serializable>(1, 1.0f);
args.put(AVMDeployWebsiteAction.PARAM_WEBPROJECT, webProjectRef);
args.put(AVMDeployWebsiteAction.PARAM_SERVER, serverRef);
args.put(AVMDeployWebsiteAction.PARAM_ATTEMPT, attempt);
Action action = this.actionService.createAction(AVMDeployWebsiteAction.NAME, args);
this.actionService.executeAction(action, websiteRef, false, true);
}
}
// now we know the list of selected servers set the property on the attempt node
unprotectedNodeService.setProperty(attempt, WCMAppModel.PROP_DEPLOYATTEMPTSERVERS,
(Serializable)selectedDeployToNames);
// set the deploymentattempid property on the store this deployment was for
this.avmService.deleteStoreProperty(store, SandboxConstants.PROP_LAST_DEPLOYMENT_ID);
this.avmService.setStoreProperty(store, SandboxConstants.PROP_LAST_DEPLOYMENT_ID,
new PropertyValue(DataTypeDefinition.TEXT, attemptId));
}
}
}
}

View File

@@ -1,141 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm.wf;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.workflow.jbpm.JBPMNode;
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.util.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jbpm.graph.exe.ExecutionContext;
import org.springframework.beans.factory.BeanFactory;
/**
* Releases the test deploy server used by the workflow (if any).
*
* @author Gavin Cornwell
*/
public class AVMReleaseTestServerHandler extends JBPMSpringActionHandler
{
private SearchService searchService;
private NodeService unprotectedNodeService;
private static final String BEAN_NODE_SERVICE = "nodeService";
private static final String BEAN_SEARCH_SERVICE = "searchService";
private static final long serialVersionUID = -202652488887586866L;
private static final Log logger = LogFactory.getLog(AVMReleaseTestServerHandler.class);
/**
* Initialize service references.
* @param factory The BeanFactory to get references from.
*/
@Override
protected void initialiseHandler(BeanFactory factory)
{
this.searchService = (SearchService)factory.getBean(BEAN_SEARCH_SERVICE);
this.unprotectedNodeService = (NodeService)factory.getBean(BEAN_NODE_SERVICE);
}
/**
* Do the actual work.
* @param executionContext The context to get stuff from.
*/
public void execute(ExecutionContext executionContext) throws Exception
{
// get the store name
NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef();
Pair<Integer, String> pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg);
String [] workflowStorePath = pkgPath.getSecond().split(":");
String workflowStoreName = workflowStorePath[0];
// get the web project node for the submission
JBPMNode webProjNode = (JBPMNode)executionContext.getContextInstance().getVariable("wcmwf_webproject");
NodeRef webProjectRef = webProjNode.getNodeRef();
if (logger.isDebugEnabled())
logger.debug("Looking for test server to release for store: " + workflowStoreName);
// query for the allocated test server (if one)
NodeRef testServer = findAllocatedServer(webProjectRef, workflowStoreName);
if (testServer != null)
{
// reset the allocatedto property on the test server node
this.unprotectedNodeService.setProperty(testServer, WCMAppModel.PROP_DEPLOYSERVERALLOCATEDTO, null);
if (logger.isDebugEnabled())
logger.debug("Released test server '" + testServer + "' from store: " + workflowStoreName);
}
else if (logger.isDebugEnabled())
{
logger.debug("Store '" + workflowStoreName + "' didn't have an allocated test server to release");
}
}
private NodeRef findAllocatedServer(NodeRef webProjectRef, String store)
{
StringBuilder query = new StringBuilder("@");
query.append(NamespaceService.WCMAPP_MODEL_PREFIX);
query.append("\\:");
query.append(WCMAppModel.PROP_DEPLOYSERVERALLOCATEDTO.getLocalName());
query.append(":\"");
query.append(store);
query.append("\"");
ResultSet results = null;
NodeRef testServer = null;
try
{
// execute the query
results = this.searchService.query(webProjectRef.getStoreRef(),
SearchService.LANGUAGE_LUCENE, query.toString());
if (results.length() == 1)
{
testServer = results.getNodeRef(0);
}
else if (results.length() > 1)
{
// get the first one and warn that we found many!
testServer = results.getNodeRef(0);
if (logger.isWarnEnabled())
logger.warn("More than one allocated test server for store '" +
store + "' was found, should only be one, first one found returned!");
}
}
finally
{
if (results != null)
{
results.close();
}
}
return testServer;
}
}

View File

@@ -1,102 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm.wf;
import org.alfresco.config.JNDIConstants;
import org.alfresco.mbeans.VirtServerRegistry;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.util.RawServices;
import org.alfresco.repo.workflow.jbpm.JBPMNode;
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.Pair;
import org.alfresco.wcm.util.WCMUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jbpm.graph.exe.ExecutionContext;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
/**
* Remove all webapps in a sandbox
*
* @author Jon Cox
*/
public class AVMRemoveAllSrcWebappsHandler extends JBPMSpringActionHandler
{
static final long serialVersionUID = 3004374776252613278L;
private static Log logger = LogFactory.getLog(AVMRemoveAllSrcWebappsHandler.class);
/**
* Initialize service references.
* @param factory The BeanFactory to get references from.
*/
@Override
protected void initialiseHandler(BeanFactory factory)
{
}
/**
* Do the actual work.
* @param executionContext The context to get stuff from.
*/
public void execute(ExecutionContext executionContext) throws Exception
{
String workflowName = executionContext.getProcessDefinition().getName();
// optimization: direct submits no longer virtualize the workflow sandbox
boolean isSubmitDirectWorkflowSandbox = ((workflowName != null) && (workflowName.equals(WCMUtil.WORKFLOW_SUBMITDIRECT_NAME)));
if (logger.isDebugEnabled())
{
logger.debug("AVMRemoveAllSrcWebappsHandler.execute: "+workflowName);
}
if (! isSubmitDirectWorkflowSandbox)
{
// retrieve submitted package
NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().
getVariable("bpm_package")).getNodeRef();
Pair<Integer, String> pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg);
Integer version = pkgPath.getFirst();
String www_dir = pkgPath.getSecond();
String appbase_dir = www_dir + "/" + JNDIConstants.DIR_DEFAULT_APPBASE;
ApplicationContext springContext = RawServices.Instance().getContext();
VirtServerRegistry vServerRegistry = (VirtServerRegistry)
springContext.getBean("VirtServerRegistry");
if (logger.isDebugEnabled())
{
logger.debug("Sending JMX message to shut down workflow webapps: ["+version+", "+appbase_dir+"]");
}
vServerRegistry.removeAllWebapps( version, appbase_dir, true );
if (logger.isDebugEnabled())
{
logger.debug("Sent JMX message to shut down workflow webapps: ["+version+", "+appbase_dir+"]");
}
}
}
}

View File

@@ -1,85 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm.wf;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.workflow.jbpm.JBPMNode;
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.Pair;
import org.alfresco.wcm.sandbox.SandboxFactory;
import org.alfresco.wcm.util.WCMUtil;
import org.jbpm.graph.exe.ExecutionContext;
import org.springframework.beans.factory.BeanFactory;
/**
* Remove WF sandbox
*
* @author brittp
*/
public class AVMRemoveWFStoreHandler extends JBPMSpringActionHandler
{
private static final long serialVersionUID = 4113360751217684995L;
private SandboxFactory sandboxFactory;
/**
* Initialize service references.
* @param factory The BeanFactory to get references from.
*/
@Override
protected void initialiseHandler(BeanFactory factory)
{
sandboxFactory = (SandboxFactory)factory.getBean("sandboxFactory");
}
/**
* Do the actual work.
* @param executionContext The context to get stuff from.
*/
public void execute(ExecutionContext executionContext) throws Exception
{
// TODO: Allow submit parameters to be passed into this action handler
// rather than pulling directly from execution context
// retrieve submitted package
NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef();
Pair<Integer, String> pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg);
String workflowName = executionContext.getProcessDefinition().getName();
// optimization: direct submits no longer virtualize the workflow sandbox
final boolean isSubmitDirectWorkflowSandbox = ((workflowName != null) && (workflowName.equals(WCMUtil.WORKFLOW_SUBMITDIRECT_NAME)));
// Now delete the stores in the WCM workflow sandbox
final String avmPath = pkgPath.getSecond();
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
{
public Object doWork() throws Exception
{
sandboxFactory.deleteSandbox(WCMUtil.getSandboxStoreId(avmPath), isSubmitDirectWorkflowSandbox);
return null;
}
}, AuthenticationUtil.getSystemUserName());
}
}

View File

@@ -1,90 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm.wf;
import java.util.List;
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
import org.alfresco.wcm.sandbox.SandboxConstants;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jbpm.graph.exe.ExecutionContext;
import org.springframework.beans.factory.BeanFactory;
/**
* Performs a 'submit' operation: update from one sandbox layer to
* its corresponding staging sandbox.
* @author britt
*/
public class AVMSubmitHandler extends JBPMSpringActionHandler
{
private static final long serialVersionUID = 7561005904505181493L;
private static Log fgLogger = LogFactory.getLog(AVMSubmitHandler.class);
/**
* The AVMSyncService.
*/
private AVMSyncService fAVMSyncService;
/**
* The AVMService.
*/
private AVMService fAVMService;
/**
* Set any bean references necessary.
* @param factory The BeanFactory from which to get beans.
*/
@Override
protected void initialiseHandler(BeanFactory factory)
{
fAVMSyncService = (AVMSyncService)factory.getBean("AVMSyncService");
fAVMService = (AVMService)factory.getBean("AVMService");
}
/**
* Do the actual submit work.
* @param executionContext The jBPM context.
*/
public void execute(ExecutionContext executionContext) throws Exception
{
String avmSource = (String)executionContext.getContextInstance().getVariable("sourcePath");
String [] storePath = avmSource.split(":");
if (storePath.length != 2)
{
fgLogger.error("Malformed path: " + avmSource);
return;
}
String webSiteName =
fAVMService.getStoreProperty(storePath[0], SandboxConstants.PROP_WEBSITE_NAME).
getStringValue();
String avmDest = webSiteName + ":" + storePath[1]; // note: it is implied that the website name is the same as staging name
List<AVMDifference> diffs =
fAVMSyncService.compare(-1, avmSource, -1, avmDest, null);
// TODO fix update comments if needed.
// Ignore conflicts and older nodes for now.
fAVMSyncService.update(diffs, null, true, true, false, false, null, null);
// Now flatten out the source.
fAVMSyncService.flatten(avmSource, avmDest);
}
}

View File

@@ -1,195 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.avm.wf;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.util.AVMUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.workflow.jbpm.JBPMNode;
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.Pair;
import org.alfresco.wcm.util.WCMUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jbpm.graph.exe.ExecutionContext;
import org.springframework.beans.factory.BeanFactory;
public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements Serializable
{
private static final long serialVersionUID = 4113360751217684995L;
private static final Log logger = LogFactory.getLog(AVMSubmitPackageHandler.class);
/** The AVMService instance. */
private AVMService fAVMService;
/** The AVMSyncService instance. */
private AVMSyncService fAVMSyncService;
/** The AVMLockingService instance. */
private AVMLockingService fAVMLockingService;
/**
* The AVMSubmitTransactionListener instance (for JMX notification of virtualization server after commit/rollback).
*/
private AVMSubmitTransactionListener fAVMSubmitTransactionListener;
/**
* Initialize service references.
*
* @param factory
* The BeanFactory to get references from.
*/
@Override
protected void initialiseHandler(final BeanFactory factory)
{
fAVMService = (AVMService) factory.getBean(ServiceRegistry.AVM_SERVICE.getLocalName());
fAVMSyncService = (AVMSyncService) factory.getBean(ServiceRegistry.AVM_SYNC_SERVICE.getLocalName());
fAVMLockingService = (AVMLockingService) factory.getBean(ServiceRegistry.AVM_LOCKING_SERVICE.getLocalName());
fAVMSubmitTransactionListener = (AVMSubmitTransactionListener) factory.getBean("AVMSubmitTransactionListener");
AlfrescoTransactionSupport.bindListener(fAVMSubmitTransactionListener);
}
/**
* Do the actual work.
*
* @param executionContext
* The context to get stuff from.
*/
public void execute(final ExecutionContext executionContext) throws Exception
{
// TODO: Allow submit parameters to be passed into this action handler
// rather than pulling directly from execution context
final NodeRef pkg = ((JBPMNode) executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef();
final Pair<Integer, String> pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg);
final AVMNodeDescriptor pkgDesc = fAVMService.lookup(pkgPath.getFirst(), pkgPath.getSecond());
if (pkgDesc == null)
{
logger.warn("Submit skipped since workflow package does not exist: "+pkgPath);
}
else
{
final String from = (String) executionContext.getContextInstance().getVariable("wcmwf_fromPath");
final String targetPath = pkgDesc.getIndirection();
if (logger.isDebugEnabled())
{
logger.debug("handling submit of " + pkgPath.getSecond() + " from " + from + " to " + targetPath);
}
// submit the package changes
final String description = (String) executionContext.getContextInstance().getVariable("bpm_workflowDescription");
final String tag = (String) executionContext.getContextInstance().getVariable("wcmwf_label");
final String webProject = WCMUtil.getWebProject(fAVMService, AVMUtil.getStoreName(targetPath));
final List<AVMDifference> stagingDiffs = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, targetPath, null);
// Allow AVMSubmitTransactionListener to inspect the staging diffs
// so it can notify the virtualization server via JMX if when this
// submit succeeds or fails. This allows virtual webapps devoted
// to the workarea to be destroyed, and staging to be updated in
// the event that some of the files alter the behavior of the
// webapp itself (e.g.: WEB-INF/web.xml, WEB-INF/lib/*.jar), etc.
AlfrescoTransactionSupport.bindResource("staging_diffs", stagingDiffs);
// Workflow does this as system as the staging area has restricted access and reviewers
// may not have permission to flatten the store the workflow was submitted from
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
{
public Object doWork() throws Exception
{
fAVMSyncService.update(stagingDiffs, null, false, false, true, true, tag, description);
fAVMSyncService.flatten(pkgPath.getSecond(), targetPath);
if (webProject != null)
{
for (final AVMDifference diff : stagingDiffs)
{
recursivelyRemoveLocks(webProject, -1, diff.getSourcePath());
}
}
else
{
logger.warn("No webproject (hence no locks removed) for submit of " + pkgPath.getSecond() + " from " + from + " to " + targetPath);
}
// flatten source folder where changes were submitted from
if (from != null && from.length() > 0)
{
// first, submit changes back to sandbox forcing addition of edits in workflow (and submission
// flag removal). second, flatten sandbox, removing modified items that have been submitted
// TODO: Without locking on the sandbox, it's possible that a change to a "submitted" item
// may get lost when the item is finally approved
final List<AVMDifference> sandboxDiffs = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, from, null);
fAVMSyncService.update(sandboxDiffs, null, true, true, false, false, tag, description);
fAVMSyncService.flatten(from, targetPath);
}
return null;
}
}, AuthenticationUtil.getSystemUserName());
}
}
/**
* Recursively remove locks from a path. Walking child folders looking for files to remove locks from.
*/
private void recursivelyRemoveLocks(String wpStoreId, int version, String wfPath)
{
AVMNodeDescriptor desc = fAVMService.lookup(version, wfPath, true);
if (desc.isFile() || desc.isDeletedFile())
{
String relativePath = WCMUtil.getStoreRelativePath(wfPath);
if (logger.isDebugEnabled())
{
logger.debug("removing file lock on " + relativePath + " (store id: "+wpStoreId+")");
}
fAVMLockingService.removeLock(wpStoreId, relativePath);
}
else
{
if (desc.isDeletedDirectory() == false)
{
Map<String, AVMNodeDescriptor> list = fAVMService.getDirectoryListing(desc, true);
for (AVMNodeDescriptor child : list.values())
{
recursivelyRemoveLocks(wpStoreId, version, child.getPath());
}
}
}
}
}

View File

@@ -1,147 +0,0 @@
/*-----------------------------------------------------------------------------
* Copyright 2007-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.*
*
* Author Jon Cox <jcox@alfresco.com>
* File AVMSubmitTransactionListener.java
*----------------------------------------------------------------------------*/
package org.alfresco.repo.avm.wf;
import java.util.List;
import org.alfresco.mbeans.VirtServerRegistry;
import org.alfresco.repo.avm.util.RawServices;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.TransactionListenerAdapter;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.util.VirtServerUtils;
import org.springframework.context.ApplicationContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Gets callbacks at critical moments within a transaction
* (commit, rollback, etc.) to perform JMX update notifications
* to the virtualization server.
*/
public class AVMSubmitTransactionListener extends TransactionListenerAdapter
{
private static Log log =
LogFactory.getLog(AVMSubmitTransactionListener.class);
public AVMSubmitTransactionListener() { }
/**
* Notify virtualization server that webapps in workflow sandbox
* are not longer needed, and possibly trigger a notification
* instrucing the virtualization server to reload staging
* and every virtual webapp that depends on it.
*/
@Override
public void afterCommit()
{
List<AVMDifference> stagingDiffs =
(List<AVMDifference>)
AlfrescoTransactionSupport.getResource("staging_diffs");
if ( stagingDiffs == null) { return; } // TODO: log this?
AVMDifference requiresUpdate = null;
for (AVMDifference diff : stagingDiffs)
{
// Example values:
//
// diff.getSourceVersion() == -1; diff.getSourcePath() ==
// mysite--workflow-21edf548-b17e-11db-bd90-35dd2ee4a5c6:/www/avm_webapps/ROOT/x.txt
//
// diff.getDestinationVersion() == -1; diff.getDestinationPath() ==
// mysite:/www/avm_webapps/ROOT/x.txt
if ( requiresUpdate == null )
{
if ( VirtServerUtils.requiresUpdateNotification( diff.getDestinationPath() ) )
{
requiresUpdate = diff;
}
}
}
ApplicationContext springContext = RawServices.Instance().getContext();
VirtServerRegistry vServerRegistry = (VirtServerRegistry)
springContext.getBean("VirtServerRegistry");
// TODO: In the future, we might want to allow a single submit to
// update multiple staging areas & versions. If so,
// the logic above will have to look for each unique
// version/webapp tuple, rather than assume everything
// is going into the same version and into the same
// store/webapp.
// Only update staging if necessary
if ( requiresUpdate != null )
{
vServerRegistry.updateAllWebapps( requiresUpdate.getDestinationVersion(),
requiresUpdate.getDestinationPath(),
true
);
if (log.isDebugEnabled())
log.debug("JMX update to virt server called after commit." +
" Version: " + requiresUpdate.getDestinationVersion() +
" Path: " + requiresUpdate.getDestinationPath());
}
// Remove virtual webapps from workflow sandbox prior to
// AVMRemoveWFStoreHandler in the "process-end" clause.
// This way, even if the workflow is aborted, the JMX message
// to the virt server is still sent. Therefore, no longer
// doing this here:
//
// if ( ! stagingDiffs.isEmpty() )
// {
// // All the files are from the same workflow sandbox;
// // so to remove all the webapps, you just need to
// // look at the 1st difference
//
// AVMDifference d = stagingDiffs.iterator().next();
// vServerRegistry.removeAllWebapps( d.getSourceVersion(),
// d.getSourcePath(), true );
// }
AlfrescoTransactionSupport.unbindResource("staging_diffs");
if (log.isDebugEnabled())
log.debug("staging_diff resource unbound after commit");
}
/**
* Handle failed transaction.
*/
@Override
public void afterRollback()
{
AlfrescoTransactionSupport.unbindResource("staging_diffs");
if (log.isDebugEnabled())
log.debug("staging_diff resource unbound after rollback");
}
}

View File

@@ -223,7 +223,10 @@ public class ContentStoreCleaner
PropertyCheck.mandatory(this, "contentDataDAO", contentDataDAO);
PropertyCheck.mandatory(this, "dictionaryService", dictionaryService);
PropertyCheck.mandatory(this, "contentService", contentService);
PropertyCheck.mandatory(this, "avmNodeDAO", avmNodeDAO);
// Sparta: remove WCM/AVM
//PropertyCheck.mandatory(this, "avmNodeDAO", avmNodeDAO);
PropertyCheck.mandatory(this, "transactionService", transactionService);
PropertyCheck.mandatory(this, "eagerContentStoreCleaner", eagerContentStoreCleaner);

View File

@@ -26,7 +26,6 @@ import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.domain.node.NodeIdAndAclId;
import org.alfresco.repo.domain.permissions.AVMAccessControlListDAO.CounterSet;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.security.permissions.ACLType;
import org.alfresco.repo.security.permissions.AccessControlList;
@@ -479,4 +478,76 @@ public class ADMAccessControlListDAO implements AccessControlListDAO
}
}
}
/**
*
* Counter for each type of ACL change
* @author andyh
*
*/
public static class CounterSet extends HashMap<ACLType, Counter>
{
/**
*
*/
private static final long serialVersionUID = -3682278258679211481L;
CounterSet()
{
super();
this.put(ACLType.DEFINING, new Counter());
this.put(ACLType.FIXED, new Counter());
this.put(ACLType.GLOBAL, new Counter());
this.put(ACLType.LAYERED, new Counter());
this.put(ACLType.OLD, new Counter());
this.put(ACLType.SHARED, new Counter());
}
void add(ACLType type, Counter c)
{
Counter counter = get(type);
counter.add(c.getCounter());
}
void increment(ACLType type)
{
Counter counter = get(type);
counter.increment();
}
void add(CounterSet other)
{
add(ACLType.DEFINING, other.get(ACLType.DEFINING));
add(ACLType.FIXED, other.get(ACLType.FIXED));
add(ACLType.GLOBAL, other.get(ACLType.GLOBAL));
add(ACLType.LAYERED, other.get(ACLType.LAYERED));
add(ACLType.OLD, other.get(ACLType.OLD));
add(ACLType.SHARED, other.get(ACLType.SHARED));
}
}
/**
* Simple counter
* @author andyh
*
*/
public static class Counter
{
int counter;
void increment()
{
counter++;
}
int getCounter()
{
return counter;
}
void add(int i)
{
counter += i;
}
}
}

View File

@@ -20,6 +20,7 @@ package org.alfresco.repo.domain.permissions;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -263,7 +264,9 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO
public List<Long> getAVMNodesByAcl(long aclEntityId, int maxResults)
{
return getAVMNodeEntityIdsByAcl(aclEntityId, maxResults);
// Sparta: remove WCM/AVM
//return getAVMNodeEntityIdsByAcl(aclEntityId, maxResults);
return Collections.emptyList();
}
public void updateAcl(AclUpdateEntity entity)

View File

@@ -1,351 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.node.index;
import java.util.LinkedHashMap;
import java.util.List;
import org.alfresco.repo.node.index.FullIndexRecoveryComponent.RecoveryMode;
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
import org.alfresco.repo.search.IndexMode;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Check and recover the indexes for AVM stores
*
* @author andyh
*/
public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
{
private static Log logger = LogFactory.getLog(AVMFullIndexRecoveryComponent.class);
private RecoveryMode recoveryMode;
private boolean lockServer;
private AVMService avmService;
private AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor;
/**
* Set the type of recovery to perform. Default is {@link RecoveryMode#VALIDATE to validate} the indexes only.
*
* @param recoveryMode
* one of the {@link RecoveryMode } values
*/
public void setRecoveryMode(String recoveryMode)
{
this.recoveryMode = RecoveryMode.valueOf(recoveryMode);
}
/**
* Set this on to put the server into READ-ONLY mode for the duration of the index recovery. The default is
* <tt>true</tt>, i.e. the server will be locked against further updates.
*
* @param lockServer
* true to force the server to be read-only
*/
public void setLockServer(boolean lockServer)
{
this.lockServer = lockServer;
}
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
public void setAvmSnapShotTriggeredIndexingMethodInterceptor(AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor)
{
this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor;
}
@Override
protected void reindexImpl()
{
processStores();
}
private void processStores()
{
List<AVMStoreDescriptor> stores = avmService.getStores();
LinkedHashMap<String, RecoveryMode> actions = new LinkedHashMap<String, RecoveryMode>();
if (stores.size() == 0)
{
return;
}
switch (recoveryMode)
{
case AUTO:
case VALIDATE:
int count = 0;
int tracker = -1;
if (logger.isDebugEnabled())
{
logger.debug("Checking indexes for AVM Stores: " + recoveryMode);
}
for (AVMStoreDescriptor store : stores)
{
if (isShuttingDown())
{
return;
}
actions.put(store.getName(), checkStore(store.getName()));
count++;
if (count * 10l / stores.size() > tracker)
{
tracker = (int) (count * 10l / stores.size());
if (logger.isDebugEnabled())
{
logger.debug(" Store check " + (tracker * 10) + "% complete");
}
}
}
if (logger.isDebugEnabled())
{
logger.debug("Finished checking indexes for AVM Stores");
}
break;
case FULL:
case NONE:
for (AVMStoreDescriptor store : stores)
{
if (isShuttingDown())
{
return;
}
actions.put(store.getName(), checkStore(store.getName()));
}
break;
default:
}
int full = 0;
int auto = 0;
int invalid = 0;
for (String store : actions.keySet())
{
RecoveryMode mode = actions.get(store);
switch (mode)
{
case AUTO:
auto++;
break;
case FULL:
full++;
break;
case VALIDATE:
invalid++;
break;
case NONE:
default:
}
}
if (recoveryMode != RecoveryMode.NONE)
{
if (logger.isDebugEnabled())
{
logger.debug("Invalid indexes: " + invalid);
logger.debug("Indexes for full rebuild: " + full);
logger.debug("Indexes for auto update: " + auto);
}
}
int count = 0;
int tracker = -1;
int total = full + auto;
if (total > 0)
{
logger.info("Rebuilding indexes for " + total + " AVM Stores");
for (String store : actions.keySet())
{
RecoveryMode mode = actions.get(store);
if (isShuttingDown())
{
return;
}
if ((mode == RecoveryMode.FULL) || (mode == RecoveryMode.AUTO))
{
processStore(store, mode);
count++;
}
if (count * 10l / total > tracker)
{
tracker = (int) (count * 10l / total);
logger.info(" Reindex " + (tracker * 10) + "% complete");
}
}
logger.info("Finished rebuilding indexes for AVM Stores");
}
}
private RecoveryMode checkStore(String store)
{
if (logger.isDebugEnabled())
{
logger.debug("Checking AVM store for index recovery: " + recoveryMode + " on store " + store);
}
// do we just ignore
if (recoveryMode == RecoveryMode.NONE)
{
return RecoveryMode.NONE;
}
// Nothing to do for unindexed stores
if (avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(store) == IndexMode.UNINDEXED)
{
return RecoveryMode.NONE;
}
if (recoveryMode == RecoveryMode.FULL) // no validate required
{
return RecoveryMode.FULL;
}
else
// validate first
{
if (!avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated(store))
{
logger.warn(" Index for avm store " + store + " is out of date");
return recoveryMode;
}
int lastActualSnapshotId = avmService.getLatestSnapshotID(store);
if (lastActualSnapshotId <= 0)
{
return RecoveryMode.NONE;
}
int lastIndexedSnapshotId = avmSnapShotTriggeredIndexingMethodInterceptor.getLastIndexedSnapshot(store);
if (lastActualSnapshotId != lastIndexedSnapshotId)
{
logger.warn(" Index for avm store " + store + " is out of date");
return recoveryMode;
}
else
{
return RecoveryMode.NONE;
}
}
}
private void processStore(String store, RecoveryMode mode)
{
QName vetoName = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "AVMFullIndexRecoveryComponent");
// put the server into read-only mode for the duration
try
{
if (lockServer)
{
// set the server into read-only mode
transactionService.setAllowWrite(false, vetoName);
}
recoverStore(store, mode);
}
finally
{
// remove veto
transactionService.setAllowWrite(true, vetoName);
}
}
private void recoverStore(final String store, final RecoveryMode mode)
{
IndexMode storeIndexMode = avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(store);
if (storeIndexMode != IndexMode.UNINDEXED)
{
if (mode == RecoveryMode.AUTO)
{
logger.info(" Auto recovering index for " + store);
}
else if (mode == RecoveryMode.FULL)
{
logger.info(" Rebuilding index for " + store);
// delete existing index
RetryingTransactionCallback<Void> deleteWork = new RetryingTransactionCallback<Void>()
{
public Void execute() throws Exception
{
avmSnapShotTriggeredIndexingMethodInterceptor.deleteIndex(store);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(deleteWork, true, true);
}
final int latest = avmService.getLatestSnapshotID(store);
if (latest <= 0)
{
if (!avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated(store))
{
avmSnapShotTriggeredIndexingMethodInterceptor.createIndex(store);
}
return;
}
final int latestIndexed = avmSnapShotTriggeredIndexingMethodInterceptor.getLastIndexedSnapshot(store);
RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
if (mode == RecoveryMode.AUTO)
{
logger.info(" Rebuilding index for snapshots " + latestIndexed +" to "+latest);
avmSnapShotTriggeredIndexingMethodInterceptor.indexSnapshot(store, latestIndexed, latest);
}
else
{
logger.info(" Rebuilding index for snapshots " + 0 +" to "+latest);
avmSnapShotTriggeredIndexingMethodInterceptor.indexSnapshot(store, 0, latest);
}
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true, true);
if (logger.isDebugEnabled())
{
logger.debug(" Index updated for " + store + "("+storeIndexMode.toString()+")");
}
}
else
{
if (logger.isDebugEnabled())
{
logger.debug(" Index skipped for " + store+ "("+storeIndexMode.toString()+")");
}
}
}
}

View File

@@ -1,137 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.node.index;
import java.util.List;
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
import org.alfresco.repo.search.IndexMode;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Track and update when snapshots are created and indexed in a cluster
*
* @author Andy Hind
* @since 2.1.0
*/
public class AVMRemoteSnapshotTracker extends AbstractReindexComponent
{
private static Log logger = LogFactory.getLog(AVMRemoteSnapshotTracker.class);
private AVMService avmService;
private AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor;
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
public void setAvmSnapShotTriggeredIndexingMethodInterceptor(AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor)
{
this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor;
}
@Override
protected void reindexImpl()
{
processStores();
}
/**
* Loop throught the avm stores and compare the latest snapshot to that in the index. Update the index if it has
* fallen behind.
*/
private void processStores()
{
List<AVMStoreDescriptor> stores = avmService.getStores();
if (stores.size() == 0)
{
return;
}
boolean upToDate;
do
{
upToDate = true;
for (AVMStoreDescriptor store : stores)
{
if (isShuttingDown())
{
break;
}
if (avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(store.getName()) != IndexMode.UNINDEXED)
{
int current = avmService.getLatestSnapshotID(store.getName());
int lastIndexed = avmSnapShotTriggeredIndexingMethodInterceptor.getLastIndexedSnapshot(store.getName());
if (lastIndexed < current)
{
if (logger.isDebugEnabled())
{
logger.debug("Reindexing snapshots for AVM store " + store.getName() + " from " + lastIndexed + " to " + current);
}
recoverSnapShot(store.getName(), lastIndexed, current);
upToDate = false;
}
}
}
if (upToDate)
{
if (logger.isDebugEnabled())
{
logger.debug("Reindex check complete for AVM stores");
}
}
}
while (!upToDate);
}
/**
* Do the index update in one lump (not individual snapshots)
*
* @param store
* @param lastIndexed
* @param current
*/
private void recoverSnapShot(final String store, final int lastIndexed, final int current)
{
RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
if (lastIndexed == -1)
{
avmSnapShotTriggeredIndexingMethodInterceptor.createIndex(store);
}
avmSnapShotTriggeredIndexingMethodInterceptor.indexSnapshot(store, lastIndexed, current);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true);
}
}

View File

@@ -1,159 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search;
import java.util.List;
import org.alfresco.repo.search.impl.lucene.AVMLuceneIndexer;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.namespace.QName;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
/**
* @author Andy
*
*/
public interface AVMSnapShotTriggeredIndexingMethodInterceptor extends MethodInterceptor
{
public final static QName PROP_SANDBOX_STAGING_MAIN = QName.createQName(null, ".sandbox.staging.main");
public final static QName PROP_SANDBOX_STAGING_PREVIEW = QName.createQName(null, ".sandbox.staging.preview");
public final static QName PROP_SANDBOX_AUTHOR_MAIN = QName.createQName(null, ".sandbox.author.main");
public final static QName PROP_SANDBOX_AUTHOR_PREVIEW = QName.createQName(null, ".sandbox.author.preview");
public final static QName PROP_SANDBOX_WORKFLOW_MAIN = QName.createQName(null, ".sandbox.workflow.main");
public final static QName PROP_SANDBOX_WORKFLOW_PREVIEW = QName.createQName(null, ".sandbox.workflow.preview");
public final static QName PROP_SANDBOX_AUTHOR_WORKFLOW_MAIN = QName.createQName(null, ".sandbox.author.workflow.main");
public final static QName PROP_SANDBOX_AUTHOR_WORKFLOW_PREVIEW = QName.createQName(null, ".sandbox.author.workflow.preview");
@SuppressWarnings("unchecked")
public abstract Object invoke(MethodInvocation mi) throws Throwable;
/**
* Set the AVM service
*
* @param avmService
*/
public abstract void setAvmService(AVMService avmService);
/**
* Set the AVM indexer and searcher
*
* @param indexerAndSearcher
*/
public abstract void setIndexerAndSearcher(IndexerAndSearcher indexerAndSearcher);
/**
* Enable or disable indexing
*
* @param enableIndexing
*/
public abstract void setEnableIndexing(boolean enableIndexing);
/**
* Set the index modes.... Strings of the form ... (ASYNCHRONOUS | SYNCHRONOUS | UNINDEXED):(NAME | TYPE):regexp
*
* @param definitions
*/
public abstract void setIndexingDefinitions(List<String> definitions);
/**
* Set the default index mode = used when there are no matches
*
* @param defaultMode
*/
public abstract void setDefaultMode(IndexMode defaultMode);
/**
* Is snapshot triggered indexing enabled
*
* @return true if indexing is enabled for AVM
*/
public abstract boolean isIndexingEnabled();
/**
* @param store
* @param before
* @param after
*/
public abstract void indexSnapshot(String store, int before, int after);
/**
* @param store
* @param after
*/
public abstract void indexSnapshot(String store, int after);
/**
* @param store
* @return - the last indexed snapshot
*/
public abstract int getLastIndexedSnapshot(String store);
/**
* Is the snapshot applied to the index? Is there an entry for any node that was added OR have all the nodes in the
* transaction been deleted as expected?
*
* @param store
* @param id
* @return - true if applied, false if not
*/
public abstract boolean isSnapshotIndexed(String store, int id);
/**
* Check if the index is up to date according to its index defintion and that all asynchronous work is done.
*
* @param store
* @return
*/
public abstract boolean isIndexUpToDateAndSearchable(String store);
/**
* Check if the index is up to date according to its index defintion i it does not check that all asynchronous work
* is done.
*
* @param store
* @return
*/
public abstract boolean isIndexUpToDate(String store);
/**
* Given an avm store name determine if it is indexed and if so how.
*
* @param store
* @return
*/
public abstract IndexMode getIndexMode(String store);
public abstract boolean hasIndexBeenCreated(String store);
public abstract void createIndex(String store);
public abstract AVMLuceneIndexer getIndexer(String store);
public abstract void deleteIndex(String store);
}

View File

@@ -1,600 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.management.subsystems.SwitchableApplicationContextFactory;
import org.alfresco.repo.search.impl.lucene.AVMLuceneIndexer;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.QName;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Method interceptor for atomic indexing of AVM entries The properties can defined how stores are indexed based on type
* (as set by Alfresco the Web site management UI) or based on the name of the store. Creates and deletes are indexed
* synchronously. Updates may be asynchronous, synchronous or ignored by the index.
*
* @author andyh
*/
public class AVMSnapShotTriggeredIndexingMethodInterceptorImpl implements AVMSnapShotTriggeredIndexingMethodInterceptor
{
private static Log logger = LogFactory.getLog(AVMSnapShotTriggeredIndexingMethodInterceptorImpl.class);
// Copy of store properties used to tag avm stores (a store propertry)
private AVMService avmService;
private IndexerAndSearcher indexerAndSearcher;
private boolean enableIndexing = true;
private IndexMode defaultMode = IndexMode.ASYNCHRONOUS;
private Map<String, IndexMode> modeCache = new HashMap<String, IndexMode>();
private List<IndexingDefinition> indexingDefinitions = new ArrayList<IndexingDefinition>();
private SwitchableApplicationContextFactory searchApplicationContextFactory;
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation)
*/
@Override
@SuppressWarnings("unchecked")
public Object invoke(MethodInvocation mi) throws Throwable
{
if (enableIndexing)
{
if (mi.getMethod().getName().equals("createSnapshot"))
{
// May cause any number of other stores to do snap shot under the covers via layering or do nothing
// So we have to watch what actually changes
Object returnValue = mi.proceed();
Map<String, Integer> snapShots = (Map<String, Integer>) returnValue;
// Index any stores that have moved on
for (String store : snapShots.keySet())
{
int after = snapShots.get(store).intValue();
indexSnapshot(store, after);
}
return returnValue;
}
else if (mi.getMethod().getName().equals("purgeStore"))
{
String store = (String) mi.getArguments()[0];
Object returnValue = mi.proceed();
if (getIndexMode(store) != IndexMode.UNINDEXED)
{
AVMLuceneIndexer avmIndexer = getIndexer(store);
if (avmIndexer != null)
{
if (logger.isDebugEnabled())
{
logger.debug("purgeStore " + store, new Exception("Stack Trace"));
}
avmIndexer.deleteIndex(store, IndexMode.SYNCHRONOUS);
}
}
return returnValue;
}
else if (mi.getMethod().getName().equals("createStore"))
{
String store = (String) mi.getArguments()[0];
Object returnValue = mi.proceed();
if (getIndexMode(store) != IndexMode.UNINDEXED)
{
createIndex(store);
}
return returnValue;
}
else if (mi.getMethod().getName().equals("renameStore"))
{
String from = (String) mi.getArguments()[0];
String to = (String) mi.getArguments()[1];
Object returnValue = mi.proceed();
int after = avmService.getLatestSnapshotID(to);
if (getIndexMode(from) != IndexMode.UNINDEXED)
{
AVMLuceneIndexer avmIndexer = getIndexer(from);
if (avmIndexer != null)
{
if (logger.isDebugEnabled())
{
logger.debug("renameStore deleteIndex " + from, new Exception("Stack Trace"));
}
avmIndexer.deleteIndex(from, IndexMode.SYNCHRONOUS);
}
}
if (getIndexMode(to) != IndexMode.UNINDEXED)
{
AVMLuceneIndexer avmIndexer = getIndexer(to);
if (avmIndexer != null)
{
if (logger.isDebugEnabled())
{
logger.debug("renameStore createIndex " + to + "(0, " + after + ")", new Exception("Stack Trace"));
}
avmIndexer.createIndex(to, IndexMode.SYNCHRONOUS);
avmIndexer.index(to, 0, after, getIndexMode(to));
}
}
return returnValue;
}
else
{
return mi.proceed();
}
}
else
{
return mi.proceed();
}
}
/**
* @param searchApplicationContextFactory the searchApplicationContextFactory to set
*/
public void setSearchApplicationContextFactory(SwitchableApplicationContextFactory searchApplicationContextFactory)
{
this.searchApplicationContextFactory = searchApplicationContextFactory;
}
/**
* @return the searchApplicationContextFactory
*/
public SwitchableApplicationContextFactory getSearchApplicationContextFactory()
{
return searchApplicationContextFactory;
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#setAvmService(org.alfresco.service.cmr.avm.AVMService)
*/
@Override
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#setIndexerAndSearcher(org.alfresco.repo.search.IndexerAndSearcher)
*/
@Override
public void setIndexerAndSearcher(IndexerAndSearcher indexerAndSearcher)
{
this.indexerAndSearcher = indexerAndSearcher;
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#setEnableIndexing(boolean)
*/
@Override
public void setEnableIndexing(boolean enableIndexing)
{
this.enableIndexing = enableIndexing;
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#setIndexingDefinitions(java.util.List)
*/
@Override
public void setIndexingDefinitions(List<String> definitions)
{
indexingDefinitions.clear();
for (String def : definitions)
{
IndexingDefinition id = new IndexingDefinition(def);
indexingDefinitions.add(id);
}
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#setDefaultMode(org.alfresco.repo.search.IndexMode)
*/
@Override
public void setDefaultMode(IndexMode defaultMode)
{
this.defaultMode = defaultMode;
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#isIndexingEnabled()
*/
@Override
public boolean isIndexingEnabled()
{
return enableIndexing;
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#indexSnapshot(java.lang.String, int, int)
*/
@Override
public void indexSnapshot(String store, int before, int after)
{
indexSnapshotImpl(store, before, after);
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#indexSnapshot(java.lang.String, int)
*/
@Override
public void indexSnapshot(String store, int after)
{
indexSnapshotImpl(store, -1, after);
}
private void indexSnapshotImpl(String store, int before, int after)
{
if (getIndexMode(store) != IndexMode.UNINDEXED)
{
AVMLuceneIndexer avmIndexer = getIndexer(store);
if (avmIndexer != null)
{
int last = getLastIndexedSnapshot(avmIndexer, store);
if ((last == -1) && (! hasIndexBeenCreated(store)))
{
createIndex(store);
// ALF-7845
last = getLastIndexedSnapshot(avmIndexer, store);
}
int from = before != -1 ? before : last;
if (from > after)
{
if (logger.isTraceEnabled())
{
logger.trace("skip indexSnapshotImpl " + store + " (" + (before == -1 ? "-1, " : "") + from +", " + after +")", new Exception("Stack Trace"));
}
}
else
{
if (logger.isDebugEnabled())
{
logger.debug("indexSnapshotImpl " + store + " (" + (before == -1 ? "-1, " : "") + from +", " + after +")", new Exception("Stack Trace"));
}
avmIndexer.index(store, from, after, getIndexMode(store));
}
}
}
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#getLastIndexedSnapshot(java.lang.String)
*/
@Override
public int getLastIndexedSnapshot(String store)
{
AVMLuceneIndexer avmIndexer = getIndexer(store);
if (avmIndexer != null)
{
return getLastIndexedSnapshot(avmIndexer, store);
}
return -1;
}
private int getLastIndexedSnapshot(AVMLuceneIndexer avmIndexer, String store)
{
return avmIndexer.getLastIndexedSnapshot(store);
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#isSnapshotIndexed(java.lang.String, int)
*/
@Override
public boolean isSnapshotIndexed(String store, int id)
{
AVMLuceneIndexer avmIndexer = getIndexer(store);
if (avmIndexer != null)
{
return avmIndexer.isSnapshotIndexed(store, id);
}
return false;
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#isIndexUpToDateAndSearchable(java.lang.String)
*/
@Override
public boolean isIndexUpToDateAndSearchable(String store)
{
switch (getIndexMode(store))
{
case UNINDEXED:
return false;
case SYNCHRONOUS:
case ASYNCHRONOUS:
int last = avmService.getLatestSnapshotID(store);
AVMLuceneIndexer avmIndexer = getIndexer(store);
if (avmIndexer != null)
{
avmIndexer.flushPending();
return avmIndexer.isSnapshotSearchable(store, last);
}
return false;
default:
return false;
}
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#isIndexUpToDate(java.lang.String)
*/
@Override
public boolean isIndexUpToDate(String store)
{
switch (getIndexMode(store))
{
case UNINDEXED:
return true;
case SYNCHRONOUS:
case ASYNCHRONOUS:
int last = avmService.getLatestSnapshotID(store);
AVMLuceneIndexer avmIndexer = getIndexer(store);
if (avmIndexer != null)
{
avmIndexer.flushPending();
return avmIndexer.isSnapshotIndexed(store, last);
}
return false;
default:
return false;
}
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#getIndexMode(java.lang.String)
*/
@Override
public synchronized IndexMode getIndexMode(String store)
{
IndexMode mode = modeCache.get(store);
if (mode == null)
{
for (IndexingDefinition def : indexingDefinitions)
{
if (def.definitionType == DefinitionType.NAME)
{
if (def.pattern.matcher(store).matches())
{
mode = def.indexMode;
modeCache.put(store, mode);
break;
}
}
else
{
AVMStoreDescriptor avmStoreDescriptor = avmService.getStore(store);
Map<QName, PropertyValue> storeProperties = null;
if (avmStoreDescriptor != null)
{
storeProperties = avmService.getStoreProperties(store);
}
String storeType = StoreType.getStoreType(store, avmStoreDescriptor, storeProperties).toString();
if (def.pattern.matcher(storeType).matches())
{
mode = def.indexMode;
modeCache.put(store, mode);
break;
}
}
}
}
// No definition
if (mode == null)
{
mode = defaultMode;
modeCache.put(store, mode);
}
return mode;
}
private class IndexingDefinition
{
IndexMode indexMode;
DefinitionType definitionType;
Pattern pattern;
IndexingDefinition(String definition)
{
String[] split = definition.split(":", 3);
if (split.length != 3)
{
throw new AlfrescoRuntimeException("Invalid index defintion. Must be of of the form IndexMode:DefinitionType:regular expression");
}
indexMode = IndexMode.valueOf(split[0].toUpperCase());
definitionType = DefinitionType.valueOf(split[1].toUpperCase());
pattern = Pattern.compile(split[2]);
}
}
private enum DefinitionType
{
NAME, TYPE;
}
public enum StoreType
{
STAGING, STAGING_PREVIEW, AUTHOR, AUTHOR_PREVIEW, WORKFLOW, WORKFLOW_PREVIEW, AUTHOR_WORKFLOW, AUTHOR_WORKFLOW_PREVIEW, UNKNOWN;
public static StoreType getStoreType(String name, AVMStoreDescriptor storeDescriptor, Map<QName, PropertyValue> storeProperties)
{
// if (avmService.getStore(name) != null)
if (storeDescriptor != null)
{
// Map<QName, PropertyValue> storeProperties = avmService.getStoreProperties(name);
if (storeProperties.containsKey(PROP_SANDBOX_STAGING_MAIN))
{
return StoreType.STAGING;
}
else if (storeProperties.containsKey(PROP_SANDBOX_STAGING_PREVIEW))
{
return StoreType.STAGING_PREVIEW;
}
else if (storeProperties.containsKey(PROP_SANDBOX_AUTHOR_MAIN))
{
return StoreType.AUTHOR;
}
else if (storeProperties.containsKey(PROP_SANDBOX_AUTHOR_PREVIEW))
{
return StoreType.AUTHOR_PREVIEW;
}
else if (storeProperties.containsKey(PROP_SANDBOX_WORKFLOW_MAIN))
{
return StoreType.WORKFLOW;
}
else if (storeProperties.containsKey(PROP_SANDBOX_WORKFLOW_PREVIEW))
{
return StoreType.WORKFLOW_PREVIEW;
}
else if (storeProperties.containsKey(PROP_SANDBOX_AUTHOR_WORKFLOW_MAIN))
{
return StoreType.AUTHOR_WORKFLOW;
}
else if (storeProperties.containsKey(PROP_SANDBOX_AUTHOR_WORKFLOW_PREVIEW))
{
return StoreType.AUTHOR_WORKFLOW_PREVIEW;
}
else
{
return StoreType.UNKNOWN;
}
}
else
{
return StoreType.UNKNOWN;
}
}
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#hasIndexBeenCreated(java.lang.String)
*/
@Override
public boolean hasIndexBeenCreated(String store)
{
AVMLuceneIndexer avmIndexer = getIndexer(store);
if (avmIndexer != null)
{
avmIndexer.flushPending();
return avmIndexer.hasIndexBeenCreated(store);
}
return false;
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#createIndex(java.lang.String)
*/
@Override
public void createIndex(String store)
{
AVMLuceneIndexer avmIndexer = getIndexer(store);
if (avmIndexer != null)
{
if (logger.isDebugEnabled())
{
logger.debug("createIndex " + store, new Exception("Stack Trace"));
}
avmIndexer.createIndex(store, IndexMode.SYNCHRONOUS);
}
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#getIndexer(java.lang.String)
*/
@Override
public AVMLuceneIndexer getIndexer(String store)
{
StoreRef storeRef = AVMNodeConverter.ToStoreRef(store);
Indexer indexer = indexerAndSearcher.getIndexer(storeRef);
if (indexer instanceof AVMLuceneIndexer)
{
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
return avmIndexer;
}
else
{
if(searchApplicationContextFactory.getCurrentSourceBeanName().equals("solr"))
{
throw new AlfrescoRuntimeException("No AVM Indexer available (AVM is not supported with SOLR");
//return null;
}
else
{
return null;
}
}
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor#deleteIndex(java.lang.String)
*/
@Override
public void deleteIndex(String store)
{
StoreRef storeRef = AVMNodeConverter.ToStoreRef(store);
Indexer indexer = indexerAndSearcher.getIndexer(storeRef);
if (indexer instanceof AVMLuceneIndexer)
{
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
avmIndexer.deleteIndex(storeRef);
}
else
{
if(searchApplicationContextFactory.getCurrentSourceBeanName().equals("solr"))
{
throw new AlfrescoRuntimeException("No AVM Indexer available (AVM is not supported with SOLR");
}
//else nothing to do
}
}
}

View File

@@ -1,102 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.lucene;
import java.util.List;
import org.alfresco.repo.search.BackgroundIndexerAware;
import org.alfresco.repo.search.IndexMode;
import org.alfresco.service.cmr.avm.VersionDescriptor;
/**
* AVM specific indxer support
*
* @author andyh
*
*/
public interface AVMLuceneIndexer extends LuceneIndexer, BackgroundIndexerAware
{
/**
* Index a specified change to a store between two snapshots
*
* @param store - the name of the store
* @param srcVersion - the id of the snapshot before the changeset
* @param dstVersion - the id of the snapshot created by the change set
* @param mode
*/
public void index(String store, int srcVersion, int dstVersion, IndexMode mode);
/**
* Delete the index for the specified store.
*
* @param store
* @param mode
*/
public void deleteIndex(String store, IndexMode mode);
/**
* Create an index for the specified store.
* This makes sure that the root node for the store is indexed correctly.
*
* @param store
* @param mode
*/
public void createIndex(String store, IndexMode mode);
/**
* Is the snapshot applied to the index?
*
* Is there an entry for any node that was added OR have all the nodes in the transaction been deleted as expected?
*
* @param store
* @param id
* @return - true if applied, false if not
*/
public boolean isSnapshotIndexed(String store, int id);
/**
* Is snapshot searchable
* @param store
* @param id
* @return - true if snapshot has been fully indexed, false if pending or unindexed.
*/
public boolean isSnapshotSearchable(String store, int id);
/**
* Has the index been ceated
*
* @param store
* @return
*/
public boolean hasIndexBeenCreated(String store);
/**
* Get the number of docs this indexer has indexed so far
* @return
*/
public long getIndexedDocCount();
/**
* Get the last snapshot in the index - this does not mean that all snapshots before it have been indexed.
*
* @param store
* @return
*/
public int getLastIndexedSnapshot(String store);
}

View File

@@ -1,213 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.lucene;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.content.ContentStore;
import org.alfresco.repo.content.transform.TransformerDebug;
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
import org.alfresco.repo.search.IndexMode;
import org.alfresco.repo.search.SearcherException;
import org.alfresco.repo.search.SupportsBackgroundIndexing;
import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.transaction.TransactionService;
/**
* Factory for AVM indexers and searchers
*
* @author andyh
*
*/
public class AVMLuceneIndexerAndSearcherFactory extends AbstractLuceneIndexerAndSearcherFactory implements SupportsBackgroundIndexing
{
private DictionaryService dictionaryService;
private NamespaceService nameSpaceService;
private ContentService contentService;
protected TransactionService transactionService;
private AVMService avmService;
private AVMSyncService avmSyncService;
private NodeService nodeService;
private ContentStore contentStore;
private TransformerDebug transformerDebug;
private FullTextSearchIndexer fullTextSearchIndexer;
private AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor;
public AVMLuceneIndexerAndSearcherFactory()
{
//s_logger.error("Creating AVMLuceneIndexerAndSearcherFactory");
}
/**
* Set the dictionary service
*/
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
/**
* Set the name space service
*/
public void setNameSpaceService(NamespaceService nameSpaceService)
{
this.nameSpaceService = nameSpaceService;
}
/**
* Set the content service
*/
public void setContentService(ContentService contentService)
{
this.contentService = contentService;
}
public void setTransactionService(TransactionService transactionService)
{
this.transactionService = transactionService;
}
/**
* Set the AVM service
*/
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
/**
* Set the AVM sync service
*/
public void setAvmSyncService(AVMSyncService avmSyncService)
{
this.avmSyncService = avmSyncService;
}
/**
* Set the node service
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* Set the content service
*/
public void setContentStore(ContentStore contentStore)
{
this.contentStore = contentStore;
}
/**
* Sets the transformer debug.
* @param transformerDebug
*/
public void setTransformerDebug(TransformerDebug transformerDebug)
{
this.transformerDebug = transformerDebug;
}
/**
* @param avmSnapShotTriggeredIndexingMethodInterceptor the avmSnapShotTriggeredIndexingMethodInterceptor to set
*/
public void setAvmSnapShotTriggeredIndexingMethodInterceptor(AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor)
{
this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor;
}
@Override
protected LuceneIndexer createIndexer(StoreRef storeRef, String deltaId)
{
AVMLuceneIndexerImpl indexer = AVMLuceneIndexerImpl.getUpdateIndexer(storeRef, deltaId, this);
indexer.setDictionaryService(dictionaryService);
indexer.setContentService(contentService);
indexer.setTransactionService(transactionService);
indexer.setMaxAtomicTransformationTime(getMaxTransformationTime());
indexer.setAvmService(avmService);
indexer.setAvmSyncService(avmSyncService);
indexer.setContentStore(contentStore);
indexer.setTransformerDebug(transformerDebug);
indexer.setFullTextSearchIndexer(fullTextSearchIndexer);
return indexer;
}
@Override
protected List<StoreRef> getAllStores()
{
List<AVMStoreDescriptor> stores = avmService.getStores();
List<StoreRef> storeRefs = new ArrayList<StoreRef>(stores.size());
for(AVMStoreDescriptor storeDesc : stores)
{
StoreRef storeRef = AVMNodeConverter.ToStoreRef(storeDesc.getName());
if (avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(storeRef.getIdentifier()) == IndexMode.UNINDEXED)
{
// ALF-5722 fix
continue;
}
storeRefs.add(storeRef);
}
return storeRefs;
}
@Override
protected LuceneSearcher getSearcher(StoreRef storeRef, LuceneIndexer indexer) throws SearcherException
{
//TODO: Store overlays
ADMLuceneSearcherImpl searcher = ADMLuceneSearcherImpl.getSearcher(storeRef, indexer, this);
searcher.setNamespacePrefixResolver(nameSpaceService);
// searcher.setLuceneIndexLock(luceneIndexLock);
searcher.setNodeService(nodeService);
searcher.setTenantService(tenantService);
searcher.setDictionaryService(dictionaryService);
searcher.setQueryRegister(getQueryRegister());
searcher.setDictionaryService(dictionaryService);
searcher.setQueryLanguages(getQueryLanguages());
return searcher;
}
@Override
protected SearchService getNodeSearcher() throws SearcherException
{
throw new UnsupportedOperationException();
}
/**
* Register the full text searcher (done by the seracher bean to break cyclic bean defs)
*
*/
public void setFullTextSearchIndexer(FullTextSearchIndexer fullTextSearchIndexer)
{
this.fullTextSearchIndexer = fullTextSearchIndexer;
}
}

View File

@@ -32,7 +32,7 @@ import net.sf.acegisecurity.providers.dao.User;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.AVMRepository;
//import org.alfresco.repo.avm.AVMRepository;
import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.domain.permissions.AclDAO;
import org.alfresco.repo.policy.JavaBehaviour;
@@ -613,12 +613,15 @@ public class PermissionServiceImpl extends AbstractLifecycleBean implements Perm
private AccessStatus doAvmCan(NodeRef nodeRef, PermissionReference permission)
{
/* Sparta: remove WCM/AVM
org.alfresco.util.Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
int version = avmVersionPath.getFirst();
String path = avmVersionPath.getSecond();
boolean result = AVMRepository.GetInstance().can(nodeRef.getStoreRef().getIdentifier(), version, path, permission.getName());
AccessStatus status = result ? AccessStatus.ALLOWED : AccessStatus.DENIED;
return status;
*/
return AccessStatus.DENIED;
}
/*

Some files were not shown because too many files have changed in this diff Show More