From 0baa0f74f434a2fb7ad92094e59433dbdce3b0f6 Mon Sep 17 00:00:00 2001 From: Erik Winlof Date: Wed, 3 Sep 2014 12:01:49 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud) 78403: Merged EOL (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 75700: ACE-2149: EOL AVM / WCM - Remove most of the AVM and WCM beans, scripts, classes, patches, etc - The Explorer client is very broken for compilation - TODO: Remove all WCM-related functionality, which I thought would be best left to a UI dev I've murdered many of the classes and beans but there's more to do - The repository compiles TODO: Get it running again - TODO: Check if we can wipe the 'deployment' project as well git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@82540 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco-global.properties.sample | 3 - config/alfresco/avm-console-context.xml | 36 - config/alfresco/avm-console.properties | 16 - config/alfresco/avm-services-context.xml | 267 -- config/alfresco/avm-test-context.xml | 22 - .../bootstrap/customMessagesSpace.xml | 2 +- .../customWebClientExtensionSpace.xml | 2 +- config/alfresco/bootstrap/webScripts.xml | 2 +- .../bootstrap/webScriptsExtensions.xml | 2 +- .../alfresco/bootstrap/webScriptsReadme.xml | 4 +- config/alfresco/caches.properties | 43 - config/alfresco/content-services-context.xml | 8 - config/alfresco/dao/dao-context.xml | 70 - .../AlfrescoCreate-AvmTables.sql | 248 -- .../Schema-Reference-AVM.xml | 742 ---- .../AlfrescoCreate-AvmTables.sql | 255 -- .../Schema-Reference-AVM.xml | 753 ---- .../remove-AVM-issuer.sql | 26 - .../modify-AVM-mimetype.sql | 24 - .../remove-AVM-issuer.sql | 57 - .../modify-AVM-mimetype.sql | 24 - .../remove-AVM-issuer.sql | 50 - .../fix-AVM-seqs.sql | 23 - .../fix-AVM-seqs.sql | 33 - .../AVM-rename-dupes.sql | 61 - .../link-validation-metadata-removing.sql | 51 - .../AVM-index-child-entries-lower.sql | 50 - .../AVM-index-child-entries-lower.sql | 51 - .../fix-AVM-seqs-order.sql | 24 - .../drop-AVM-index.sql | 26 - .../drop-AVM-index.sql | 27 - ...ynchronous-avm-indexing-context.xml.sample | 40 - ...-xml-metadata-extracter-context.xml.sample | 156 - .../alfresco/ibatis/alfresco-SqlMapConfig.xml | 15 +- config/alfresco/ibatis/ibatis-context.xml | 6 - .../avm-common-SqlMap.xml | 1212 ------ .../avm-insert-SqlMap.xml | 23 - .../avm-insert-SqlMap.xml | 47 - .../alfresco/opencmis-qnamefilter-context.xml | 2 - .../alfresco/patch/patch-services-context.xml | 470 --- config/alfresco/public-services-context.xml | 383 -- config/alfresco/repository.properties | 50 - .../templates/following-email-templates.xml | 2 +- .../templates/invite-email-templates.xml | 14 +- .../alfresco/templates/new-user-templates.xml | 14 +- .../templates/notify_email_templates.xml | 14 +- config/alfresco/templates/readme_template.xml | 2 +- config/alfresco/tx-cache-context.xml | 75 - config/alfresco/wcm-services-context.xml | 343 -- config/alfresco/workflow-context.xml | 3 - .../org/alfresco/filesys/avm/AVMContext.java | 667 ---- .../alfresco/filesys/avm/AVMDiskDriver.java | 3347 ----------------- .../alfresco/filesys/avm/AVMNetworkFile.java | 565 --- .../org/alfresco/filesys/avm/AVMPath.java | 727 ---- .../filesys/avm/AVMSearchContext.java | 324 -- .../alfresco/filesys/avm/AVMShareMapper.java | 393 -- .../avm/AVMSingleFileSearchContext.java | 196 - .../filesys/avm/DummyFolderPseudoFile.java | 91 - .../avm/PseudoFileListSearchContext.java | 296 -- .../alfresco/filesys/avm/StorePseudoFile.java | 211 -- .../org/alfresco/filesys/avm/StoreType.java | 59 - .../filesys/avm/VersionPseudoFile.java | 119 - .../avm/WebProjectStorePseudoFile.java | 181 - .../alfresco/filesys/avm/package-info.java | 5 - .../config/ServerConfigurationBean.java | 245 +- .../java/org/alfresco/model/WCMAppModel.java | 167 - source/java/org/alfresco/model/WCMModel.java | 44 - .../org/alfresco/model/WCMWorkflowModel.java | 36 - .../admin/IndexConfigurationCheckerImpl.java | 43 - .../patch/impl/AVMPermissionDataPatch.java | 58 - .../patch/impl/AVMToADMRemoteStorePatch.java | 697 ---- .../AVMWebProjectInheritPermissionsPatch.java | 105 - .../impl/AuthorityDefaultZonesPatch.java | 23 +- .../patch/impl/MigrateAttrAVMLocksPatch.java | 125 - .../impl/MultiTShareExistingTenantsPatch.java | 1 - .../org/alfresco/repo/avm/AVMCrawler.java | 329 -- .../repo/avm/AVMDeploymentAttemptCleaner.java | 166 - .../avm/AVMDeploymentAttemptCleanerJob.java | 56 - .../repo/avm/AVMExpiredContentJob.java | 57 - .../repo/avm/AVMExpiredContentProcessor.java | 492 --- .../org/alfresco/repo/avm/AVMInterpreter.java | 970 ----- .../repo/avm/AVMLockingAwareService.java | 722 ---- .../alfresco/repo/avm/AVMNodeConverter.java | 131 - .../org/alfresco/repo/avm/AVMNodeService.java | 2090 ---------- .../org/alfresco/repo/avm/AVMNodeType.java | 32 - .../org/alfresco/repo/avm/AVMRemoteLocal.java | 555 --- .../repo/avm/AVMRemoteTransportService.java | 1101 ------ .../alfresco/repo/avm/AVMServiceNOOPImpl.java | 735 ---- .../repo/avm/AVMSyncServiceNOOPImpl.java | 77 - .../repo/avm/AVMSyncServiceTransportImpl.java | 108 - .../repo/avm/AvmMetadataExtracter.java | 92 - .../alfresco/repo/avm/BasicAttributes.java | 98 - .../repo/avm/BasicAttributesImpl.java | 214 -- .../repo/avm/CreateStoreCallback.java | 33 - .../repo/avm/CreateStoreTxnListener.java | 107 - .../repo/avm/CreateVersionCallback.java | 33 - .../repo/avm/CreateVersionTxnListener.java | 109 - .../alfresco/repo/avm/LayeredFolderType.java | 332 -- .../java/org/alfresco/repo/avm/LookupKey.java | 158 - .../alfresco/repo/avm/MultiTAVMService.java | 1066 ------ .../alfresco/repo/avm/PurgeStoreCallback.java | 32 - .../repo/avm/PurgeStoreTxnListener.java | 107 - .../repo/avm/PurgeVersionCallback.java | 33 - .../repo/avm/PurgeVersionTxnListener.java | 109 - .../avm/actions/AVMDeployWebsiteAction.java | 601 --- .../repo/avm/actions/AVMRevertListAction.java | 106 - .../avm/actions/AVMRevertStoreAction.java | 93 - .../avm/actions/AVMRevertToVersionAction.java | 95 - .../avm/actions/AVMUndoSandboxListAction.java | 144 - .../avm/actions/SimpleAVMPromoteAction.java | 117 - .../avm/actions/StartAVMWorkflowAction.java | 152 - .../avm/locking/AVMLockingServiceImpl.java | 518 --- .../org/alfresco/repo/avm/util/AVMUtil.java | 151 - .../alfresco/repo/avm/util/BulkLoader.java | 144 - .../alfresco/repo/avm/util/BulkReader.java | 100 - .../avm/util/FileExtensionNameMatcher.java | 75 - .../repo/avm/util/RemoteBulkLoader.java | 36 - .../alfresco/repo/avm/util/SimplePath.java | 134 - .../repo/avm/util/UriSchemeNameMatcher.java | 201 - .../repo/avm/util/VersionPathStuffer.java | 86 - .../repo/avm/util/VersionPathUnstuffer.java | 77 - .../java/org/alfresco/repo/clt/AVMCopyIn.java | 168 - .../org/alfresco/repo/clt/AVMCopyOut.java | 157 - source/java/org/alfresco/repo/clt/AVMLs.java | 93 - .../org/alfresco/repo/clt/AVMLsStores.java | 54 - .../org/alfresco/repo/clt/AVMLsVersions.java | 54 - .../java/org/alfresco/repo/clt/AVMMkDir.java | 83 - .../alfresco/repo/clt/AVMMkLayeredDir.java | 55 - .../org/alfresco/repo/clt/AVMMkStore.java | 51 - source/java/org/alfresco/repo/clt/AVMRm.java | 55 - .../org/alfresco/repo/clt/AVMSnapshot.java | 51 - .../java/org/alfresco/repo/clt/CltBase.java | 241 -- .../org/alfresco/repo/clt/RepoCopyIn.java | 173 - .../org/alfresco/repo/clt/RepoCopyOut.java | 165 - source/java/org/alfresco/repo/clt/RepoLs.java | 99 - .../repo/content/ContentServiceImpl.java | 33 +- .../content/cleanup/ContentStoreCleaner.java | 14 - .../filestore/DeletionMetricsRunner.java | 3 - .../copy/CrossRepositoryCopyServiceImpl.java | 409 -- ...actDeploymentReceiverTransportAdapter.java | 49 - .../deploy/DeploymentClientOutputStream.java | 125 - .../repo/deploy/DeploymentDestination.java | 71 - ...verAuthenticatorAuthenticationService.java | 66 - .../DeploymentReceiverServiceClient.java | 144 - .../DeploymentReceiverTransportAdapter.java | 63 - ...oymentReceiverTransportAdapterHessian.java | 65 - ...DeploymentReceiverTransportAdapterRMI.java | 47 - ...entReceiverTransportAdapterSpringHTTP.java | 66 - .../repo/deploy/DeploymentServiceImpl.java | 2276 ----------- .../alfresco/repo/deploy/DeploymentWork.java | 68 - .../repo/domain/avm/AVMAspectEntity.java | 64 - .../repo/domain/avm/AVMChildEntryEntity.java | 133 - .../repo/domain/avm/AVMHistoryLinkEntity.java | 66 - .../alfresco/repo/domain/avm/AVMLockDAO.java | 46 - .../repo/domain/avm/AVMMergeLinkEntity.java | 63 - .../repo/domain/avm/AVMNodeAspectEntity.java | 66 - .../domain/avm/AVMNodeChildEntryEntity.java | 80 - .../alfresco/repo/domain/avm/AVMNodeDAO.java | 133 - .../repo/domain/avm/AVMNodeEntity.java | 419 --- .../repo/domain/avm/AVMNodeLinksDAO.java | 109 - .../domain/avm/AVMNodePropertyEntity.java | 85 - .../alfresco/repo/domain/avm/AVMStoreDAO.java | 120 - .../repo/domain/avm/AVMStoreEntity.java | 149 - .../domain/avm/AVMStorePropertyEntity.java | 110 - .../avm/AVMVersionLayeredNodeEntryEntity.java | 64 - .../repo/domain/avm/AVMVersionRootDAO.java | 128 - .../repo/domain/avm/AVMVersionRootEntity.java | 164 - .../domain/avm/AbstractAVMLockDAOImpl.java | 108 - .../domain/avm/AbstractAVMNodeDAOImpl.java | 698 ---- .../avm/AbstractAVMNodeLinksDAOImpl.java | 555 --- .../domain/avm/AbstractAVMStoreDAOImpl.java | 549 --- .../avm/AbstractAVMVersionRootDAOImpl.java | 314 -- .../domain/avm/ibatis/AVMLockDAOImpl.java | 103 - .../domain/avm/ibatis/AVMNodeDAOImpl.java | 314 -- .../avm/ibatis/AVMNodeLinksDAOImpl.java | 237 -- .../domain/avm/ibatis/AVMStoreDAOImpl.java | 229 -- .../avm/ibatis/AVMVersionRootDAOImpl.java | 233 -- .../domain/patch/AbstractPatchDAOImpl.java | 50 - .../alfresco/repo/domain/patch/PatchDAO.java | 24 - .../domain/patch/ibatis/PatchDAOImpl.java | 92 +- .../permissions/ADMAccessControlListDAO.java | 11 +- .../AVMPermissionsDaoComponentImpl.java | 193 - .../exporter/AVMZipExporterServiceImpl.java | 130 - .../alfresco/repo/importer/AVMImporter.java | 52 - .../repo/importer/AVMZipBootstrap.java | 243 -- .../repo/importer/AVMZipImporter.java | 210 -- .../java/org/alfresco/repo/jscript/AVM.java | 245 -- .../org/alfresco/repo/jscript/AVMNode.java | 366 -- .../alfresco/repo/jscript/AVMScriptStore.java | 186 - .../repo/jscript/CrossRepositoryCopy.java | 94 - .../org/alfresco/repo/jscript/ScriptNode.java | 26 +- .../org/alfresco/repo/model/Repository.java | 176 +- .../repo/model/ml/MLContentInterceptor.java | 3 +- .../repo/node/MLPropertyInterceptor.java | 3 +- .../node/index/AbstractReindexComponent.java | 4 - .../index/FullIndexRecoveryComponent.java | 5 +- .../alfresco/repo/remote/AVMRemoteImpl.java | 571 --- .../repo/remote/AVMRemoteInputStream.java | 123 - .../repo/remote/AVMRemoteOutputStream.java | 115 - .../repo/remote/AVMSyncServiceRemote.java | 109 - ...stractLuceneIndexerAndSearcherFactory.java | 1 - .../FullTextSearchIndexerBootstrapBean.java | 9 +- .../impl/PermissionServiceImpl.java | 30 +- .../permissions/impl/acegi/ACLEntryVoter.java | 29 +- .../service/ServiceDescriptorRegistry.java | 88 - .../alfresco/repo/site/SiteAVMBootstrap.java | 155 - .../java/org/alfresco/repo/template/AVM.java | 235 -- .../repo/template/AVMTemplateNode.java | 601 --- .../repo/template/AVMTemplateStore.java | 182 - .../repo/template/FreeMarkerProcessor.java | 10 +- .../org/alfresco/repo/template/Workflow.java | 29 +- .../tenant/MultiTNodeServiceInterceptor.java | 2 +- .../repo/workflow/WorkflowInterpreter.java | 73 - .../repo/workflow/WorkflowServiceImpl.java | 52 +- .../workflow/jscript/JscriptWorkflowTask.java | 11 +- .../alfresco/sandbox/SandboxConstants.java | 33 - .../org/alfresco/service/ServiceRegistry.java | 112 - .../cmr/avm/AVMBadArgumentException.java | 70 - .../service/cmr/avm/AVMCycleException.java | 69 - .../service/cmr/avm/AVMException.java | 66 - .../service/cmr/avm/AVMExistsException.java | 69 - .../service/cmr/avm/AVMNodeDescriptor.java | 529 --- .../service/cmr/avm/AVMNotFoundException.java | 69 - .../service/cmr/avm/AVMReadOnlyException.java | 65 - .../alfresco/service/cmr/avm/AVMService.java | 1403 ------- .../service/cmr/avm/AVMStoreDescriptor.java | 122 - .../cmr/avm/AVMWrongTypeException.java | 70 - .../service/cmr/avm/LayeringDescriptor.java | 89 - .../service/cmr/avm/VersionDescriptor.java | 156 - .../cmr/avm/deploy/DeploymentCallback.java | 35 - .../cmr/avm/deploy/DeploymentEvent.java | 142 - .../cmr/avm/deploy/DeploymentReport.java | 78 - .../avm/deploy/DeploymentReportCallback.java | 40 - .../cmr/avm/deploy/DeploymentService.java | 128 - .../service/cmr/avm/deploy/package-info.java | 25 - .../cmr/avm/locking/AVMLockingException.java | 41 - .../cmr/avm/locking/AVMLockingService.java | 171 - .../service/cmr/avmsync/AVMDifference.java | 214 -- .../service/cmr/avmsync/AVMSyncException.java | 71 - .../service/cmr/avmsync/AVMSyncService.java | 94 - .../service/cmr/remote/AVMRemote.java | 999 ----- .../cmr/remote/AVMRemoteTransport.java | 549 --- .../cmr/remote/AVMSyncServiceTransport.java | 102 - .../cmr/view/AVMZipExporterService.java | 72 - source/java/org/alfresco/util/XMLUtil.java | 11 - .../WCMSandboxRevertSnapshotAction.java | 94 - .../wcm/actions/WCMSandboxSubmitAction.java | 95 - .../wcm/actions/WCMSandboxUndoAction.java | 95 - .../org/alfresco/wcm/asset/AssetInfo.java | 59 - .../org/alfresco/wcm/asset/AssetInfoImpl.java | 132 - .../org/alfresco/wcm/asset/AssetService.java | 225 -- .../alfresco/wcm/asset/AssetServiceImpl.java | 695 ---- .../AbstractPreviewURIServiceProvider.java | 58 - .../wcm/preview/NullPreviewURIService.java | 40 - .../alfresco/wcm/preview/PreviewContext.java | 57 - .../wcm/preview/PreviewURIService.java | 70 - .../wcm/preview/PreviewURIServiceImpl.java | 131 - .../preview/PreviewURIServiceProvider.java | 51 - .../preview/PreviewURIServiceRegistry.java | 47 - .../PreviewURIServiceRegistryImpl.java | 73 - .../preview/URITemplatePreviewURIService.java | 85 - ...VirtualisationServerPreviewURIService.java | 151 - .../wcm/sandbox/SandboxConstants.java | 56 - .../alfresco/wcm/sandbox/SandboxFactory.java | 1364 ------- .../org/alfresco/wcm/sandbox/SandboxInfo.java | 76 - .../alfresco/wcm/sandbox/SandboxInfoImpl.java | 104 - .../alfresco/wcm/sandbox/SandboxService.java | 376 -- .../wcm/sandbox/SandboxServiceImpl.java | 1259 ------- .../alfresco/wcm/sandbox/SandboxVersion.java | 76 - .../wcm/sandbox/SandboxVersionImpl.java | 92 - .../alfresco/wcm/sandbox/script/Asset.java | 589 --- .../alfresco/wcm/sandbox/script/Sandbox.java | 349 -- .../java/org/alfresco/wcm/util/WCMUtil.java | 895 ----- .../alfresco/wcm/util/WCMWorkflowUtil.java | 198 - .../wcm/webproject/WebProjectInfo.java | 135 - .../wcm/webproject/WebProjectInfoImpl.java | 200 - .../wcm/webproject/WebProjectService.java | 563 --- .../wcm/webproject/WebProjectServiceImpl.java | 1616 -------- .../wcm/webproject/script/WebProject.java | 315 -- .../wcm/webproject/script/WebProjects.java | 195 - .../cleanup/ContentStoreCleanerTest.java | 3 - .../rendition/MockedTestServiceRegistry.java | 86 - .../impl/AbstractReadPermissionTest.java | 149 +- .../permissions/impl/ReadPermissionTest.java | 55 - 284 files changed, 206 insertions(+), 58844 deletions(-) delete mode 100644 config/alfresco/avm-console-context.xml delete mode 100644 config/alfresco/avm-console.properties delete mode 100644 config/alfresco/avm-services-context.xml delete mode 100644 config/alfresco/avm-test-context.xml delete mode 100644 config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-AvmTables.sql delete mode 100644 config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-AVM.xml delete mode 100644 config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-AvmTables.sql delete mode 100644 config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-AVM.xml delete mode 100644 config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.Dialect/remove-AVM-issuer.sql delete mode 100644 config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.MySQLInnoDBDialect/modify-AVM-mimetype.sql delete mode 100644 config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.MySQLInnoDBDialect/remove-AVM-issuer.sql delete mode 100644 config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.PostgreSQLDialect/modify-AVM-mimetype.sql delete mode 100644 config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.PostgreSQLDialect/remove-AVM-issuer.sql delete mode 100755 config/alfresco/dbscripts/upgrade/3.3/org.hibernate.dialect.Dialect/fix-AVM-seqs.sql delete mode 100755 config/alfresco/dbscripts/upgrade/3.3/org.hibernate.dialect.PostgreSQLDialect/fix-AVM-seqs.sql delete mode 100644 config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/AVM-rename-dupes.sql delete mode 100644 config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/link-validation-metadata-removing.sql delete mode 100644 config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.MySQLInnoDBDialect/AVM-index-child-entries-lower.sql delete mode 100644 config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.PostgreSQLDialect/AVM-index-child-entries-lower.sql delete mode 100644 config/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/fix-AVM-seqs-order.sql delete mode 100644 config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/drop-AVM-index.sql delete mode 100644 config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/drop-AVM-index.sql delete mode 100644 config/alfresco/extension/asynchronous-avm-indexing-context.xml.sample delete mode 100644 config/alfresco/extension/wcm-xml-metadata-extracter-context.xml.sample delete mode 100644 config/alfresco/ibatis/org.hibernate.dialect.Dialect/avm-common-SqlMap.xml delete mode 100644 config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/avm-insert-SqlMap.xml delete mode 100644 config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/avm-insert-SqlMap.xml delete mode 100644 config/alfresco/wcm-services-context.xml delete mode 100644 source/java/org/alfresco/filesys/avm/AVMContext.java delete mode 100644 source/java/org/alfresco/filesys/avm/AVMDiskDriver.java delete mode 100644 source/java/org/alfresco/filesys/avm/AVMNetworkFile.java delete mode 100644 source/java/org/alfresco/filesys/avm/AVMPath.java delete mode 100644 source/java/org/alfresco/filesys/avm/AVMSearchContext.java delete mode 100644 source/java/org/alfresco/filesys/avm/AVMShareMapper.java delete mode 100644 source/java/org/alfresco/filesys/avm/AVMSingleFileSearchContext.java delete mode 100644 source/java/org/alfresco/filesys/avm/DummyFolderPseudoFile.java delete mode 100644 source/java/org/alfresco/filesys/avm/PseudoFileListSearchContext.java delete mode 100644 source/java/org/alfresco/filesys/avm/StorePseudoFile.java delete mode 100644 source/java/org/alfresco/filesys/avm/StoreType.java delete mode 100644 source/java/org/alfresco/filesys/avm/VersionPseudoFile.java delete mode 100644 source/java/org/alfresco/filesys/avm/WebProjectStorePseudoFile.java delete mode 100644 source/java/org/alfresco/filesys/avm/package-info.java delete mode 100644 source/java/org/alfresco/model/WCMAppModel.java delete mode 100644 source/java/org/alfresco/model/WCMModel.java delete mode 100644 source/java/org/alfresco/model/WCMWorkflowModel.java delete mode 100644 source/java/org/alfresco/repo/admin/patch/impl/AVMPermissionDataPatch.java delete mode 100644 source/java/org/alfresco/repo/admin/patch/impl/AVMToADMRemoteStorePatch.java delete mode 100644 source/java/org/alfresco/repo/admin/patch/impl/AVMWebProjectInheritPermissionsPatch.java delete mode 100644 source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrAVMLocksPatch.java delete mode 100644 source/java/org/alfresco/repo/avm/AVMCrawler.java delete mode 100644 source/java/org/alfresco/repo/avm/AVMDeploymentAttemptCleaner.java delete mode 100644 source/java/org/alfresco/repo/avm/AVMDeploymentAttemptCleanerJob.java delete mode 100644 source/java/org/alfresco/repo/avm/AVMExpiredContentJob.java delete mode 100644 source/java/org/alfresco/repo/avm/AVMExpiredContentProcessor.java delete mode 100644 source/java/org/alfresco/repo/avm/AVMInterpreter.java delete mode 100644 source/java/org/alfresco/repo/avm/AVMLockingAwareService.java delete mode 100644 source/java/org/alfresco/repo/avm/AVMNodeConverter.java delete mode 100644 source/java/org/alfresco/repo/avm/AVMNodeService.java delete mode 100644 source/java/org/alfresco/repo/avm/AVMNodeType.java delete mode 100644 source/java/org/alfresco/repo/avm/AVMRemoteLocal.java delete mode 100644 source/java/org/alfresco/repo/avm/AVMRemoteTransportService.java delete mode 100644 source/java/org/alfresco/repo/avm/AVMServiceNOOPImpl.java delete mode 100644 source/java/org/alfresco/repo/avm/AVMSyncServiceNOOPImpl.java delete mode 100644 source/java/org/alfresco/repo/avm/AVMSyncServiceTransportImpl.java delete mode 100644 source/java/org/alfresco/repo/avm/AvmMetadataExtracter.java delete mode 100644 source/java/org/alfresco/repo/avm/BasicAttributes.java delete mode 100644 source/java/org/alfresco/repo/avm/BasicAttributesImpl.java delete mode 100644 source/java/org/alfresco/repo/avm/CreateStoreCallback.java delete mode 100644 source/java/org/alfresco/repo/avm/CreateStoreTxnListener.java delete mode 100644 source/java/org/alfresco/repo/avm/CreateVersionCallback.java delete mode 100644 source/java/org/alfresco/repo/avm/CreateVersionTxnListener.java delete mode 100644 source/java/org/alfresco/repo/avm/LayeredFolderType.java delete mode 100644 source/java/org/alfresco/repo/avm/LookupKey.java delete mode 100644 source/java/org/alfresco/repo/avm/MultiTAVMService.java delete mode 100644 source/java/org/alfresco/repo/avm/PurgeStoreCallback.java delete mode 100644 source/java/org/alfresco/repo/avm/PurgeStoreTxnListener.java delete mode 100644 source/java/org/alfresco/repo/avm/PurgeVersionCallback.java delete mode 100644 source/java/org/alfresco/repo/avm/PurgeVersionTxnListener.java delete mode 100644 source/java/org/alfresco/repo/avm/actions/AVMDeployWebsiteAction.java delete mode 100644 source/java/org/alfresco/repo/avm/actions/AVMRevertListAction.java delete mode 100644 source/java/org/alfresco/repo/avm/actions/AVMRevertStoreAction.java delete mode 100644 source/java/org/alfresco/repo/avm/actions/AVMRevertToVersionAction.java delete mode 100644 source/java/org/alfresco/repo/avm/actions/AVMUndoSandboxListAction.java delete mode 100644 source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java delete mode 100644 source/java/org/alfresco/repo/avm/actions/StartAVMWorkflowAction.java delete mode 100644 source/java/org/alfresco/repo/avm/locking/AVMLockingServiceImpl.java delete mode 100644 source/java/org/alfresco/repo/avm/util/AVMUtil.java delete mode 100644 source/java/org/alfresco/repo/avm/util/BulkLoader.java delete mode 100644 source/java/org/alfresco/repo/avm/util/BulkReader.java delete mode 100644 source/java/org/alfresco/repo/avm/util/FileExtensionNameMatcher.java delete mode 100644 source/java/org/alfresco/repo/avm/util/RemoteBulkLoader.java delete mode 100644 source/java/org/alfresco/repo/avm/util/SimplePath.java delete mode 100644 source/java/org/alfresco/repo/avm/util/UriSchemeNameMatcher.java delete mode 100644 source/java/org/alfresco/repo/avm/util/VersionPathStuffer.java delete mode 100644 source/java/org/alfresco/repo/avm/util/VersionPathUnstuffer.java delete mode 100644 source/java/org/alfresco/repo/clt/AVMCopyIn.java delete mode 100644 source/java/org/alfresco/repo/clt/AVMCopyOut.java delete mode 100644 source/java/org/alfresco/repo/clt/AVMLs.java delete mode 100644 source/java/org/alfresco/repo/clt/AVMLsStores.java delete mode 100644 source/java/org/alfresco/repo/clt/AVMLsVersions.java delete mode 100644 source/java/org/alfresco/repo/clt/AVMMkDir.java delete mode 100644 source/java/org/alfresco/repo/clt/AVMMkLayeredDir.java delete mode 100644 source/java/org/alfresco/repo/clt/AVMMkStore.java delete mode 100644 source/java/org/alfresco/repo/clt/AVMRm.java delete mode 100644 source/java/org/alfresco/repo/clt/AVMSnapshot.java delete mode 100644 source/java/org/alfresco/repo/clt/CltBase.java delete mode 100644 source/java/org/alfresco/repo/clt/RepoCopyIn.java delete mode 100644 source/java/org/alfresco/repo/clt/RepoCopyOut.java delete mode 100644 source/java/org/alfresco/repo/clt/RepoLs.java delete mode 100644 source/java/org/alfresco/repo/copy/CrossRepositoryCopyServiceImpl.java delete mode 100644 source/java/org/alfresco/repo/deploy/AbstractDeploymentReceiverTransportAdapter.java delete mode 100644 source/java/org/alfresco/repo/deploy/DeploymentClientOutputStream.java delete mode 100644 source/java/org/alfresco/repo/deploy/DeploymentDestination.java delete mode 100644 source/java/org/alfresco/repo/deploy/DeploymentReceiverAuthenticatorAuthenticationService.java delete mode 100644 source/java/org/alfresco/repo/deploy/DeploymentReceiverServiceClient.java delete mode 100644 source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapter.java delete mode 100644 source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapterHessian.java delete mode 100644 source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapterRMI.java delete mode 100644 source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapterSpringHTTP.java delete mode 100644 source/java/org/alfresco/repo/deploy/DeploymentServiceImpl.java delete mode 100644 source/java/org/alfresco/repo/deploy/DeploymentWork.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMAspectEntity.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMChildEntryEntity.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMHistoryLinkEntity.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMLockDAO.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMMergeLinkEntity.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMNodeAspectEntity.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMNodeChildEntryEntity.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMNodeDAO.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMNodeEntity.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMNodeLinksDAO.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMNodePropertyEntity.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMStoreDAO.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMStoreEntity.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMStorePropertyEntity.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMVersionLayeredNodeEntryEntity.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMVersionRootDAO.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AVMVersionRootEntity.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AbstractAVMLockDAOImpl.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AbstractAVMNodeDAOImpl.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AbstractAVMNodeLinksDAOImpl.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AbstractAVMStoreDAOImpl.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/AbstractAVMVersionRootDAOImpl.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/ibatis/AVMLockDAOImpl.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeDAOImpl.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeLinksDAOImpl.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/ibatis/AVMStoreDAOImpl.java delete mode 100644 source/java/org/alfresco/repo/domain/avm/ibatis/AVMVersionRootDAOImpl.java delete mode 100644 source/java/org/alfresco/repo/domain/permissions/AVMPermissionsDaoComponentImpl.java delete mode 100644 source/java/org/alfresco/repo/exporter/AVMZipExporterServiceImpl.java delete mode 100644 source/java/org/alfresco/repo/importer/AVMImporter.java delete mode 100644 source/java/org/alfresco/repo/importer/AVMZipBootstrap.java delete mode 100644 source/java/org/alfresco/repo/importer/AVMZipImporter.java delete mode 100644 source/java/org/alfresco/repo/jscript/AVM.java delete mode 100644 source/java/org/alfresco/repo/jscript/AVMNode.java delete mode 100644 source/java/org/alfresco/repo/jscript/AVMScriptStore.java delete mode 100644 source/java/org/alfresco/repo/jscript/CrossRepositoryCopy.java delete mode 100644 source/java/org/alfresco/repo/remote/AVMRemoteImpl.java delete mode 100644 source/java/org/alfresco/repo/remote/AVMRemoteInputStream.java delete mode 100644 source/java/org/alfresco/repo/remote/AVMRemoteOutputStream.java delete mode 100644 source/java/org/alfresco/repo/remote/AVMSyncServiceRemote.java delete mode 100644 source/java/org/alfresco/repo/site/SiteAVMBootstrap.java delete mode 100644 source/java/org/alfresco/repo/template/AVM.java delete mode 100644 source/java/org/alfresco/repo/template/AVMTemplateNode.java delete mode 100644 source/java/org/alfresco/repo/template/AVMTemplateStore.java delete mode 100644 source/java/org/alfresco/sandbox/SandboxConstants.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/AVMBadArgumentException.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/AVMCycleException.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/AVMException.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/AVMExistsException.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/AVMNodeDescriptor.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/AVMNotFoundException.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/AVMReadOnlyException.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/AVMService.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/AVMStoreDescriptor.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/AVMWrongTypeException.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/LayeringDescriptor.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/VersionDescriptor.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/deploy/DeploymentCallback.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/deploy/DeploymentEvent.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/deploy/DeploymentReport.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/deploy/DeploymentReportCallback.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/deploy/DeploymentService.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/deploy/package-info.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/locking/AVMLockingException.java delete mode 100644 source/java/org/alfresco/service/cmr/avm/locking/AVMLockingService.java delete mode 100644 source/java/org/alfresco/service/cmr/avmsync/AVMDifference.java delete mode 100644 source/java/org/alfresco/service/cmr/avmsync/AVMSyncException.java delete mode 100644 source/java/org/alfresco/service/cmr/avmsync/AVMSyncService.java delete mode 100644 source/java/org/alfresco/service/cmr/remote/AVMRemote.java delete mode 100644 source/java/org/alfresco/service/cmr/remote/AVMRemoteTransport.java delete mode 100644 source/java/org/alfresco/service/cmr/remote/AVMSyncServiceTransport.java delete mode 100644 source/java/org/alfresco/service/cmr/view/AVMZipExporterService.java delete mode 100644 source/java/org/alfresco/wcm/actions/WCMSandboxRevertSnapshotAction.java delete mode 100644 source/java/org/alfresco/wcm/actions/WCMSandboxSubmitAction.java delete mode 100644 source/java/org/alfresco/wcm/actions/WCMSandboxUndoAction.java delete mode 100644 source/java/org/alfresco/wcm/asset/AssetInfo.java delete mode 100644 source/java/org/alfresco/wcm/asset/AssetInfoImpl.java delete mode 100644 source/java/org/alfresco/wcm/asset/AssetService.java delete mode 100644 source/java/org/alfresco/wcm/asset/AssetServiceImpl.java delete mode 100644 source/java/org/alfresco/wcm/preview/AbstractPreviewURIServiceProvider.java delete mode 100644 source/java/org/alfresco/wcm/preview/NullPreviewURIService.java delete mode 100644 source/java/org/alfresco/wcm/preview/PreviewContext.java delete mode 100644 source/java/org/alfresco/wcm/preview/PreviewURIService.java delete mode 100644 source/java/org/alfresco/wcm/preview/PreviewURIServiceImpl.java delete mode 100644 source/java/org/alfresco/wcm/preview/PreviewURIServiceProvider.java delete mode 100644 source/java/org/alfresco/wcm/preview/PreviewURIServiceRegistry.java delete mode 100644 source/java/org/alfresco/wcm/preview/PreviewURIServiceRegistryImpl.java delete mode 100644 source/java/org/alfresco/wcm/preview/URITemplatePreviewURIService.java delete mode 100644 source/java/org/alfresco/wcm/preview/VirtualisationServerPreviewURIService.java delete mode 100644 source/java/org/alfresco/wcm/sandbox/SandboxConstants.java delete mode 100644 source/java/org/alfresco/wcm/sandbox/SandboxFactory.java delete mode 100644 source/java/org/alfresco/wcm/sandbox/SandboxInfo.java delete mode 100644 source/java/org/alfresco/wcm/sandbox/SandboxInfoImpl.java delete mode 100644 source/java/org/alfresco/wcm/sandbox/SandboxService.java delete mode 100644 source/java/org/alfresco/wcm/sandbox/SandboxServiceImpl.java delete mode 100644 source/java/org/alfresco/wcm/sandbox/SandboxVersion.java delete mode 100644 source/java/org/alfresco/wcm/sandbox/SandboxVersionImpl.java delete mode 100644 source/java/org/alfresco/wcm/sandbox/script/Asset.java delete mode 100644 source/java/org/alfresco/wcm/sandbox/script/Sandbox.java delete mode 100644 source/java/org/alfresco/wcm/util/WCMUtil.java delete mode 100644 source/java/org/alfresco/wcm/util/WCMWorkflowUtil.java delete mode 100644 source/java/org/alfresco/wcm/webproject/WebProjectInfo.java delete mode 100644 source/java/org/alfresco/wcm/webproject/WebProjectInfoImpl.java delete mode 100644 source/java/org/alfresco/wcm/webproject/WebProjectService.java delete mode 100644 source/java/org/alfresco/wcm/webproject/WebProjectServiceImpl.java delete mode 100644 source/java/org/alfresco/wcm/webproject/script/WebProject.java delete mode 100644 source/java/org/alfresco/wcm/webproject/script/WebProjects.java diff --git a/config/alfresco-global.properties.sample b/config/alfresco-global.properties.sample index cd2cf3cbd2..e8be6393b7 100644 --- a/config/alfresco-global.properties.sample +++ b/config/alfresco-global.properties.sample @@ -157,11 +157,8 @@ alfresco.rmi.services.host=0.0.0.0 # # Select 0 to use a random unused port. # -#avm.rmi.service.port=50501 -#avmsync.rmi.service.port=50502 #attribute.rmi.service.port=50503 #authentication.rmi.service.port=50504 #repo.rmi.service.port=50505 #action.rmi.service.port=50506 -#wcm-deployment-receiver.rmi.service.port=50507 #monitor.rmi.service.port=50508 \ No newline at end of file diff --git a/config/alfresco/avm-console-context.xml b/config/alfresco/avm-console-context.xml deleted file mode 100644 index facf41e22d..0000000000 --- a/config/alfresco/avm-console-context.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - config/alfresco/avm-console.properties - - - - false - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/alfresco/avm-console.properties b/config/alfresco/avm-console.properties deleted file mode 100644 index 88bc7b85e1..0000000000 --- a/config/alfresco/avm-console.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Database specifics. -db.driver=org.gjt.mm.mysql.Driver -db.url=jdbc:mysql://127.0.0.1/avm -db.username=root -db.password= -db.pool.initial=4 -db.pool.max=32 -# Hibernate properties -hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect -hibernate.current_session_context_class=thread -hibernate.connection.isolation=2 -hibernate.default_batch_fetch_size=16 -hibernate.jdbc.batch_versioned_data=true -hibernate.cache.use_second_level_cache=true -hibernate.hbm2ddl.auto=update -# AVM specific properties. diff --git a/config/alfresco/avm-services-context.xml b/config/alfresco/avm-services-context.xml deleted file mode 100644 index a50b7967fd..0000000000 --- a/config/alfresco/avm-services-context.xml +++ /dev/null @@ -1,267 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1000 - - - 50 - - - - - - - - - ${orphanReaper.lockRefreshTime} - - - ${orphanReaper.lockTimeOut} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .*/#[^/]* - - - - - - - - .o - .bak - .tmp - ~ - - - - - - - - - - - - - - - - - admin - - - jbpm$wcmwf:changerequest - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - workspace://SpacesStore - - - - - - - - - - - - - - - - - - - - ${wcm.rename.max.time.milliseconds} - - - - diff --git a/config/alfresco/avm-test-context.xml b/config/alfresco/avm-test-context.xml deleted file mode 100644 index 7a92555358..0000000000 --- a/config/alfresco/avm-test-context.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - diff --git a/config/alfresco/bootstrap/customMessagesSpace.xml b/config/alfresco/bootstrap/customMessagesSpace.xml index 0417b57a47..c18b45c1b2 100644 --- a/config/alfresco/bootstrap/customMessagesSpace.xml +++ b/config/alfresco/bootstrap/customMessagesSpace.xml @@ -1,6 +1,6 @@ - diff --git a/config/alfresco/bootstrap/customWebClientExtensionSpace.xml b/config/alfresco/bootstrap/customWebClientExtensionSpace.xml index 3a9f5bcb5f..6b5351aa89 100644 --- a/config/alfresco/bootstrap/customWebClientExtensionSpace.xml +++ b/config/alfresco/bootstrap/customWebClientExtensionSpace.xml @@ -1,6 +1,6 @@ - diff --git a/config/alfresco/bootstrap/webScripts.xml b/config/alfresco/bootstrap/webScripts.xml index 19d6422120..a7da5c6b9a 100644 --- a/config/alfresco/bootstrap/webScripts.xml +++ b/config/alfresco/bootstrap/webScripts.xml @@ -1,6 +1,6 @@ - + diff --git a/config/alfresco/bootstrap/webScriptsExtensions.xml b/config/alfresco/bootstrap/webScriptsExtensions.xml index 69c99c9bff..18c9470c74 100644 --- a/config/alfresco/bootstrap/webScriptsExtensions.xml +++ b/config/alfresco/bootstrap/webScriptsExtensions.xml @@ -1,6 +1,6 @@ - + diff --git a/config/alfresco/bootstrap/webScriptsReadme.xml b/config/alfresco/bootstrap/webScriptsReadme.xml index 195dfc3b39..c804ce12bd 100644 --- a/config/alfresco/bootstrap/webScriptsReadme.xml +++ b/config/alfresco/bootstrap/webScriptsReadme.xml @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ /app:company_home/app:dictionary/app:content_templates/cm:readme.ftl - + diff --git a/config/alfresco/caches.properties b/config/alfresco/caches.properties index fa77849bb0..f1b0dd2a5a 100644 --- a/config/alfresco/caches.properties +++ b/config/alfresco/caches.properties @@ -268,49 +268,6 @@ cache.ticketsCache.eviction-policy=LRU cache.ticketsCache.eviction-percentage=25 cache.ticketsCache.merge-policy=hz.ADD_NEW_ENTRY -cache.avmEntitySharedCache.tx.maxItems=5000 -cache.avmEntitySharedCache.maxItems=5000 -cache.avmEntitySharedCache.timeToLiveSeconds=0 -cache.avmEntitySharedCache.maxIdleSeconds=0 -cache.avmEntitySharedCache.cluster.type=fully-distributed -cache.avmEntitySharedCache.backup-count=1 -cache.avmEntitySharedCache.eviction-policy=LRU -cache.avmEntitySharedCache.eviction-percentage=25 -cache.avmEntitySharedCache.merge-policy=hz.ADD_NEW_ENTRY - -cache.avmVersionRootEntitySharedCache.maxItems=1000 -cache.avmVersionRootEntitySharedCache.timeToLiveSeconds=0 -cache.avmVersionRootEntitySharedCache.maxIdleSeconds=0 -cache.avmVersionRootEntitySharedCache.cluster.type=fully-distributed -cache.avmVersionRootEntitySharedCache.backup-count=1 -cache.avmVersionRootEntitySharedCache.eviction-policy=LRU -cache.avmVersionRootEntitySharedCache.eviction-percentage=25 -cache.avmVersionRootEntitySharedCache.merge-policy=hz.ADD_NEW_ENTRY - -cache.avmNodeSharedCache.tx.maxItems=5000 -cache.avmNodeSharedCache.maxItems=5000 -cache.avmNodeSharedCache.timeToLiveSeconds=0 -cache.avmNodeSharedCache.maxIdleSeconds=0 -cache.avmNodeSharedCache.cluster.type=fully-distributed -cache.avmNodeSharedCache.backup-count=1 -cache.avmNodeSharedCache.eviction-policy=LRU -cache.avmNodeSharedCache.eviction-percentage=25 -cache.avmNodeSharedCache.merge-policy=hz.ADD_NEW_ENTRY - -cache.avmNodeAspectsSharedCache.tx.maxItems=5000 -cache.avmNodeAspectsSharedCache.maxItems=5000 -cache.avmNodeAspectsSharedCache.timeToLiveSeconds=0 -cache.avmNodeAspectsSharedCache.maxIdleSeconds=0 -cache.avmNodeAspectsSharedCache.cluster.type=fully-distributed -cache.avmNodeAspectsSharedCache.backup-count=1 -cache.avmNodeAspectsSharedCache.eviction-policy=LRU -cache.avmNodeAspectsSharedCache.eviction-percentage=25 -cache.avmNodeAspectsSharedCache.merge-policy=hz.ADD_NEW_ENTRY - -cache.avmStoreSharedCache.tx.maxItems=1000 - -cache.avmVersionRootEntityCache.tx.maxItems=100 - cache.authorityEntitySharedCache.tx.maxItems=50000 cache.webServicesQuerySessionSharedCache.tx.maxItems=50 diff --git a/config/alfresco/content-services-context.xml b/config/alfresco/content-services-context.xml index 31e93c2f1f..72b8566c04 100644 --- a/config/alfresco/content-services-context.xml +++ b/config/alfresco/content-services-context.xml @@ -108,11 +108,6 @@ - @@ -156,9 +151,6 @@ - - - diff --git a/config/alfresco/dao/dao-context.xml b/config/alfresco/dao/dao-context.xml index 3512ba83c3..08fa7cefb7 100644 --- a/config/alfresco/dao/dao-context.xml +++ b/config/alfresco/dao/dao-context.xml @@ -223,43 +223,6 @@ - - - - @@ -273,31 +236,10 @@ - - - @@ -305,9 +247,6 @@ - @@ -322,15 +261,6 @@ - - diff --git a/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-AvmTables.sql b/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-AvmTables.sql deleted file mode 100644 index 021df851c3..0000000000 --- a/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-AvmTables.sql +++ /dev/null @@ -1,248 +0,0 @@ --- --- Title: Create AVM tables --- Database: MySQL InnoDB --- Since: V3.2.0 Schema 3002 --- Author: janv --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - - create table avm_aspects ( - node_id bigint not null, - qname_id bigint not null, - primary key (node_id, qname_id) - ) ENGINE=InnoDB; - - create table avm_child_entries ( - parent_id bigint not null, - lc_name varchar(160) not null, - name varchar(160) not null, - child_id bigint not null, - primary key (parent_id, lc_name) - ) ENGINE=InnoDB; - - create table avm_history_links ( - ancestor bigint not null, - descendent bigint not null, - primary key (ancestor, descendent) - ) ENGINE=InnoDB; - - create table avm_merge_links ( - mfrom bigint not null, - mto bigint not null, - primary key (mfrom, mto) - ) ENGINE=InnoDB; - - create table avm_node_properties ( - node_id bigint not null, - actual_type_n integer not null, - persisted_type_n integer not null, - multi_valued bit not null, - boolean_value bit, - long_value bigint, - float_value float, - double_value double precision, - string_value text, - serializable_value blob, - qname_id bigint not null, - primary key (node_id, qname_id) - ) ENGINE=InnoDB; - - create table avm_nodes ( - id bigint not null auto_increment, - class_type varchar(20) not null, - vers bigint not null, - version_id integer not null, - guid varchar(36), - creator varchar(255) not null, - owner varchar(255) not null, - lastModifier varchar(255) not null, - createDate bigint not null, - modDate bigint not null, - accessDate bigint not null, - is_root bit, - store_new_id bigint, - acl_id bigint, - deletedType integer, - layer_id bigint, - indirection text, - indirection_version integer, - primary_indirection bit, - opacity bit, - content_url varchar(128), - mime_type varchar(100), - encoding varchar(16), - length bigint, - primary key (id) - ) ENGINE=InnoDB; - - create table avm_store_properties ( - id bigint not null auto_increment, - avm_store_id bigint, - qname_id bigint not null, - actual_type_n integer not null, - persisted_type_n integer not null, - multi_valued bit not null, - boolean_value bit, - long_value bigint, - float_value float, - double_value double precision, - string_value text, - serializable_value blob, - primary key (id) - ) ENGINE=InnoDB; - - create table avm_stores ( - id bigint not null auto_increment, - vers bigint not null, - name varchar(255) unique, - next_version_id integer not null, - current_root_id bigint, - acl_id bigint, - primary key (id) - ) ENGINE=InnoDB; - - create table avm_version_layered_node_entry ( - version_root_id bigint not null, - md5sum varchar(32) not null, - path text, - primary key (version_root_id, md5sum) - ) ENGINE=InnoDB; - - create table avm_version_roots ( - id bigint not null auto_increment, - version_id integer not null, - avm_store_id bigint not null, - create_date bigint not null, - creator varchar(255) not null, - root_id bigint not null, - tag varchar(255), - description text, - primary key (id), - constraint unique index idx_avm_vr_uq (avm_store_id, version_id) - ) ENGINE=InnoDB; - - alter table avm_aspects - add index fk_avm_nasp_n (node_id), - add constraint fk_avm_nasp_n - foreign key (node_id) - references avm_nodes (id); - - alter table avm_child_entries - add index fk_avm_ce_child (child_id), - add constraint fk_avm_ce_child - foreign key (child_id) - references avm_nodes (id); - - alter table avm_child_entries - add index fk_avm_ce_parent (parent_id), - add constraint fk_avm_ce_parent - foreign key (parent_id) - references avm_nodes (id); - - alter table avm_history_links - add index fk_avm_hl_desc (descendent), - add constraint fk_avm_hl_desc - foreign key (descendent) - references avm_nodes (id); - - alter table avm_history_links - add index fk_avm_hl_ancestor (ancestor), - add constraint fk_avm_hl_ancestor - foreign key (ancestor) - references avm_nodes (id); - - alter table avm_merge_links - add index fk_avm_ml_from (mfrom), - add constraint fk_avm_ml_from - foreign key (mfrom) - references avm_nodes (id); - - alter table avm_merge_links - add index fk_avm_ml_to (mto), - add constraint fk_avm_ml_to - foreign key (mto) - references avm_nodes (id); - - alter table avm_node_properties - add index fk_avm_nprop_n (node_id), - add constraint fk_avm_nprop_n - foreign key (node_id) - references avm_nodes (id); - - create index idx_avm_n_pi on avm_nodes (primary_indirection); - - alter table avm_nodes - add index fk_avm_n_acl (acl_id), - add constraint fk_avm_n_acl - foreign key (acl_id) - references alf_access_control_list (id); - - alter table avm_nodes - add index fk_avm_n_store (store_new_id), - add constraint fk_avm_n_store - foreign key (store_new_id) - references avm_stores (id); - - alter table avm_store_properties - add index fk_avm_sprop_store (avm_store_id), - add constraint fk_avm_sprop_store - foreign key (avm_store_id) - references avm_stores (id); - - alter table avm_stores - add index fk_avm_s_root (current_root_id), - add constraint fk_avm_s_root - foreign key (current_root_id) - references avm_nodes (id); - - alter table avm_stores - add index fk_avm_s_acl (acl_id), - add constraint fk_avm_s_acl - foreign key (acl_id) - references alf_access_control_list (id); - - alter table avm_version_layered_node_entry - add index fk_avm_vlne_vr (version_root_id), - add constraint fk_avm_vlne_vr - foreign key (version_root_id) - references avm_version_roots (id); - - create index idx_avm_vr_version on avm_version_roots (version_id); - - alter table avm_version_roots - add index fk_avm_vr_store (avm_store_id), - add constraint fk_avm_vr_store - foreign key (avm_store_id) - references avm_stores (id); - - alter table avm_version_roots - add index fk_avm_vr_root (root_id), - add constraint fk_avm_vr_root - foreign key (root_id) - references avm_nodes (id); - -CREATE INDEX fk_avm_nasp_qn ON avm_aspects (qname_id); -ALTER TABLE avm_aspects ADD CONSTRAINT fk_avm_nasp_qn FOREIGN KEY (qname_id) REFERENCES alf_qname (id); - -CREATE INDEX fk_avm_nprop_qn ON avm_node_properties (qname_id); -ALTER TABLE avm_node_properties ADD CONSTRAINT fk_avm_nprop_qn FOREIGN KEY (qname_id) REFERENCES alf_qname (id); - -CREATE INDEX fk_avm_sprop_qname ON avm_store_properties (qname_id); -ALTER TABLE avm_store_properties ADD CONSTRAINT fk_avm_sprop_qname FOREIGN KEY (qname_id) REFERENCES alf_qname (id); - -CREATE INDEX idx_avm_hl_revpk ON avm_history_links (descendent, ancestor); - -CREATE INDEX idx_avm_ce_lc_name ON avm_child_entries (lc_name, parent_id); - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.2-AvmTables'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.2-AvmTables', 'Manually executed script upgrade V3.2: AVM Tables', - 0, 3001, -1, 3002, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); \ No newline at end of file diff --git a/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-AVM.xml b/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-AVM.xml deleted file mode 100644 index b9ff7c57fa..0000000000 --- a/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-AVM.xml +++ /dev/null @@ -1,742 +0,0 @@ - - - - - - .* - - - - - - - - - bigint - false - false - - - bigint - false - false - - - - - node_id - qname_id - - - - - qname_id - alf_qname - id - - - node_id - avm_nodes - id - - - - - - node_id - - - - - qname_id - - - -
- - - - bigint - false - false - - - varchar(160) - false - false - - - varchar(160) - false - false - - - bigint - false - false - - - - - lc_name - parent_id - - - - - parent_id - avm_nodes - id - - - child_id - avm_nodes - id - - - - - - child_id - - - - - parent_id - - - - - lc_name - parent_id - - - -
- - - - bigint - false - false - - - bigint - false - false - - - - - ancestor - descendent - - - - - ancestor - avm_nodes - id - - - descendent - avm_nodes - id - - - - - - descendent - - - - - ancestor - - - - - descendent - ancestor - - - -
- - - - bigint - false - false - - - bigint - false - false - - - - - mfrom - mto - - - - - mto - avm_nodes - id - - - mfrom - avm_nodes - id - - - - - - mfrom - - - - - mto - - - -
- - - - bigint - false - false - - - int - false - false - - - int - false - false - - - bit - false - false - - - bit - true - false - - - bigint - true - false - - - float - true - false - - - double - true - false - - - text - true - false - - - blob - true - false - - - bigint - false - false - - - - - node_id - qname_id - - - - - qname_id - alf_qname - id - - - node_id - avm_nodes - id - - - - - - node_id - - - - - qname_id - - - -
- - - - bigint - false - true - - - varchar(20) - false - false - - - bigint - false - false - - - int - false - false - - - varchar(36) - true - false - - - varchar(255) - false - false - - - varchar(255) - false - false - - - varchar(255) - false - false - - - bigint - false - false - - - bigint - false - false - - - bigint - false - false - - - bit - true - false - - - bigint - true - false - - - bigint - true - false - - - int - true - false - - - bigint - true - false - - - text - true - false - - - int - true - false - - - bit - true - false - - - bit - true - false - - - varchar(128) - true - false - - - varchar(100) - true - false - - - varchar(16) - true - false - - - bigint - true - false - - - - - id - - - - - store_new_id - avm_stores - id - - - acl_id - alf_access_control_list - id - - - - - - primary_indirection - - - - - acl_id - - - - - store_new_id - - - -
- - - - bigint - false - true - - - bigint - true - false - - - bigint - false - false - - - int - false - false - - - int - false - false - - - bit - false - false - - - bit - true - false - - - bigint - true - false - - - float - true - false - - - double - true - false - - - text - true - false - - - blob - true - false - - - - - id - - - - - qname_id - alf_qname - id - - - avm_store_id - avm_stores - id - - - - - - avm_store_id - - - - - qname_id - - - -
- - - - bigint - false - true - - - bigint - false - false - - - varchar(255) - true - false - - - int - false - false - - - bigint - true - false - - - bigint - true - false - - - - - id - - - - - acl_id - alf_access_control_list - id - - - current_root_id - avm_nodes - id - - - - - - name - - - - - current_root_id - - - - - acl_id - - - -
- - - - bigint - false - false - - - varchar(32) - false - false - - - text - true - false - - - - - md5sum - version_root_id - - - - - version_root_id - avm_version_roots - id - - - - - - version_root_id - - - -
- - - - bigint - false - true - - - int - false - false - - - bigint - false - false - - - bigint - false - false - - - varchar(255) - false - false - - - bigint - false - false - - - varchar(255) - true - false - - - text - true - false - - - - - id - - - - - root_id - avm_nodes - id - - - avm_store_id - avm_stores - id - - - - - - version_id - - - - - avm_store_id - - - - - root_id - - - - - avm_store_id - version_id - - - -
-
-
diff --git a/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-AvmTables.sql b/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-AvmTables.sql deleted file mode 100644 index fc83cfc996..0000000000 --- a/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-AvmTables.sql +++ /dev/null @@ -1,255 +0,0 @@ --- --- Title: Create AVM tables --- Database: PostgreSql --- Since: V3.2.0 Schema 3002 --- Author: Pavel Yurkevich --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - - create table avm_aspects ( - node_id INT8 not null, - qname_id INT8 not null, - primary key (node_id, qname_id) - ); - - create table avm_child_entries ( - parent_id INT8 not null, - lc_name varchar(160) not null, - name varchar(160) not null, - child_id INT8 not null, - primary key (parent_id, lc_name) - ); - - create table avm_history_links ( - ancestor INT8 not null, - descendent INT8 not null, - primary key (ancestor, descendent) - ); - - create table avm_merge_links ( - mfrom INT8 not null, - mto INT8 not null, - primary key (mfrom, mto) - ); - - create table avm_node_properties ( - node_id INT8 not null, - actual_type_n INT4 not null, - persisted_type_n INT4 not null, - multi_valued BOOL not null, - boolean_value BOOL, - long_value INT8, - float_value FLOAT4, - double_value FLOAT8, - string_value VARCHAR(1024), - serializable_value BYTEA, - qname_id INT8 not null, - primary key (node_id, qname_id) - ); - - create sequence avm_nodes_seq start with 1 increment by 1; - create table avm_nodes ( - id INT8 not null, - class_type varchar(20) not null, - vers INT8 not null, - version_id INT4 not null, - guid varchar(36), - creator varchar(255) not null, - owner varchar(255) not null, - lastModifier varchar(255) not null, - createDate INT8 not null, - modDate INT8 not null, - accessDate INT8 not null, - is_root BOOL, - store_new_id INT8, - acl_id INT8, - deletedType INT4, - layer_id INT8, - indirection VARCHAR(1024), - indirection_version INT4, - primary_indirection BOOL, - opacity BOOL, - content_url varchar(128), - mime_type varchar(100), - encoding varchar(16), - length INT8, - primary key (id) - ); - - create sequence avm_store_properties_seq start with 1 increment by 1; - create table avm_store_properties ( - id INT8 not null, - avm_store_id INT8, - qname_id INT8 not null, - actual_type_n INT4 not null, - persisted_type_n INT4 not null, - multi_valued BOOL not null, - boolean_value BOOL, - long_value INT8, - float_value FLOAT4, - double_value FLOAT8, - string_value VARCHAR(1024), - serializable_value BYTEA, - primary key (id) - ); - - create sequence avm_stores_seq start with 1 increment by 1; - create table avm_stores ( - id INT8 not null, - vers INT8 not null, - name varchar(255) unique, - next_version_id INT4 not null, - current_root_id INT8, - acl_id INT8, - primary key (id) - ); - - create table avm_version_layered_node_entry ( - version_root_id INT8 not null, - md5sum varchar(32) not null, - path VARCHAR(1024), - primary key (version_root_id, md5sum) - ); - - create sequence avm_version_roots_seq start with 1 increment by 1; - create table avm_version_roots ( - id INT8 not null, - version_id INT4 not null, - avm_store_id INT8 not null, - create_date INT8 not null, - creator varchar(255) not null, - root_id INT8 not null, - tag varchar(255), - description VARCHAR(1024), - primary key (id) - ); - - alter table avm_version_roots - add constraint idx_avm_vr_uq - unique (avm_store_id, version_id); - - alter table avm_aspects - add constraint fk_avm_nasp_n - foreign key (node_id) - references avm_nodes (id); - create index fk_avm_nasp_n on avm_aspects(node_id); - - alter table avm_child_entries - add constraint fk_avm_ce_child - foreign key (child_id) - references avm_nodes (id); - create index fk_avm_ce_child on avm_child_entries(child_id); - - alter table avm_child_entries - add constraint fk_avm_ce_parent - foreign key (parent_id) - references avm_nodes (id); - create index fk_avm_ce_parent on avm_child_entries(parent_id); - - alter table avm_history_links - add constraint fk_avm_hl_desc - foreign key (descendent) - references avm_nodes (id); - create index fk_avm_hl_desc on avm_history_links(descendent); - - alter table avm_history_links - add constraint fk_avm_hl_ancestor - foreign key (ancestor) - references avm_nodes (id); - create index fk_avm_hl_ancestor on avm_history_links(ancestor); - - alter table avm_merge_links - add constraint fk_avm_ml_from - foreign key (mfrom) - references avm_nodes (id); - create index fk_avm_ml_from on avm_merge_links(mfrom); - - alter table avm_merge_links - add constraint fk_avm_ml_to - foreign key (mto) - references avm_nodes (id); - create index fk_avm_ml_to on avm_merge_links(mto); - - alter table avm_node_properties - add constraint fk_avm_nprop_n - foreign key (node_id) - references avm_nodes (id); - create index fk_avm_nprop_n on avm_node_properties(node_id); - - create index idx_avm_n_pi on avm_nodes (primary_indirection); - - alter table avm_nodes - add constraint fk_avm_n_acl - foreign key (acl_id) - references alf_access_control_list (id); - create index fk_avm_n_acl on avm_nodes(acl_id); - - alter table avm_nodes - add constraint fk_avm_n_store - foreign key (store_new_id) - references avm_stores (id); - create index fk_avm_n_store on avm_nodes(store_new_id); - - alter table avm_store_properties - add constraint fk_avm_sprop_store - foreign key (avm_store_id) - references avm_stores (id); - create index fk_avm_sprop_store on avm_store_properties(avm_store_id); - - alter table avm_stores - add constraint fk_avm_s_root - foreign key (current_root_id) - references avm_nodes (id); - create index fk_avm_s_root on avm_stores(current_root_id); - - alter table avm_stores - add constraint fk_avm_s_acl - foreign key (acl_id) - references alf_access_control_list (id); - create index fk_avm_s_acl on avm_stores(acl_id); - - alter table avm_version_layered_node_entry - add constraint fk_avm_vlne_vr - foreign key (version_root_id) - references avm_version_roots (id); - create index fk_avm_vlne_vr on avm_version_layered_node_entry(version_root_id); - - create index idx_avm_vr_version on avm_version_roots (version_id); - - alter table avm_version_roots - add constraint fk_avm_vr_store - foreign key (avm_store_id) - references avm_stores (id); - create index fk_avm_vr_store on avm_version_roots(avm_store_id); - - alter table avm_version_roots - add constraint fk_avm_vr_root - foreign key (root_id) - references avm_nodes (id); - create index fk_avm_vr_root on avm_version_roots(root_id); - -CREATE INDEX fk_avm_nasp_qn ON avm_aspects (qname_id); -ALTER TABLE avm_aspects ADD CONSTRAINT fk_avm_nasp_qn FOREIGN KEY (qname_id) REFERENCES alf_qname (id); - -CREATE INDEX fk_avm_nprop_qn ON avm_node_properties (qname_id); -ALTER TABLE avm_node_properties ADD CONSTRAINT fk_avm_nprop_qn FOREIGN KEY (qname_id) REFERENCES alf_qname (id); - -CREATE INDEX fk_avm_sprop_qname ON avm_store_properties (qname_id); -ALTER TABLE avm_store_properties ADD CONSTRAINT fk_avm_sprop_qname FOREIGN KEY (qname_id) REFERENCES alf_qname (id); - -CREATE INDEX idx_avm_hl_revpk ON avm_history_links (descendent, ancestor); - -CREATE INDEX idx_avm_ce_lc_name ON avm_child_entries (lc_name, parent_id); - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.2-AvmTables'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.2-AvmTables', 'Manually executed script upgrade V3.2: AVM Tables', - 0, 3001, -1, 3002, null, 'UNKOWN', TRUE, TRUE, 'Script completed' - ); \ No newline at end of file diff --git a/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-AVM.xml b/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-AVM.xml deleted file mode 100644 index 614063e56b..0000000000 --- a/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-AVM.xml +++ /dev/null @@ -1,753 +0,0 @@ - - - - - - .* - - - - - - - - - - - - - int8 - false - false - - - int8 - false - false - - - - - node_id - qname_id - - - - - qname_id - alf_qname - id - - - node_id - avm_nodes - id - - - - - - node_id - - - - - qname_id - - - -
- - - - int8 - false - false - - - varchar(160) - false - false - - - varchar(160) - false - false - - - int8 - false - false - - - - - - - .* - - - - - parent_id - lc_name - - - - - parent_id - avm_nodes - id - - - child_id - avm_nodes - id - - - - - - child_id - - - - - parent_id - - - - - lc_name - parent_id - - - -
- - - - int8 - false - false - - - int8 - false - false - - - - - ancestor - descendent - - - - - ancestor - avm_nodes - id - - - descendent - avm_nodes - id - - - - - - ancestor - - - - - descendent - - - - - descendent - ancestor - - - -
- - - - int8 - false - false - - - int8 - false - false - - - - - mfrom - mto - - - - - mto - avm_nodes - id - - - mfrom - avm_nodes - id - - - - - - mfrom - - - - - mto - - - -
- - - - int8 - false - false - - - int4 - false - false - - - int4 - false - false - - - bool - false - false - - - bool - true - false - - - int8 - true - false - - - float4 - true - false - - - float8 - true - false - - - varchar(1024) - true - false - - - bytea - true - false - - - int8 - false - false - - - - - node_id - qname_id - - - - - qname_id - alf_qname - id - - - node_id - avm_nodes - id - - - - - - node_id - - - - - qname_id - - - -
- - - - int8 - false - false - - - varchar(20) - false - false - - - int8 - false - false - - - int4 - false - false - - - varchar(36) - true - false - - - varchar(255) - false - false - - - varchar(255) - false - false - - - varchar(255) - false - false - - - int8 - false - false - - - int8 - false - false - - - int8 - false - false - - - bool - true - false - - - int8 - true - false - - - int8 - true - false - - - int4 - true - false - - - int8 - true - false - - - varchar(1024) - true - false - - - int4 - true - false - - - bool - true - false - - - bool - true - false - - - varchar(128) - true - false - - - varchar(100) - true - false - - - varchar(16) - true - false - - - int8 - true - false - - - - - id - - - - - acl_id - alf_access_control_list - id - - - store_new_id - avm_stores - id - - - - - - acl_id - - - - - store_new_id - - - - - primary_indirection - - - -
- - - - int8 - false - false - - - int8 - true - false - - - int8 - false - false - - - int4 - false - false - - - int4 - false - false - - - bool - false - false - - - bool - true - false - - - int8 - true - false - - - float4 - true - false - - - float8 - true - false - - - varchar(1024) - true - false - - - bytea - true - false - - - - - id - - - - - qname_id - alf_qname - id - - - avm_store_id - avm_stores - id - - - - - - qname_id - - - - - avm_store_id - - - -
- - - - int8 - false - false - - - int8 - false - false - - - varchar(255) - true - false - - - int4 - false - false - - - int8 - true - false - - - int8 - true - false - - - - - id - - - - - acl_id - alf_access_control_list - id - - - current_root_id - avm_nodes - id - - - - - - name - - - - - acl_id - - - - - current_root_id - - - -
- - - - int8 - false - false - - - varchar(32) - false - false - - - varchar(1024) - true - false - - - - - version_root_id - md5sum - - - - - version_root_id - avm_version_roots - id - - - - - - version_root_id - - - -
- - - - int8 - false - false - - - int4 - false - false - - - int8 - false - false - - - int8 - false - false - - - varchar(255) - false - false - - - int8 - false - false - - - varchar(255) - true - false - - - varchar(1024) - true - false - - - - - id - - - - - root_id - avm_nodes - id - - - avm_store_id - avm_stores - id - - - - - - root_id - - - - - avm_store_id - - - - - avm_store_id - version_id - - - - - version_id - - - -
-
-
diff --git a/config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.Dialect/remove-AVM-issuer.sql b/config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.Dialect/remove-AVM-issuer.sql deleted file mode 100644 index 5a9da842ef..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.Dialect/remove-AVM-issuer.sql +++ /dev/null @@ -1,26 +0,0 @@ --- --- Title: Upgrade to V3.2 - Remove AVM Issuer --- Database: Generic --- Since: V3.2 schema 2008 --- Author: janv --- --- remove AVM node issuer --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - --- drop issuer table - -drop table avm_issuer_ids; - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.2-Remove-AVM-Issuer'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.2-Remove-AVM-Issuer', 'Manually executed script upgrade V3.2 to remove AVM Issuer', - 0, 2007, -1, 2008, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); diff --git a/config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.MySQLInnoDBDialect/modify-AVM-mimetype.sql b/config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.MySQLInnoDBDialect/modify-AVM-mimetype.sql deleted file mode 100644 index 1f7d4365b3..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.MySQLInnoDBDialect/modify-AVM-mimetype.sql +++ /dev/null @@ -1,24 +0,0 @@ --- --- Title: Upgrade to V3.2 - modify AVM mimetype --- Database: MySQL --- Since: V3.2 schema 2017 --- Author: janv --- --- modify AVM mimetype (increase column size) --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - -ALTER TABLE avm_nodes MODIFY mime_type VARCHAR(100); - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.2-Modify-AVM-MimeType'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.2-Modify-AVM-MimeType', 'Manually executed script upgrade V3.2 to modify AVM mimetype', - 0, 2016, -1, 2017, null, 'UNKOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); diff --git a/config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.MySQLInnoDBDialect/remove-AVM-issuer.sql b/config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.MySQLInnoDBDialect/remove-AVM-issuer.sql deleted file mode 100644 index cb5d363949..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.MySQLInnoDBDialect/remove-AVM-issuer.sql +++ /dev/null @@ -1,57 +0,0 @@ --- --- Title: Upgrade to V3.2 - Remove AVM Issuer --- Database: MySQL --- Since: V3.2 schema 2008 --- Author: janv --- --- remove AVM node issuer - replace with auto-increment id --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - --- ----------------------------- --- Enable auto-increment -- --- ----------------------------- - -insert into avm_nodes (id, class_type, vers, version_id, guid, creator, owner, lastModifier, createDate, modDate, accessDate, is_root, store_new_id, acl_id, deletedType, layer_id, indirection, indirection_version, primary_indirection, opacity, content_url, mime_type, encoding, length) -select -(select max(id)+1 from avm_nodes), -class_type, vers, version_id, guid, creator, owner, lastModifier, createDate, modDate, accessDate, is_root, store_new_id, acl_id, deletedType, layer_id, indirection, indirection_version, primary_indirection, opacity, content_url, mime_type, encoding, length -from avm_nodes where id = 0; - -update avm_aspects set node_id = (select max(id) from avm_nodes) where node_id = 0; - -update avm_child_entries set parent_id = (select max(id) from avm_nodes) where parent_id = 0; -update avm_child_entries set child_id = (select max(id) from avm_nodes) where child_id = 0; - -update avm_history_links set ancestor = (select max(id) from avm_nodes) where ancestor = 0; -update avm_history_links set descendent = (select max(id) from avm_nodes) where descendent = 0; - -update avm_merge_links set mfrom = (select max(id) from avm_nodes) where mfrom = 0; -update avm_merge_links set mto = (select max(id) from avm_nodes) where mto = 0; - -update avm_node_properties set node_id = (select max(id) from avm_nodes) where node_id = 0; - -update avm_stores set current_root_id = (select max(id) from avm_nodes) where current_root_id = 0; - -update avm_version_roots set root_id = (select max(id) from avm_nodes) where root_id = 0; - -delete from avm_nodes where id = 0; - -alter table avm_nodes modify column id bigint not null auto_increment; - --- drop issuer table - -drop table avm_issuer_ids; - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.2-Remove-AVM-Issuer'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.2-Remove-AVM-Issuer', 'Manually executed script upgrade V3.2 to remove AVM Issuer', - 0, 2007, -1, 2008, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); diff --git a/config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.PostgreSQLDialect/modify-AVM-mimetype.sql b/config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.PostgreSQLDialect/modify-AVM-mimetype.sql deleted file mode 100644 index 4e6526afa1..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.PostgreSQLDialect/modify-AVM-mimetype.sql +++ /dev/null @@ -1,24 +0,0 @@ --- --- Title: Upgrade to V3.2 - modify AVM mimetype --- Database: PostgreSQL --- Since: V3.2 schema 2017 --- Author: --- --- modify AVM mimetype (increase column size) --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - -ALTER TABLE avm_nodes ALTER COLUMN mime_type TYPE VARCHAR(100); - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.2-Modify-AVM-MimeType'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.2-Modify-AVM-MimeType', 'Manually executed script upgrade V3.2 to modify AVM mimetype', - 0, 2016, -1, 2017, null, 'UNKOWN', TRUE, TRUE, 'Script completed' - ); diff --git a/config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.PostgreSQLDialect/remove-AVM-issuer.sql b/config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.PostgreSQLDialect/remove-AVM-issuer.sql deleted file mode 100644 index d290de5864..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.2/org.hibernate.dialect.PostgreSQLDialect/remove-AVM-issuer.sql +++ /dev/null @@ -1,50 +0,0 @@ --- --- Title: Upgrade to V3.2 - Remove AVM Issuer --- Database: PostgreSQL --- Since: V3.2 schema 2008 --- Author: janv --- --- remove AVM node issuer - replace with sequence --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - --- update sequence, if needed - -SELECT SETVAL('hibernate_sequence', GREATEST((MAX(id)+1), NEXTVAL('hibernate_sequence'))) FROM avm_nodes; - -insert into avm_nodes (id, class_type, vers, version_id, guid, creator, owner, lastModifier, createDate, modDate, accessDate, is_root, store_new_id, acl_id, deletedType, layer_id, indirection, indirection_version, primary_indirection, opacity, content_url, mime_type, encoding, length) -select -(select max(id)+1 from avm_nodes), -class_type, vers, version_id, guid, creator, owner, lastModifier, createDate, modDate, accessDate, is_root, store_new_id, acl_id, deletedType, layer_id, indirection, indirection_version, primary_indirection, opacity, content_url, mime_type, encoding, length -from avm_nodes where id = 0; - -update avm_aspects set node_id = (select max(id) from avm_nodes) where node_id = 0; -update avm_child_entries set parent_id = (select max(id) from avm_nodes) where parent_id = 0; -update avm_child_entries set child_id = (select max(id) from avm_nodes) where child_id = 0; -update avm_history_links set ancestor = (select max(id) from avm_nodes) where ancestor = 0; -update avm_history_links set descendent = (select max(id) from avm_nodes) where descendent = 0; -update avm_merge_links set mfrom = (select max(id) from avm_nodes) where mfrom = 0; -update avm_merge_links set mto = (select max(id) from avm_nodes) where mto = 0; -update avm_node_properties set node_id = (select max(id) from avm_nodes) where node_id = 0; -update avm_stores set current_root_id = (select max(id) from avm_nodes) where current_root_id = 0; -update avm_version_roots set root_id = (select max(id) from avm_nodes) where root_id = 0; - -delete from avm_nodes where id = 0; - --- drop issuer table - -DROP TABLE avm_issuer_ids; - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.2-Remove-AVM-Issuer'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.2-Remove-AVM-Issuer', 'Manually executed script upgrade V3.2 to remove AVM Issuer', - 0, 2007, -1, 2008, null, 'UNKOWN', TRUE, TRUE, 'Script completed' - ); - diff --git a/config/alfresco/dbscripts/upgrade/3.3/org.hibernate.dialect.Dialect/fix-AVM-seqs.sql b/config/alfresco/dbscripts/upgrade/3.3/org.hibernate.dialect.Dialect/fix-AVM-seqs.sql deleted file mode 100755 index 9a066a9442..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.3/org.hibernate.dialect.Dialect/fix-AVM-seqs.sql +++ /dev/null @@ -1,23 +0,0 @@ --- --- Title: Upgrade to V3.4 - Create AVM sequences --- Database: Generic --- Since: V3.4 schema 4105 --- Author: unknown --- --- creates sequences for AVM tables --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.3-Fix-AVM-Seqs'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.3-Fix-AVM-Seqs', 'Manually executed script upgrade V3.3 to create AVM sequences', - 0, 4104, -1, 4105, null, 'UNKOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); diff --git a/config/alfresco/dbscripts/upgrade/3.3/org.hibernate.dialect.PostgreSQLDialect/fix-AVM-seqs.sql b/config/alfresco/dbscripts/upgrade/3.3/org.hibernate.dialect.PostgreSQLDialect/fix-AVM-seqs.sql deleted file mode 100755 index ac5e2c50c7..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.3/org.hibernate.dialect.PostgreSQLDialect/fix-AVM-seqs.sql +++ /dev/null @@ -1,33 +0,0 @@ --- --- Title: Upgrade to V3.4 - Create AVM sequences --- Database: PostgreSQL --- Since: V3.4 schema 4105 --- Author: unknown --- --- creates sequences for AVM tables --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - ---ASSIGN:hibernate_seq_next_value=value -SELECT NEXTVAL('hibernate_sequence') AS value; - -CREATE SEQUENCE avm_stores_seq START WITH ${hibernate_seq_next_value} INCREMENT BY 1; -- (optional) - -CREATE SEQUENCE avm_store_properties_seq START WITH ${hibernate_seq_next_value} INCREMENT BY 1; -- (optional) - -CREATE SEQUENCE avm_nodes_seq START WITH ${hibernate_seq_next_value} INCREMENT BY 1; -- (optional) - -CREATE SEQUENCE avm_version_roots_seq START WITH ${hibernate_seq_next_value} INCREMENT BY 1; -- (optional) - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.3-Fix-AVM-Seqs'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.3-Fix-AVM-Seqs', 'Manually executed script upgrade V3.3 to create AVM sequences', - 0, 4104, -1, 4105, null, 'UNKOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); diff --git a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/AVM-rename-dupes.sql b/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/AVM-rename-dupes.sql deleted file mode 100644 index 1e90dfaee7..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/AVM-rename-dupes.sql +++ /dev/null @@ -1,61 +0,0 @@ --- --- Title: Upgrade to V3.4 - AVM rename duplicates (if any) --- Database: Generic --- Since: V3.4 schema 4201 --- Author: janv --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - -CREATE table avm_tmp_child_entries AS -SELECT - ce.parent_id, ce.name, ce.child_id -FROM - avm_child_entries ce, - ( - SELECT - ce2.parent_id, LOWER(ce2.name) as lname, MAX(ce2.child_id) as max_child_id - FROM - avm_child_entries ce2 - GROUP BY - ce2.parent_id, LOWER(ce2.name) - HAVING - COUNT(*) > 1 - ) entities - WHERE - ce.parent_id = entities.parent_id AND - LOWER(ce.name) = entities.lname AND - ce.child_id != entities.max_child_id; - -UPDATE avm_child_entries ce - SET name = ce.name || '-renamed.duplicate.mark-' || ce.child_id || '.temp' -WHERE EXISTS - (SELECT - 1 - FROM - avm_tmp_child_entries tmp - WHERE - ce.parent_id = tmp.parent_id AND - ce.name = tmp.name AND - ce.child_id = tmp.child_id); - ---ASSIGN:update_count=value -SELECT - COUNT(*) as value -FROM - avm_tmp_child_entries; - - -DROP TABLE avm_tmp_child_entries; - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.4-AVM-rename-dupes'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.4-AVM-rename-dupes', 'Manually executed script upgrade V3.4', - 0, 4200, -1, 4201, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed: rows updated = ${update_count}' - ); diff --git a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/link-validation-metadata-removing.sql b/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/link-validation-metadata-removing.sql deleted file mode 100644 index bd42c3adf1..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/link-validation-metadata-removing.sql +++ /dev/null @@ -1,51 +0,0 @@ --- --- Title: Removing Link Validation related metadata --- Database: Generic --- Since: V3.4 --- Author: Dmitry Velichkevich --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- --- ALF-5185: WCM: upgrade / re-index can fail on 3.4 if link validation (now removed) was previously being used - --- --- Removing Link Validation Reports --- -DELETE -FROM - avm_store_properties -WHERE - qname_id in ( - SELECT - id - FROM - alf_qname - WHERE - local_name = '.link.validation.report' - ); - --- --- Removing Link Validation QName --- -DELETE -FROM - alf_qname -WHERE - local_name = '.link.validation.report'; - --- --- Record script finish --- -DELETE -FROM - alf_applied_patch -WHERE - id = 'patch.db-V3.4-RemovingLinkValidationMetadata'; - -INSERT INTO - alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) -VALUES ( - 'patch.db-V3.4-RemovingLinkValidationMetadata', 'Link Validation reports metadata removed V3.4', - 0, 4113, -1, 4114, null, 'UNKOWN', ${TRUE}, ${TRUE}, 'Script completed' -); diff --git a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.MySQLInnoDBDialect/AVM-index-child-entries-lower.sql b/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.MySQLInnoDBDialect/AVM-index-child-entries-lower.sql deleted file mode 100644 index 944fafa54b..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.MySQLInnoDBDialect/AVM-index-child-entries-lower.sql +++ /dev/null @@ -1,50 +0,0 @@ --- --- Title: Upgrade to V3.4 - AVM rename duplicates (if any) --- Database: MySQL --- Since: V3.4 schema 4209 --- Author: dward --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- -create table t_avm_child_entries ( - parent_id bigint not null, - lc_name varchar(160) not null, - name varchar(160) not null, - child_id bigint not null, - primary key (parent_id, lc_name) -) ENGINE=InnoDB; - ---FOREACH avm_child_entries.child_id system.upgrade.t_avm_child_entries.batchsize -INSERT INTO t_avm_child_entries (parent_id, lc_name, name, child_id) -SELECT parent_id, LOWER(name), name, child_id -FROM avm_child_entries -WHERE child_id >= ${LOWERBOUND} AND child_id <= ${UPPERBOUND}; - -DROP TABLE avm_child_entries; -ALTER TABLE t_avm_child_entries RENAME TO avm_child_entries; - -alter table avm_child_entries - add index fk_avm_ce_child (child_id), - add constraint fk_avm_ce_child - foreign key (child_id) - references avm_nodes (id); - -alter table avm_child_entries - add index fk_avm_ce_parent (parent_id), - add constraint fk_avm_ce_parent - foreign key (parent_id) - references avm_nodes (id); - -CREATE INDEX idx_avm_ce_lc_name ON avm_child_entries (lc_name, parent_id); - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.4-AVM-index-child-entries-lower'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.4-AVM-index-child-entries-lower', 'Manually executed script upgrade V3.4', - 0, 6002, -1, 6003, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); diff --git a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.PostgreSQLDialect/AVM-index-child-entries-lower.sql b/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.PostgreSQLDialect/AVM-index-child-entries-lower.sql deleted file mode 100644 index 0879d7de95..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.PostgreSQLDialect/AVM-index-child-entries-lower.sql +++ /dev/null @@ -1,51 +0,0 @@ --- --- Title: Upgrade to V3.4 - AVM rename duplicates (if any) --- Database: PostgreSQL --- Since: V3.4 schema 4209 --- Author: dward --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - -create table t_avm_child_entries ( - parent_id INT8 not null, - lc_name varchar(160) not null, - name varchar(160) not null, - child_id INT8 not null, - primary key (parent_id, lc_name) -); - ---FOREACH avm_child_entries.child_id system.upgrade.t_avm_child_entries.batchsize -INSERT INTO t_avm_child_entries (parent_id, lc_name, name, child_id) -SELECT parent_id, LOWER(name), name, child_id -FROM avm_child_entries -WHERE child_id >= ${LOWERBOUND} AND child_id <= ${UPPERBOUND}; - -DROP TABLE avm_child_entries; -ALTER TABLE t_avm_child_entries RENAME TO avm_child_entries; - -alter table avm_child_entries - add constraint fk_avm_ce_child - foreign key (child_id) - references avm_nodes (id); -create index fk_avm_ce_child on avm_child_entries(child_id); - -alter table avm_child_entries - add constraint fk_avm_ce_parent - foreign key (parent_id) - references avm_nodes (id); -create index fk_avm_ce_parent on avm_child_entries(parent_id); - -CREATE INDEX idx_avm_ce_lc_name ON avm_child_entries (lc_name, parent_id); - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.4-AVM-index-child-entries-lower'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.4-AVM-index-child-entries-lower', 'Manually executed script upgrade V3.4', - 0, 6002, -1, 6003, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); diff --git a/config/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/fix-AVM-seqs-order.sql b/config/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/fix-AVM-seqs-order.sql deleted file mode 100644 index 91b714403f..0000000000 --- a/config/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/fix-AVM-seqs-order.sql +++ /dev/null @@ -1,24 +0,0 @@ --- --- Title: DROP Indexes --- Database: Generic --- Since: V4.1 Schema 6030 --- Author: Alex Mukha --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- --- MNT-9275: When upgrading on Oracle RAC from version 3.2.2 to version 3.3 or higher, values returned by sequences are not ordered. - --- Used only for Oracle - --- --- Record script finish --- - -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V4.1-fix-AVM-seqs-order'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V4.1-fix-AVM-seqs-order', 'Manually executed script to set ORDER bit for sequences', - 0, 6030, -1, 6031, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); \ No newline at end of file diff --git a/config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/drop-AVM-index.sql b/config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/drop-AVM-index.sql deleted file mode 100644 index 5a6c05cce8..0000000000 --- a/config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/drop-AVM-index.sql +++ /dev/null @@ -1,26 +0,0 @@ --- --- Title: DROP unused IDX_AVM_VR_REVUQ index --- Database: InnoDB --- Since: V4.2 Schema 6031 --- Author: Alex Mukha --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- --- ALF-19487 : ORACLE: AVM: Schema difference is present after upgrade from 3.4.13/4.0.2/4.1.5 - -DROP INDEX idx_avm_vr_revuq ON avm_version_roots; -DROP INDEX version_id ON avm_version_roots; -ALTER TABLE avm_version_roots ADD CONSTRAINT UNIQUE INDEX idx_avm_vr_uq (avm_store_id, version_id); - --- --- Record script finish --- - -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V4.2-drop-AVM-index'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V4.2-drop-AVM-index', 'Manually executed script to drop unnecessary index', - 0, 6031, -1, 6032, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); \ No newline at end of file diff --git a/config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/drop-AVM-index.sql b/config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/drop-AVM-index.sql deleted file mode 100644 index 7b9baebab7..0000000000 --- a/config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/drop-AVM-index.sql +++ /dev/null @@ -1,27 +0,0 @@ --- --- Title: DROP unused IDX_AVM_VR_REVUQ index --- Database: PostgreSQL --- Since: V4.2 Schema 6031 --- Author: Alex Mukha --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- --- ALF-19487 : ORACLE: AVM: Schema difference is present after upgrade from 3.4.13/4.0.2/4.1.5 - -DROP INDEX idx_avm_vr_revuq; -ALTER TABLE avm_version_roots DROP CONSTRAINT avm_version_roots_version_id_avm_store_id_key; --(optional) -ALTER TABLE avm_version_roots DROP CONSTRAINT avm_version_roots_version_id_key; --(optional) -ALTER TABLE avm_version_roots ADD CONSTRAINT idx_avm_vr_uq UNIQUE (avm_store_id, version_id); - --- --- Record script finish --- - -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V4.2-drop-AVM-index'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V4.2-drop-AVM-index', 'Manually executed script to drop unnecessary index', - 0, 6031, -1, 6032, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); \ No newline at end of file diff --git a/config/alfresco/extension/asynchronous-avm-indexing-context.xml.sample b/config/alfresco/extension/asynchronous-avm-indexing-context.xml.sample deleted file mode 100644 index e057aec635..0000000000 --- a/config/alfresco/extension/asynchronous-avm-indexing-context.xml.sample +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - true - - - - SYNCHRONOUS - - - - - - ASYNCHRONOUS:TYPE:STAGING - UNINDEXED:TYPE:STAGING_PREVIEW - UNINDEXED:TYPE:AUTHOR - UNINDEXED:TYPE:AUTHOR_PREVIEW - UNINDEXED:TYPE:WORKFLOW - UNINDEXED:TYPE:WORKFLOW_PREVIEW - UNINDEXED:TYPE:AUTHOR_WORKFLOW - UNINDEXED:TYPE:AUTHOR_WORKFLOW_PREVIEW - ASYNCHRONOUS:NAME:avmAsynchronousTest - SYNCHRONOUS:NAME:.* - - - - \ No newline at end of file diff --git a/config/alfresco/extension/wcm-xml-metadata-extracter-context.xml.sample b/config/alfresco/extension/wcm-xml-metadata-extracter-context.xml.sample deleted file mode 100644 index 14f76a7728..0000000000 --- a/config/alfresco/extension/wcm-xml-metadata-extracter-context.xml.sample +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - http://www.alfresco.org/model/content/1.0 - cm:author - cm:title - cm:description - - - - - - - - - http://www.alfresco.org/model/forum/1.0 - /model/author/text() - /model/@name - /model/description/text() - /model/version/text() - - - - - - - - - - - - - - - - - - - - - - - - - - - EAGER - - - - - - - - - \ No newline at end of file diff --git a/config/alfresco/ibatis/alfresco-SqlMapConfig.xml b/config/alfresco/ibatis/alfresco-SqlMapConfig.xml index f7d2b71ca8..ca00ba9762 100644 --- a/config/alfresco/ibatis/alfresco-SqlMapConfig.xml +++ b/config/alfresco/ibatis/alfresco-SqlMapConfig.xml @@ -111,6 +111,7 @@ Inbound settings from iBatis + @@ -157,20 +158,6 @@ Inbound settings from iBatis - - - - - - - - - - - - - - diff --git a/config/alfresco/ibatis/ibatis-context.xml b/config/alfresco/ibatis/ibatis-context.xml index d1592f130e..dff4b882c9 100644 --- a/config/alfresco/ibatis/ibatis-context.xml +++ b/config/alfresco/ibatis/ibatis-context.xml @@ -35,12 +35,6 @@
- - - - - - diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/avm-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/avm-common-SqlMap.xml deleted file mode 100644 index f22ebbbea0..0000000000 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/avm-common-SqlMap.xml +++ /dev/null @@ -1,1212 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - insert into avm_stores (next_version_id, name, vers, current_root_id, acl_id) - values (#{version}, #{name}, 0, null, null) - - - - insert into avm_stores (id, next_version_id, name, vers, current_root_id, acl_id) - values (#{id}, #{version}, #{name}, 0, null, null) - - - - insert into avm_nodes (class_type, deletedType, version_id, vers, store_new_id, acl_id, guid, owner, creator, createDate, lastModifier, modDate, accessDate, is_root, layer_id, indirection, indirection_version, primary_indirection, opacity, content_url, mime_type, encoding, length) - values (#{classType}, #{deletedType}, #{version}, 0, #{storeNewId}, #{aclId}, #{guid}, #{owner}, #{creator}, #{createdDate}, #{modifier}, #{modifiedDate}, #{accessDate}, #{isRoot}, #{layerId}, #{indirection}, #{indirectionVersion}, #{primaryIndirection}, #{opacity}, #{contentUrl}, #{mimetype}, #{encoding}, #{length}) - - - - insert into avm_nodes (id, class_type, deletedType, version_id, vers, store_new_id, acl_id, guid, owner, creator, createDate, lastModifier, modDate, accessDate, is_root, layer_id, indirection, indirection_version, primary_indirection, opacity, content_url, mime_type, encoding, length) - values (#{id}, #{classType}, #{deletedType}, #{version}, 0, #{storeNewId}, #{aclId}, #{guid}, #{owner}, #{creator}, #{createdDate}, #{modifier}, #{modifiedDate}, #{accessDate}, #{isRoot}, #{layerId}, #{indirection}, #{indirectionVersion}, #{primaryIndirection}, #{opacity}, #{contentUrl}, #{mimetype}, #{encoding}, #{length}) - - - - insert into avm_version_roots (avm_store_id, root_id, version_id, creator, create_date, tag, description) - values (#{storeId}, #{rootNodeId}, #{version}, #{creator}, #{createdDate}, #{tag}, #{description}) - - - - insert into avm_version_roots (id, avm_store_id, root_id, version_id, creator, create_date, tag, description) - values (#{id}, #{storeId}, #{rootNodeId}, #{version}, #{creator}, #{createdDate}, #{tag,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}) - - - - insert into avm_store_properties (actual_type_n, persisted_type_n, multi_valued, boolean_value, long_value, float_value, double_value, string_value, serializable_value, avm_store_id, qname_id) - values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - - - - insert into avm_store_properties (id, actual_type_n, persisted_type_n, multi_valued, boolean_value, long_value, float_value, double_value, string_value, serializable_value, avm_store_id, qname_id) - values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - - - - - - - - - insert into avm_aspects (node_id, qname_id) - values (#{nodeId}, #{qnameId}) - - - - insert into avm_child_entries (parent_id, lc_name, name, child_id) - values (#{parentNodeId}, #{lowerName}, #{name}, #{childNodeId}) - - - - insert into avm_history_links (ancestor, descendent) - values (#{ancestorNodeId}, #{descendentNodeId}) - - - - insert into avm_merge_links (mfrom, mto) - values (#{mergeFromNodeId}, #{mergeToNodeId}) - - - - insert into avm_version_layered_node_entry (version_root_id, md5sum, path) - values (#{versionRootId}, #{md5sum}, #{path}) - - - - insert into avm_node_properties (actual_type_n, persisted_type_n, multi_valued, boolean_value, long_value, float_value, double_value, string_value, serializable_value, node_id, qname_id) - values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - - - - - - - - - - - - - - - - - - - - - - - update - avm_stores - set - next_version_id = #{nextVersion}, - name = #{name,jdbcType=VARCHAR}, - current_root_id = #{rootNodeId,jdbcType=BIGINT}, - acl_id = #{aclId,jdbcType=BIGINT}, - vers = #{vers} - where - id = #{id} - - and vers = (#{vers} - 1) - - - - - - delete - from - avm_stores - where - id = ? - - - - - - - - - - - - - - - - - - - - - update - avm_store_properties - set - actual_type_n = ?, - persisted_type_n = ?, - multi_valued = ?, - boolean_value = ?, - long_value = ?, - float_value = ?, - double_value = ?, - string_value = ?, - serializable_value = ? - where - avm_store_id = ? and - qname_id = ? - - - - delete - from - avm_store_properties - where - avm_store_id = #{avmStoreId} and - qname_id = #{qnameId} - - - - delete - from - avm_store_properties - where - avm_store_id = ? - - - - - - - - - - - - - - - - - - - - - - update - avm_nodes - set - store_new_id = null - where - store_new_id = ? - - - - - update - avm_nodes - set - store_new_id = #{storeNewId,jdbcType=BIGINT}, - acl_id = #{aclId,jdbcType=BIGINT}, - layer_id = #{layerId,jdbcType=BIGINT}, - version_id = #{version}, - class_type = #{classType}, - deletedType = #{deletedType,jdbcType=INTEGER}, - owner = #{owner}, - modDate = #{modifiedDate}, - accessDate = #{accessDate}, - is_root = #{isRoot,jdbcType=BIT}, - lastModifier = #{modifier}, - indirection = #{indirection,jdbcType=VARCHAR}, - indirection_version = #{indirectionVersion,jdbcType=INTEGER}, - primary_indirection = #{primaryIndirection,jdbcType=BIT}, - opacity = #{opacity,jdbcType=BIT}, - content_url = #{contentUrl,jdbcType=VARCHAR}, - mime_type = #{mimetype,jdbcType=VARCHAR}, - encoding = #{encoding,jdbcType=VARCHAR}, - length = #{length,jdbcType=BIGINT}, - guid = #{guid,jdbcType=VARCHAR}, - vers = #{vers} - where - id = #{id} - - and vers = (#{vers} - 1) - - - - - update - avm_nodes - set - modDate = #{modifiedDate}, - guid = #{guid,jdbcType=VARCHAR}, - vers = #{vers} - where - id = #{id} - - and vers = (#{vers} - 1) - - - - - update - avm_nodes - set - modDate = #{modifiedDate}, - content_url = #{contentUrl,jdbcType=VARCHAR}, - mime_type = #{mimetype,jdbcType=VARCHAR}, - encoding = #{encoding,jdbcType=VARCHAR}, - length = #{length,jdbcType=BIGINT}, - vers = #{vers} - where - id = #{id} - - and vers = (#{vers} - 1) - - - - - - update - avm_nodes set acl_id = null - where - acl_id is not null - and id in - - #{item} - - - - - - update - avm_nodes set acl_id = #{id,jdbcType=BIGINT} - where - id in - - #{item} - - - - - delete - from - avm_nodes - where - id = ? - - - - - - - - - - - - - update - avm_node_properties - set - actual_type_n = ?, - persisted_type_n = ?, - multi_valued = ?, - boolean_value = ?, - long_value = ?, - float_value = ?, - double_value = ?, - string_value = ?, - serializable_value = ? - where - node_id = ? and - qname_id = ? - - - - delete - from - avm_node_properties - where - node_id = #{nodeId} and - qname_id = #{qnameId} - - - - delete - from - avm_node_properties - where - node_id = ? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - update - avm_version_roots - set - tag = #{tag,jdbcType=VARCHAR}, - description = #{description,jdbcType=VARCHAR} - where - id = #{id} - - - - delete - from - avm_version_roots - where - id = ? - - - - - - - - - - delete - from - avm_version_layered_node_entry - where - version_root_id = ? - - - - - - - - - - - - delete - from - avm_aspects - where - node_id = #{nodeId} and - qname_id = #{qnameId} - - - - delete - from - avm_aspects - where - node_id = ? - - - - - - - - - - - - - - - - - - - - - - - - - - - update - avm_child_entries - set - name = #{name} - where - parent_id = #{parentNodeId} and - child_id = #{childNodeId} - - - - - delete - from - avm_child_entries - where - parent_id = #{parentNodeId} and - lc_name = #{lowerName} - - - - - delete - from - avm_child_entries - where - parent_id = #{parentNodeId} and - child_id = #{childNodeId} - - - - - delete - from - avm_child_entries - where - parent_id = ? - - - - - - - - - - - - - - delete - from - avm_merge_links - where - mfrom = #{mergeFromNodeId} and - mto = #{mergeToNodeId} - - - - - - - - - - - - - - delete - from - avm_history_links - where - ancestor = #{ancestorNodeId} and - descendent = #{descendentNodeId} - - - - - - - - - - - - - - - - - delete from - alf_prop_unique_ctx - where exists - ( - select - * - from - alf_prop_value pv3 - join alf_prop_string_value psv3 on (psv3.id = pv3.long_value), - alf_prop_link pl - left join alf_prop_value pkey on (pkey.id = pl.key_prop_id and pkey.persisted_type = 3) - left join alf_prop_string_value psvk on (psvk.id = pkey.long_value) - left join alf_prop_value pval on (pval.id = pl.value_prop_id and pval.persisted_type = 3) - left join alf_prop_string_value psvv on (psvv.id = pval.long_value) - where - value1_prop_id = ? and - value2_prop_id = ? and - value3_prop_id = pv3.id and - pv3.persisted_type = 3 and - psv3.string_value like ? and - prop1_id = pl.root_prop_id and - psvk.string_value = ? and - psvv.string_value = ? - ) - - - - delete from - alf_prop_unique_ctx - where exists - ( - select - * - from - alf_prop_value pv3 - join alf_prop_string_value psv3 on (psv3.id = pv3.long_value) - where - value1_prop_id = ? and - value2_prop_id = ? and - value3_prop_id = pv3.id and - pv3.persisted_type = 3 and - psv3.string_value like ? - ) - - - \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/avm-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/avm-insert-SqlMap.xml deleted file mode 100644 index 613ebebb40..0000000000 --- a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/avm-insert-SqlMap.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/avm-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/avm-insert-SqlMap.xml deleted file mode 100644 index 4bea77007f..0000000000 --- a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/avm-insert-SqlMap.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - select nextVal('avm_stores_seq') - - - - - - - - - - select nextVal('avm_store_properties_seq') - - - - - - - - - - select nextVal('avm_nodes_seq') - - - - - - - - - - select nextVal('avm_version_roots_seq') - - - - - - - \ No newline at end of file diff --git a/config/alfresco/opencmis-qnamefilter-context.xml b/config/alfresco/opencmis-qnamefilter-context.xml index 7377131be1..d3f519b81f 100644 --- a/config/alfresco/opencmis-qnamefilter-context.xml +++ b/config/alfresco/opencmis-qnamefilter-context.xml @@ -9,8 +9,6 @@ {http://www.jcp.org/jcr/nt/1.0}* {http://www.jcp.org/jcr/mix/1.0}* {http://www.jcp.org/jcr/sv/1.0}* - {http://www.alfresco.org/model/wcmappmodel/1.0}* - {http://www.alfresco.org/model/wcmmodel/1.0}* diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml index 44b6f644f9..1e78f665ca 100644 --- a/config/alfresco/patch/patch-services-context.xml +++ b/config/alfresco/patch/patch-services-context.xml @@ -464,16 +464,6 @@ 3.3 - - patch.AVMGuidPatch - patch.AVMGuidPatch.description - 0 - 51 - 52 - - 3.3 - - patch.webscripts patch.webscripts.description @@ -494,16 +484,6 @@ 3.3 - - patch.AVMLayeredSnapshot - patch.AVMLayeredSnapshot.description - 0 - 55 - 56 - - 3.3 - - patch.groupMembersAsIdentifiers patch.groupMembersAsIdentifiers.description @@ -634,16 +614,6 @@ 3.4.x - - patch.db-V2.1-RemoveWcmSubmittedAspect - patch.schemaUpgradeScript.description - 0 - 103 - 104 - - 3.4.x - - patch.webscripts3 patch.webscripts3.description @@ -664,26 +634,6 @@ 3.4.x - - patch.avmStoreAsIdentifier - patch.avmStoreAsIdentifier.description - 0 - 109 - 110 - - 3.4.x - - - - patch.avmFormPropertyIdentifier - patch.avmFormPropertyIdentifier.description - 0 - 111 - 112 - - 3.4.x - - patch.formsFolder patch.formsFolder.description @@ -776,22 +726,6 @@ - - patch.updateAvmPermissionData - patch.updateAvmPermissionData.description - 0 - 119 - 120 - - - - - - - - - - patch.db-V2.2-CleanNodeStatuses patch.schemaUpgradeScript.description @@ -874,25 +808,6 @@ - - patch.avmWebProjectInheritPermissions02 - patch.avmWebProjectInheritPermissions.description - 0 - 122 - 123 - - - - - - - - - - - - - patch.updateDmPermissions patch.updateDmPermissions.description @@ -1120,242 +1035,6 @@ - - patch.redeploySubmitProcess4 - patch.redeploySubmitProcess.description - 0 - 1000 - 1001 - - - - - - - - - - - jbpm - alfresco/workflow/submit_processdefinition.xml - text/xml - - - - - - - patch.redeploySubmitProcess5 - patch.redeploySubmitProcess.description - 0 - 2000 - 2001 - - - - - - - - - - jbpm - alfresco/workflow/submit_processdefinition.xml - text/xml - - - - - - - patch.deploySubmitDirectProcess - patch.deploySubmitDirectProcess.description - 0 - 2000 - 2001 - - - - - - - - - - jbpm - alfresco/workflow/submitdirect_processdefinition.xml - text/xml - - - - - - - - - - - - - - - - - - - patch.redeploySubmitProcess6 - patch.redeploySubmitProcess.description - 0 - 2002 - 2003 - - - - - - - - - jbpm - alfresco/workflow/submit_processdefinition.xml - text/xml - - - jbpm - alfresco/workflow/submitdirect_processdefinition.xml - text/xml - - - - - - - patch.redeploySubmitProcess7 - patch.redeploySubmitProcess.description - 0 - 2003 - 2004 - - - - - - - - - jbpm - alfresco/workflow/submit_processdefinition.xml - text/xml - - - jbpm - alfresco/workflow/submitdirect_processdefinition.xml - text/xml - - - - - patch.db-V2.2-Person-3 patch.schemaUpgradeScript.description @@ -1408,17 +1087,6 @@ - - patch.db-V3.2-Remove-AVM-Issuer - patch.schemaUpgradeScript.description - 0 - 2007 - 2008 - - classpath:alfresco/dbscripts/upgrade/3.2/${db.script.dialect}/remove-AVM-issuer.sql - - - patch.mtShareExistingTenants patch.mtShareExistingTenants.description @@ -1556,9 +1224,6 @@ - - - @@ -1575,17 +1240,6 @@ - - patch.db-V3.2-Modify-AVM-MimeType - patch.schemaUpgradeScript.description - 0 - 2016 - 2017 - - classpath:alfresco/dbscripts/upgrade/3.2/${db.script.dialect}/modify-AVM-mimetype.sql - - - patch.imapFolders patch.imapFolders.description @@ -1992,17 +1646,6 @@ - - patch.db-V3.3-Fix-AVM-Seqs - patch.schemaUpgradeScript.description - 0 - 4104 - 4105 - - classpath:alfresco/dbscripts/upgrade/3.3/${db.script.dialect}/fix-AVM-seqs.sql - - - patch.db-V3.4-property-unique-ctx-value patch.schemaUpgradeScript.description @@ -2090,26 +1733,6 @@ - - patch.migrateAttrAVMLocks - patch.migrateAttrAVMLocks.description - 0 - 4106 - 4107 - false - - - - - - - - - - - - - patch.migrateAttrPropBackedBeans patch.migrateAttrPropBackedBeans.description @@ -2165,7 +1788,6 @@ - @@ -2354,31 +1976,6 @@ - - - - - - - - - - - - - - - - - - - - - - classpath:alfresco/dbscripts/upgrade/3.4/${db.script.dialect}/link-validation-metadata-removing.sql - - - patch.mtFixAdminExistingTenants patch.mtFixAdminExistingTenants.description @@ -2438,17 +2035,6 @@ - - patch.db-V3.4-AVM-rename-dupes - patch.schemaUpgradeScript.description - 0 - 5005 - 5006 - - classpath:alfresco/dbscripts/upgrade/3.4/${db.script.dialect}/AVM-rename-dupes.sql - - - patch.activitiesEmailTemplate patch.activitiesEmailTemplate.description @@ -2774,30 +2360,6 @@ - - - patch.avmToAdmRemoteStore - patch.avmToAdmRemoteStore.description - 0 - 5011 - 5012 - false - - - - - - - sitestore - /alfresco/site-data - - - - - - - - patch.copiedFromAspect @@ -3106,17 +2668,6 @@ - - patch.db-V3.4-AVM-index-child-entries-lower - patch.avmIndexChildEntriesLower.description - 0 - 6002 - 6003 - - classpath:alfresco/dbscripts/upgrade/3.4/${db.script.dialect}/AVM-index-child-entries-lower.sql - - - @@ -3631,27 +3182,6 @@ - - - - 0 - 6030 - 6031 - - classpath:alfresco/dbscripts/upgrade/4.1/${db.script.dialect}/fix-AVM-seqs-order.sql - - - - - - - 0 - 6031 - 6032 - - classpath:alfresco/dbscripts/upgrade/4.2/${db.script.dialect}/drop-AVM-index.sql - - patch.db-V4.1-ChildAssoc-OrderBy patch.schemaUpgradeScript.description diff --git a/config/alfresco/public-services-context.xml b/config/alfresco/public-services-context.xml index 153120f0b7..070274b331 100644 --- a/config/alfresco/public-services-context.xml +++ b/config/alfresco/public-services-context.xml @@ -779,135 +779,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - copy - - - - - - - - org.alfresco.service.cmr.repository.CrossRepositoryCopyService - - - - crossRepositoryCopyService - - - - crossRepositoryCopyServiceWriteTxnAdvisor - checkTxnAdvisor - - - - - - - - - - - - - - org.alfresco.service.cmr.avm.AVMService - - - - avmLockingAwareService - - - - avmServiceWriteTxnAdvisor - avmServiceReadTxnAdvisor - checkTxnAdvisor - - - - - - - - - - org.alfresco.service.cmr.avm.AVMService - - - - avmLockingAwareService - - - - avmSnapShotTriggeredIndexingMethodInterceptor - - - - - - - - - org.alfresco.service.cmr.avm.AVMService - - - - - - - checkTxnAdvisor - - - - - - - - - - - - - - - - - @@ -919,212 +790,6 @@ - - - - - - - getFileInputStream - getContentReader - getDirectoryListing - getDirectoryListingDirect - getDirectoryListingArray - getDeleted - getNextVersionID - getLatestSnapshotID - getStoreVersions - getStores - getStore - getStoreRoot - lookup - getPaths - getHeadPaths - getPathsInStoreHead - getPathsInStoreVersion - getIndirectionPath - getHistory - getCommonAncestor - getLayeringInfo - getNodeProperty - getNodeProperties - getStoreProperty - getStoreProperties - queryStorePropertyKey - queryStoresPropertyKeys - getContentDataForRead - getAspects - hasAspect - getAPath - getGuid - getStoreVersionsFrom - getStoreVersionsTo - getStoreVersionsBetween - - - - - - - - - - - getFileOutputStream - getContentWriter - createFile - createDirectory - createLayeredFile - createLayeredDirectory - retargetLayeredDirectory - createStore - createBranch - removeNode - rename - uncover - makeTransparent - createSnapshot - purgeStore - purgeVersion - makePrimary - setOpacity - setNodeProperty - setNodeProperties - deleteNodeProperty - deleteNodeProperties - setStoreProperty - setStoreProperties - deleteStoreProperty - getContentDataForWrite - setContentData - setMetaDataFrom - addAspect - removeAspect - link - forceCopy - copy - renameStore - getSystemStore - revert - setGuid - setEncoding - setMimeType - - - - - - - - org.alfresco.service.cmr.avm.AVMService - - - - avmService - - - - avmServiceWriteTxnAdvisor - avmServiceReadTxnAdvisor - checkTxnAdvisor - - - - - - - - - - org.alfresco.service.cmr.avm.AVMService - - - - avmService - - - - avmSnapShotTriggeredIndexingMethodInterceptor - - - - - - - - - - - - - - - - - - - - - compare - - - - - - - - - - - - update - flatten - resetLayer - - - - - - - - org.alfresco.service.cmr.avmsync.AVMSyncService - - - - avmSyncService - - - - avmSyncServiceWriteTxnAdvisor - avmSyncServiceReadTxnAdvisor - checkTxnAdvisor - - - - @@ -1175,54 +840,6 @@ - - - - - - - - - getLockOwner - getLockData - getLockState - hasAccess - - - - - - - - - - - lock - modifyLock - removeLock - removeLocks - - - - - - - - org.alfresco.service.cmr.avm.locking.AVMLockingService - - - - avmLockingService - - - - avmLockingServiceWriteTxnAdvisor - avmLockingServiceReadTxnAdvisor - checkTxnAdvisor - - - - diff --git a/config/alfresco/repository.properties b/config/alfresco/repository.properties index 8dcc7dcfe4..1490e4b61d 100644 --- a/config/alfresco/repository.properties +++ b/config/alfresco/repository.properties @@ -125,7 +125,6 @@ index.recovery.maximumPoolSize=5 # See http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html index.tracking.cronExpression=0/5 * * * * ? index.tracking.adm.cronExpression=${index.tracking.cronExpression} -index.tracking.avm.cronExpression=${index.tracking.cronExpression} # Other properties. index.tracking.maxTxnDurationMinutes=10 index.tracking.reindexLagMs=1000 @@ -476,8 +475,6 @@ spaces.templates.email.following.childname=app:following spaces.templates.rss.childname=app:rss_templates spaces.savedsearches.childname=app:saved_searches spaces.scripts.childname=app:scripts -spaces.wcm.childname=app:wcm -spaces.wcm_content_forms.childname=app:wcm_forms spaces.content_forms.childname=app:forms spaces.user_homes.childname=app:user_homes spaces.user_homes.regex.key=userName @@ -488,7 +485,6 @@ spaces.templates.email.invite.childname=cm:invite spaces.templates.email.activities.childname=cm:activities spaces.rendition.rendering_actions.childname=app:rendering_actions spaces.replication.replication_actions.childname=app:replication_actions -spaces.wcm_deployed.childname=cm:wcm_deployed spaces.transfers.childname=app:transfers spaces.transfer_groups.childname=app:transfer_groups spaces.transfer_temp.childname=app:temp @@ -559,9 +555,6 @@ user.name.caseSensitive=false domain.name.caseSensitive=false domain.separator= -# AVM Specific properties. -avm.remote.idlestream.timeout=30000 - #Format caption extracted from the XML Schema. xforms.formatCaption=true @@ -613,23 +606,17 @@ alfresco.rmi.services.retries=4 # # Specify 0 to use a random unused port. # -avm.rmi.service.port=50501 -avmsync.rmi.service.port=50502 authentication.rmi.service.port=50504 repo.rmi.service.port=50505 action.rmi.service.port=50506 -deployment.rmi.service.port=50507 monitor.rmi.service.port=50508 # # enable or disable individual RMI services # -avm.rmi.service.enabled=true -avmsync.rmi.service.enabled=true authentication.rmi.service.enabled=true repo.rmi.service.enabled=true action.rmi.service.enabled=true -deployment.rmi.service.enabled=true monitor.rmi.service.enabled=true @@ -834,43 +821,6 @@ transferservice.receiver.lockRetryWait=100 # time" for both source and destination. Default 5 minutes. transferservice.receiver.lockTimeOut=300000 -# Max time allowed for WCM folder rename operation issued by external clients (CIFS, FTP) -wcm.rename.max.time.milliseconds=2000 - -; DM Receiever Properties -; -; The name of the DM Receiver target - you deploy to this target name -deployment.dmr.name=alfresco - -; consolidate staging, author and workflow sandboxes to one -deployment.dmr.consolidate=true - -; The name of the Alfresco receiver targer -deployment.avm.name=avm - -;Where should the root of the web project be stored, by default /www/avm_webapps -deployment.avm.rootPath=/www/avm_webapps - -; Pattern for live stores deployment by the alfresco receiver -deployment.avm.storeNamePattern=%storeName%-live - -; Built in deployment receiver properties for the default -; filesystem receiver - -; filesystem receiver configuration -deployment.filesystem.rootdir=./wcm -deployment.filesystem.datadir=${deployment.filesystem.rootdir}/depdata -deployment.filesystem.logdir=${deployment.filesystem.rootdir}/deplog -deployment.filesystem.metadatadir=${deployment.filesystem.rootdir}/depmetadata - -deployment.filesystem.autofix=true -deployment.filesystem.errorOnOverwrite=false - -; default filesystem target configuration -deployment.filesystem.default.rootdir=./www -deployment.filesystem.default.name=filesystem -deployment.filesystem.default.metadatadir=${deployment.filesystem.metadatadir}/default - # OrphanReaper orphanReaper.lockRefreshTime=60000 orphanReaper.lockTimeOut=3600000 diff --git a/config/alfresco/templates/following-email-templates.xml b/config/alfresco/templates/following-email-templates.xml index 2890f12552..719d794c7c 100644 --- a/config/alfresco/templates/following-email-templates.xml +++ b/config/alfresco/templates/following-email-templates.xml @@ -1,7 +1,7 @@ - + ${spaces.templates.email.following.name} ${spaces.templates.email.following.name} diff --git a/config/alfresco/templates/invite-email-templates.xml b/config/alfresco/templates/invite-email-templates.xml index ccc6afaa37..e7ab0611b7 100644 --- a/config/alfresco/templates/invite-email-templates.xml +++ b/config/alfresco/templates/invite-email-templates.xml @@ -3,7 +3,7 @@ /app:company_home/app:dictionary/app:email_templates/cm:invite - + @@ -19,7 +19,7 @@ - + @@ -35,7 +35,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -67,7 +67,7 @@ - + @@ -83,7 +83,7 @@ - + @@ -99,7 +99,7 @@ - + diff --git a/config/alfresco/templates/new-user-templates.xml b/config/alfresco/templates/new-user-templates.xml index 238e0b05da..ce28206735 100644 --- a/config/alfresco/templates/new-user-templates.xml +++ b/config/alfresco/templates/new-user-templates.xml @@ -3,7 +3,7 @@ /app:company_home/app:dictionary/app:email_templates/cm:invite - + @@ -19,7 +19,7 @@ - + @@ -35,7 +35,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -67,7 +67,7 @@ - + @@ -83,7 +83,7 @@ - + @@ -99,7 +99,7 @@ - + diff --git a/config/alfresco/templates/notify_email_templates.xml b/config/alfresco/templates/notify_email_templates.xml index 83f0799ca5..886daf9454 100644 --- a/config/alfresco/templates/notify_email_templates.xml +++ b/config/alfresco/templates/notify_email_templates.xml @@ -1,6 +1,6 @@ - + @@ -15,7 +15,7 @@ - + @@ -30,7 +30,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -60,7 +60,7 @@ - + @@ -75,7 +75,7 @@ - + @@ -90,7 +90,7 @@ - + diff --git a/config/alfresco/templates/readme_template.xml b/config/alfresco/templates/readme_template.xml index 3f604bb2de..629092a734 100644 --- a/config/alfresco/templates/readme_template.xml +++ b/config/alfresco/templates/readme_template.xml @@ -1,6 +1,6 @@ - + diff --git a/config/alfresco/tx-cache-context.xml b/config/alfresco/tx-cache-context.xml index bef435d4cb..8f1ce6aead 100644 --- a/config/alfresco/tx-cache-context.xml +++ b/config/alfresco/tx-cache-context.xml @@ -341,81 +341,6 @@ - - - - - - - - org.alfresco.cache.avmStoreTransactionalCache - - - - - - - - - - - - - - - org.alfresco.cache.avmEntityTransactionalCache - - - - - - - - - - - - - - - org.alfresco.cache.avmVersionRootEntityTransactionalCache - - - - - - - - - - - - - - - org.alfresco.cache.avmNodeTransactionalCache - - - - - - - - - - - - - - - org.alfresco.cache.avmNodeAspectsTransactionalCache - - - - - - - diff --git a/config/alfresco/wcm-services-context.xml b/config/alfresco/wcm-services-context.xml deleted file mode 100644 index 1224753743..0000000000 --- a/config/alfresco/wcm-services-context.xml +++ /dev/null @@ -1,343 +0,0 @@ - - - - - - - - - - - org.alfresco.wcm.webproject.WebProjectService - - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.readOnly} - ${server.transaction.mode.readOnly} - ${server.transaction.mode.readOnly} - ${server.transaction.mode.readOnly} - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.wcm.asset.AssetService - - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.readOnly} - ${server.transaction.mode.default} - ${server.transaction.mode.default} - ${server.transaction.mode.readOnly} - ${server.transaction.mode.readOnly} - ${server.transaction.mode.readOnly} - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - mlAwareLockingAwareNodeService - - - - org.alfresco.service.cmr.repository.NodeService - - - - - mlPropertyInterceptorLockingAware - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.wcm.sandbox.SandboxService - - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.readOnly} - ${server.transaction.mode.readOnly} - ${server.transaction.mode.readOnly} - ${server.transaction.mode.readOnly} - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - webprojects - - - - - - - - - - - - - - org.alfresco.wcm.preview.PreviewURIService - - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.readOnly} - ${server.transaction.mode.default} - - - - - - - - - - - - - - - - Virtualisation Server Preview - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - - - - - - - false - - - - - - - - - false - - - - - - - - - alfresco.messages.wcm-services - - - - - \ No newline at end of file diff --git a/config/alfresco/workflow-context.xml b/config/alfresco/workflow-context.xml index a64d142e9e..1c3417fc12 100644 --- a/config/alfresco/workflow-context.xml +++ b/config/alfresco/workflow-context.xml @@ -27,7 +27,6 @@ - @@ -62,8 +61,6 @@ - - diff --git a/source/java/org/alfresco/filesys/avm/AVMContext.java b/source/java/org/alfresco/filesys/avm/AVMContext.java deleted file mode 100644 index e32a0d49af..0000000000 --- a/source/java/org/alfresco/filesys/avm/AVMContext.java +++ /dev/null @@ -1,667 +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 . - */ - -package org.alfresco.filesys.avm; - -import java.util.StringTokenizer; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.filesys.alfresco.AlfrescoContext; -import org.alfresco.filesys.alfresco.AlfrescoDiskDriver; -import org.alfresco.filesys.alfresco.IOControlHandler; -import org.alfresco.jlan.server.filesys.DiskInterface; -import org.alfresco.jlan.server.filesys.FileName; -import org.alfresco.jlan.server.filesys.FileSystem; -import org.alfresco.jlan.server.filesys.NotifyChange; -import org.alfresco.jlan.server.filesys.cache.FileState; -import org.alfresco.jlan.server.filesys.cache.FileStateCache; -import org.alfresco.jlan.util.StringList; -import org.alfresco.repo.avm.CreateStoreCallback; -import org.alfresco.repo.avm.CreateVersionCallback; -import org.alfresco.repo.avm.PurgeStoreCallback; -import org.alfresco.repo.avm.PurgeVersionCallback; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * AVM Filesystem Context Class - * - *

Contains per filesystem context. - * - * @author GKSpencer - */ -public class AVMContext extends AlfrescoContext - implements CreateStoreCallback, PurgeStoreCallback, CreateVersionCallback, PurgeVersionCallback { - - // Logging - - private static final Log logger = LogFactory.getLog(AVMContext.class); - - // Constants - // - // Version id that indicates the head version - - public static final int VERSION_HEAD = -1; - - // Store types to show in the virtualization view - - public static final int ShowNormalStores = 0x0001; - public static final int ShowSiteStores = 0x0002; - public static final int ShowStagingStores = 0x0004; - public static final int ShowAuthorStores = 0x0008; - public static final int ShowPreviewStores = 0x0010; - - // Store, root path and version - - private String m_storePath; - private int m_version = VERSION_HEAD; - - // Flag to indicate if the virtualization view is enabled - // - // The first set of folders then map to the stores and the second layer map to the versions with - // paths below. - - private boolean m_virtualView; - - // Virtualization view filtering options - - private int m_showOptions = ShowStagingStores + ShowAuthorStores; - - // List of newly created store names that need adding into the virtualization view - - private StringList m_newStores; - private Object m_newStoresLock; - - // Allow admin user to write to web project staging stores - - private boolean m_allowAdminStagingWrites; - - // Auto create the store if it doesn't exist? - - private boolean m_createStore; - - /** - * Default constructor allowing initialization by container. - */ - public AVMContext() - { - } - - /** - * Class constructor - * - *

Construct a context for a normal view onto a single store/version within AVM. - * - * @param filesysName String - * @param storePath String - * @param version int - */ - public AVMContext( String filesysName, String storePath, int version) - { - setDeviceName(filesysName); - - // Set the store root path - setStorePath(storePath); - - // Set the store version to use - setVersion(version); - } - - /** - * Class constructor - * - *

Construct a context for a virtualization view onto all stores/versions within AVM. - * - * @param filesysName String - * @param showOptions int - * @param avmDriver AVMDiskDriver - */ - public AVMContext( String filesysName, int showOptions, AVMDiskDriver avmDriver) - { - setDeviceName(filesysName); - - // Enable the virtualization view - setVirtualView(true); - setShowOptions(showOptions); - } - - public void setStorePath(String path) - { - this.m_storePath = path; - } - - public void setVersion(int version) - { - this.m_version = version; - } - - public void setShowOptions(int showOptions) - { - this.m_showOptions = showOptions; - } - - public void setStores(String showAttr) - { - if ( showAttr != null) - { - // Split the show options string - - StringTokenizer tokens = new StringTokenizer( showAttr, ","); - StringList optList = new StringList(); - - while ( tokens.hasMoreTokens()) - optList.addString( tokens.nextToken().trim().toLowerCase()); - - // Build the show options mask - - this.m_showOptions = 0; - - if ( optList.containsString("normal")) - this.m_showOptions += ShowNormalStores; - - if ( optList.containsString("site")) - this.m_showOptions += ShowSiteStores; - - if ( optList.containsString("author")) - this.m_showOptions += ShowAuthorStores; - - if ( optList.containsString("preview")) - this.m_showOptions += ShowPreviewStores; - - if ( optList.containsString("staging")) - this.m_showOptions += ShowStagingStores; - } - } - - public void setVirtualView(boolean isVirtualView) - { - this.m_virtualView = isVirtualView; - } - - public boolean getCreateStore() - { - return m_createStore; - } - - public void setCreateStore(boolean createStore) - { - m_createStore = createStore; - } - - - @Override - public void initialize(AlfrescoDiskDriver filesysDriver) - { - if (m_virtualView) - { - // A context for a view onto all stores/versions within AVM. - m_newStoresLock = new Object(); - m_newStores = new StringList(); - - setShareName("VirtualView"); - } - else - { - if (m_storePath == null - || m_storePath.length() == 0) - throw new AlfrescoRuntimeException("Device missing init value: storePath"); - - // A context for a normal view onto a single store/version within AVM. - if (m_storePath.endsWith("/")) - m_storePath = m_storePath.substring(0, m_storePath.length() - 1); - - // Range check the version id - if (m_version < 0 && m_version != AVMContext.VERSION_HEAD) - throw new AlfrescoRuntimeException("Invalid store version id specified, " + m_version); - - setShareName(m_storePath + "(" + m_version + ")"); - } - super.initialize(filesysDriver); - } - - /** - * Return the filesystem type, either FileSystem.TypeFAT or FileSystem.TypeNTFS. - * - * @return String - */ - public String getFilesystemType() - { - return FileSystem.TypeNTFS; - } - - /** - * Return the store path - * - * @return String - */ - public final String getStorePath() - { - return m_storePath; - } - - /** - * Return the version - * - * @return int - */ - public final int isVersion() - { - return m_version; - } - - /** - * Check if the virtualization view is enabled - * - * @return boolean - */ - public final boolean isVirtualizationView() - { - return m_virtualView; - } - - /** - * Check if the admin user is allowed to write to web project staging stores - * - * @return boolean - */ - public final boolean allowAdminStagingWrites() { - return m_allowAdminStagingWrites; - } - - /** - * Set the admin web project staging store writeable status - * - * @param writeable boolean - */ - public final void setAllowAdminStagingWrites(boolean writeable) { - m_allowAdminStagingWrites = writeable; - } - - /** - * Check if there are any new stores queued for adding to the virtualization view - * - * @return boolean - */ - protected final boolean hasNewStoresQueued() { - if ( m_newStores == null || m_newStores.numberOfStrings() == 0) - return false; - return true; - } - - /** - * Return the new stores queue, and reset the current queue - * - * @return StringList - */ - protected StringList getNewStoresQueue() { - - StringList storesQueue = null; - - synchronized ( m_newStoresLock) { - storesQueue = m_newStores; - m_newStores = new StringList(); - } - - return storesQueue; - } - - /** - * Check if normal stores should be shown in the virtualization view - * - * @return boolean - */ - public final boolean showNormalStores() - { - return (m_showOptions & ShowNormalStores) != 0 ? true : false; - } - - /** - * Check if site data stores should be shown in the virtualization view - * - * @return boolean - */ - public final boolean showSiteStores() - { - return (m_showOptions & ShowSiteStores) != 0 ? true : false; - } - - /** - * Check if author stores should be shown in the virtualization view - * - * @return boolean - */ - public final boolean showAuthorStores() - { - return (m_showOptions & ShowAuthorStores) != 0 ? true : false; - } - - /** - * Check if preview stores should be shown in the virtualization view - * - * @return boolean - */ - public final boolean showPreviewStores() - { - return (m_showOptions & ShowPreviewStores) != 0 ? true : false; - } - - /** - * Check if staging stores should be shown in the virtualization view - * - * @return boolean - */ - public final boolean showStagingStores() - { - return (m_showOptions & ShowStagingStores) != 0 ? true : false; - } - - /** - * Check if the specified store type should be visible - * - * @param storeType int - * @return boolean - */ - public final boolean showStoreType(int storeType) - { - boolean showStore = false; - - switch (storeType) - { - case StoreType.Normal: - showStore = showNormalStores(); - break; - case StoreType.SiteStore: - showStore = showSiteStores(); - break; - case StoreType.WebAuthorMain: - showStore = showAuthorStores(); - break; - case StoreType.WebStagingMain: - showStore = showStagingStores(); - break; - case StoreType.WebAuthorPreview: - case StoreType.WebStagingPreview: - showStore = showPreviewStores(); - break; - } - - return showStore; - } - - /** - * Close the filesystem context - */ - public void CloseContext() { - - // Call the base class - - super.CloseContext(); - } - - /** - * Create the I/O control handler for this filesystem type - * - * @param filesysDriver DiskInterface - * @return IOControlHandler - */ - protected IOControlHandler createIOHandler( DiskInterface filesysDriver) - { - return null; - } - - /** - * Create store call back handler - * - * @param storeName String - * @param versionID int - */ - public void storeCreated(String storeName) - { - // Not interested if the virtualization view is not enabled - - if ( isVirtualizationView() == false) - return; - - // Make sure the file state cache is enabled - - FileStateCache fsTable = getStateCache(); - if ( fsTable == null) - return; - - // Find the file state for the root folder - - FileState rootState = fsTable.findFileState( FileName.DOS_SEPERATOR_STR, true); - - if ( rootState != null) - { - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug("Queueing new store " + storeName + " for addition to virtualization view"); - - // Add the new store name to the list to be picked up by the next file server access - // to the filesystem - - synchronized ( m_newStoresLock) { - - // Add the new store name - - m_newStores.addString( storeName); - } - } - } - - /** - * Purge store call back handler - * - * @param storeName String - */ - public void storePurged(String storeName) - { - // Not interested if the virtualization view is not enabled - - if ( isVirtualizationView() == false) - return; - - // Make sure the file state cache is enabled - - FileStateCache fsTable = getStateCache(); - if ( fsTable == null) - return; - - // Find the file state for the root folder - - FileState rootState = fsTable.findFileState( FileName.DOS_SEPERATOR_STR); - - if ( rootState != null && rootState.hasPseudoFiles()) - { - // Remove the pseudo folder for the store - - rootState.getPseudoFileList().removeFile( storeName, false); - - // Build the filesystem relative path to the deleted store folder - - StringBuilder pathStr = new StringBuilder(); - - pathStr.append( FileName.DOS_SEPERATOR); - pathStr.append( storeName); - - // Remove the file state for the deleted store - - String storePath = pathStr.toString(); - fsTable.removeFileState( storePath); - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug( "Removed pseudo folder for purged store " + storeName); - - // Update the file state modify time - - rootState.updateModifyDateTime(); - - // Send a change notification for the deleted folder - - if ( hasChangeHandler()) - { - // Send the change notification - - getChangeHandler().notifyDirectoryChanged(NotifyChange.ActionRemoved, storePath); - } - } - } - - /** - * Create version call back handler - * - * @param storeName String - * @param versionID int - */ - public void versionCreated(String storeName, int versionID) - { - // Not interested if the virtualization view is not enabled - - if ( isVirtualizationView() == false) - return; - - // Make sure the file state cache is enabled - - FileStateCache fsTable = getStateCache(); - if ( fsTable == null) - return; - - // Build the path to the store version folder - - StringBuilder pathStr = new StringBuilder(); - - pathStr.append( FileName.DOS_SEPERATOR); - pathStr.append( storeName); - pathStr.append( FileName.DOS_SEPERATOR); - pathStr.append( AVMPath.VersionsFolder); - - // Find the file state for the store versions folder - - FileState verState = fsTable.findFileState( pathStr.toString()); - - if ( verState != null) - { - // Create the version folder name - - StringBuilder verStr = new StringBuilder(); - - verStr.append( AVMPath.VersionFolderPrefix); - verStr.append( versionID); - - String verName = verStr.toString(); - - // Add a pseudo folder for the new version - - pathStr.append( FileName.DOS_SEPERATOR); - pathStr.append( verName); - - verState.addPseudoFile( new VersionPseudoFile( verName, pathStr.toString())); - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug( "Added pseudo folder for new version " + storeName + ":/" + verName); - - // Send a change notification for the new folder - - if ( hasChangeHandler()) - { - // Build the filesystem relative path to the new version folder - - pathStr.append( FileName.DOS_SEPERATOR); - pathStr.append( verName); - - // Send the change notification - - getChangeHandler().notifyDirectoryChanged(NotifyChange.ActionAdded, pathStr.toString()); - } - } - } - - /** - * Purge version call back handler - * - * @param storeName String - */ - public void versionPurged(String storeName, int versionID) - { - // Not interested if the virtualization view is not enabled - - if ( isVirtualizationView() == false) - return; - - // Make sure the file state cache is enabled - - FileStateCache fsTable = getStateCache(); - if ( fsTable == null) - return; - - // Build the path to the store version folder - - StringBuilder pathStr = new StringBuilder(); - - pathStr.append( FileName.DOS_SEPERATOR); - pathStr.append( storeName); - pathStr.append( FileName.DOS_SEPERATOR); - pathStr.append( AVMPath.VersionsFolder); - - // Find the file state for the store versions folder - - FileState verState = fsTable.findFileState( pathStr.toString()); - - if ( verState != null && verState.hasPseudoFiles()) - { - // Create the version folder name - - StringBuilder verStr = new StringBuilder(); - - verStr.append( AVMPath.VersionFolderPrefix); - verStr.append( versionID); - - String verName = verStr.toString(); - - // Remove the pseudo folder for the purged version - - verState.getPseudoFileList().removeFile( verName, true); - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug( "Removed pseudo folder for purged version " + storeName + ":/" + verName); - - // Send a change notification for the deleted folder - - if ( hasChangeHandler()) - { - // Build the filesystem relative path to the deleted version folder - - pathStr.append( FileName.DOS_SEPERATOR); - pathStr.append( verName); - - // Send the change notification - - getChangeHandler().notifyDirectoryChanged(NotifyChange.ActionRemoved, pathStr.toString()); - } - } - } -} diff --git a/source/java/org/alfresco/filesys/avm/AVMDiskDriver.java b/source/java/org/alfresco/filesys/avm/AVMDiskDriver.java deleted file mode 100644 index ddd7316366..0000000000 --- a/source/java/org/alfresco/filesys/avm/AVMDiskDriver.java +++ /dev/null @@ -1,3347 +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 . */ - -package org.alfresco.filesys.avm; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.StringTokenizer; - -import javax.transaction.UserTransaction; - -import org.alfresco.filesys.alfresco.AlfrescoDiskDriver; -import org.alfresco.filesys.config.ServerConfigurationBean; -import org.alfresco.filesys.alfresco.AlfrescoTxDiskDriver; -import org.alfresco.jlan.server.SrvSession; -import org.alfresco.jlan.server.auth.ClientInfo; -import org.alfresco.jlan.server.core.DeviceContext; -import org.alfresco.jlan.server.core.DeviceContextException; -import org.alfresco.jlan.server.filesys.AccessDeniedException; -import org.alfresco.jlan.server.filesys.DirectoryNotEmptyException; -import org.alfresco.jlan.server.filesys.DiskInterface; -import org.alfresco.jlan.server.filesys.FileAttribute; -import org.alfresco.jlan.server.filesys.FileExistsException; -import org.alfresco.jlan.server.filesys.FileInfo; -import org.alfresco.jlan.server.filesys.FileName; -import org.alfresco.jlan.server.filesys.FileOpenParams; -import org.alfresco.jlan.server.filesys.FileStatus; -import org.alfresco.jlan.server.filesys.NetworkFile; -import org.alfresco.jlan.server.filesys.PathNotFoundException; -import org.alfresco.jlan.server.filesys.SearchContext; -import org.alfresco.jlan.server.filesys.TreeConnection; -import org.alfresco.jlan.server.filesys.cache.FileState; -import org.alfresco.jlan.server.filesys.pseudo.PseudoFile; -import org.alfresco.jlan.server.filesys.pseudo.PseudoFileList; -import org.alfresco.jlan.server.filesys.pseudo.PseudoFolderNetworkFile; -import org.alfresco.jlan.util.StringList; -import org.alfresco.jlan.util.WildCard; -import org.alfresco.model.ContentModel; -import org.alfresco.model.WCMAppModel; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.repo.avm.CreateStoreTxnListener; -import org.alfresco.repo.avm.CreateVersionTxnListener; -import org.alfresco.repo.avm.PurgeStoreTxnListener; -import org.alfresco.repo.avm.PurgeVersionTxnListener; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.security.authentication.AuthenticationComponent; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -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.avm.AVMService; -import org.alfresco.service.cmr.avm.AVMStoreDescriptor; -import org.alfresco.service.cmr.avm.AVMWrongTypeException; -import org.alfresco.service.cmr.avm.VersionDescriptor; -import org.alfresco.service.cmr.avm.locking.AVMLockingException; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.InvalidNodeRefException; -import org.alfresco.service.cmr.repository.CyclicChildRelationshipException; -import org.alfresco.service.cmr.security.AuthenticationService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.wcm.sandbox.SandboxConstants; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.config.ConfigElement; - -/** - * AVM Repository Filesystem Driver Class - *

- * Provides a filesystem interface for various protocols such as SMB/CIFS and FTP. - * - * @author GKSpencer - */ -public class AVMDiskDriver extends AlfrescoTxDiskDriver implements DiskInterface -{ - // Logging - - private static final Log logger = LogFactory.getLog(AVMDiskDriver.class); - - // Configuration key names - - private static final String KEY_STORE = "storePath"; - private static final String KEY_VERSION = "version"; - private static final String KEY_CREATE = "createStore"; - - // AVM path seperator - - public static final char AVM_SEPERATOR = '/'; - public static final String AVM_SEPERATOR_STR = "/"; - - // Define client role names - - public static final String RoleContentManager = "ContentManager"; - public static final String RoleWebProject = "WebProject"; - public static final String RoleNotWebAuthor = "NotWebAuthor"; - - // Content manager web project role - - private static final String ROLE_CONTENT_MANAGER = "ContentManager"; - - // File status values used in the file state cache - - public static final int FileUnknown = FileStatus.Unknown; - public static final int FileNotExist = FileStatus.NotExist; - public static final int FileExists = FileStatus.FileExists; - public static final int DirectoryExists = FileStatus.DirectoryExists; - - public static final int CustomFileStatus= FileStatus.MaxStatus + 1; - - // Services and helpers - - private AVMService m_avmService; - private MimetypeService m_mimetypeService; - private AuthenticationComponent m_authComponent; - private AuthenticationService m_authService; - private NodeService m_nodeService; - - // AVM listeners - - private CreateStoreTxnListener m_createStoreListener; - private PurgeStoreTxnListener m_purgeStoreListener; - private CreateVersionTxnListener m_createVerListener; - private PurgeVersionTxnListener m_purgeVerListener; - - // Web project store - - private String m_webProjectStore; - - /** - * Default constructor - */ - public AVMDiskDriver() - { - } - - /** - * Return the AVM service - * - * @return AVMService - */ - public final AVMService getAvmService() - { - return m_avmService; - } - - /** - * Return the authentication service - * - * @return AuthenticationService - */ - public final AuthenticationService getAuthenticationService() - { - return m_authService; - } - - /** - * Set the AVM service - * - * @param avmService - * AVMService - */ - public void setAvmService(AVMService avmService) - { - m_avmService = avmService; - } - - /** - * Set the authentication component - * - * @param authComponent - * AuthenticationComponent - */ - public void setAuthenticationComponent(AuthenticationComponent authComponent) - { - m_authComponent = authComponent; - } - - /** - * Set the authentication service - * - * @param authService - * AuthenticationService - */ - public void setAuthenticationService(AuthenticationService authService) - { - m_authService = authService; - } - - /** - * Set the mimetype service - * - * @param mimetypeService - * MimetypeService - */ - public void setMimetypeService(MimetypeService mimetypeService) - { - m_mimetypeService = mimetypeService; - } - - /** - * Set the node service - * - * @param nodeService NodeService - */ - public void setNodeService(NodeService nodeService) - { - m_nodeService = nodeService; - } - - /** - * Set the create store listener - * - * @param createStoreListener - * CreateStoreTxnListener - */ - public void setCreateStoreListener(CreateStoreTxnListener createStoreListener) - { - m_createStoreListener = createStoreListener; - } - - /** - * Set the purge store listener - * - * @param purgeStoreListener - * PurgeStoreTxnListener - */ - public void setPurgeStoreListener(PurgeStoreTxnListener purgeStoreListener) - { - m_purgeStoreListener = purgeStoreListener; - } - - /** - * Set the create version listener - * - * @param createVersionListener - * CreateVersionTxnListener - */ - public void setCreateVersionListener(CreateVersionTxnListener createVersionListener) - { - m_createVerListener = createVersionListener; - } - - /** - * Set the purge version listener - * - * @param purgeVersionListener - * PurgeVersionTxnListener - */ - public void setPurgeVersionListener(PurgeVersionTxnListener purgeVersionListener) - { - m_purgeVerListener = purgeVersionListener; - } - - /** - * Set the web project store - * - * @param webStore String - */ - public void setWebProjectStore(String webStore) - { - m_webProjectStore = webStore; - } - - /** - * Parse and validate the parameter string and create a device context object for this instance of the shared - * device. - * - * @param shareName String - * @param cfg ConfigElement - * @return DeviceContext - * @exception DeviceContextException - */ - public DeviceContext createContext(String shareName, ConfigElement cfg) - throws DeviceContextException - { - AVMContext context = null; - - try - { - // Check if the share is a virtualization view - - ConfigElement virtElem = cfg.getChild("virtualView"); - if (virtElem != null) - { - // Check if virtualization view show options have been specified - - int showOptions = AVMContext.ShowStagingStores + AVMContext.ShowAuthorStores; - - String showAttr = virtElem.getAttribute( "stores"); - if ( showAttr != null) - { - // Split the show options string - - StringTokenizer tokens = new StringTokenizer( showAttr, ","); - StringList optList = new StringList(); - - while ( tokens.hasMoreTokens()) - optList.addString( tokens.nextToken().trim().toLowerCase()); - - // Build the show options mask - - showOptions = 0; - - if ( optList.containsString("normal")) - showOptions += AVMContext.ShowNormalStores; - - if ( optList.containsString("site")) - showOptions += AVMContext.ShowSiteStores; - - if ( optList.containsString("author")) - showOptions += AVMContext.ShowAuthorStores; - - if ( optList.containsString("preview")) - showOptions += AVMContext.ShowPreviewStores; - - if ( optList.containsString("staging")) - showOptions += AVMContext.ShowStagingStores; - } - else if ( cfg.getChild("showAllSandboxes") != null) - { - // Old style show options - - showOptions = AVMContext.ShowNormalStores + AVMContext.ShowSiteStores + - AVMContext.ShowAuthorStores + AVMContext.ShowPreviewStores + - AVMContext.ShowStagingStores; - } - - // Create the context - - context = new AVMContext(shareName, showOptions, this); - - // Check if the admin user should be allowed to write to the web project staging stores - - if ( cfg.getChild("adminWriteable") != null) - context.setAllowAdminStagingWrites( true); - - } - else - { - // Get the store path - - ConfigElement storeElement = cfg.getChild(KEY_STORE); - if (storeElement == null - || storeElement.getValue() == null || storeElement.getValue().length() == 0) - throw new DeviceContextException("Device missing init value: " + KEY_STORE); - - String storePath = storeElement.getValue(); - - // Get the version if specified, or default to the head version - - int version = AVMContext.VERSION_HEAD; - - ConfigElement versionElem = cfg.getChild(KEY_VERSION); - if (versionElem != null) - { - // Check if the version is valid - - if (versionElem.getValue() == null || versionElem.getValue().length() == 0) - throw new DeviceContextException("Store version not specified"); - - // Validate the version id - - try - { - version = Integer.parseInt(versionElem.getValue()); - } - catch (NumberFormatException ex) - { - throw new DeviceContextException("Invalid store version specified, " - + versionElem.getValue()); - } - - // Range check the version id - - if (version < 0 && version != AVMContext.VERSION_HEAD) - throw new DeviceContextException("Invalid store version id specified, " + version); - } - - // Create the context - - context = new AVMContext(shareName, storePath, version); - - // Check if the create flag is enabled - - ConfigElement createStore = cfg.getChild(KEY_CREATE); - context.setCreateStore(createStore != null); - - // Enable file state caching - - //context.enableStateCache( true); - } - - } - catch (Exception ex) - { - logger.error("Error during create context", ex); - - // Rethrow the exception - - throw new DeviceContextException("Driver setup error, " + ex.getMessage()); - } - - // Register the context bean - registerContext(context); - - // Return the context for this shared filesystem - return context; - } - - /** - * Register a device context object for this instance of the shared - * device. - * - * @param context the device context - * @param serverConfig ServerConfigurationBean - * @exception DeviceContextException - */ - @Override - public void registerContext(DeviceContext ctx) - throws DeviceContextException - { - super.registerContext(ctx); - - AVMContext context = (AVMContext)ctx; - // Use the system user as the authenticated context for the filesystem initialization - - try - { - AuthenticationUtil.pushAuthentication(); - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); - - // Wrap the initialization in a transaction - - UserTransaction tx = getTransactionService().getUserTransaction(false); - - try - { - // Start the transaction - - if (tx != null) - tx.begin(); - - // Check if the share is a virtualization view - - if (context.isVirtualizationView()) - { - // Enable file state caching - -// context.enableStateCache(serverConfig, true); - - // Plug the virtualization view context into the various store/version call back listeners - // so that store/version pseudo folders can be kept in sync with AVM - - m_createStoreListener.addCallback(context); - m_purgeStoreListener.addCallback(context); - - m_createVerListener.addCallback(context); - m_purgeVerListener.addCallback(context); - - // Create the file state for the root path, this will build the store pseudo folder list - - findPseudoState( new AVMPath( ""), context); - } - else - { - // Get the store path - String storePath = context.getStorePath(); - - // Get the version - int version = context.isVersion(); - - // Validate the store path - - AVMNodeDescriptor rootNode = m_avmService.lookup(version, storePath); - if (rootNode == null) - { - // Check if the store should be created - - if (!context.getCreateStore()|| version != AVMContext.VERSION_HEAD) - throw new DeviceContextException("Invalid store path/version, " - + storePath + " (" + version + ")"); - - // Parse the store path - - String storeName = null; - String path = null; - - int pos = storePath.indexOf(":/"); - if (pos != -1) - { - storeName = storePath.substring(0, pos); - if (storePath.length() > pos) - path = storePath.substring(pos + 2); - } - else - storeName = storePath; - - // Check if the store exists - - AVMStoreDescriptor storeDesc = null; - - try - { - storeDesc = m_avmService.getStore(storeName); - } - catch (AVMNotFoundException ex) - { - } - - // Create a new store if it does not exist - - if (storeDesc == null) - m_avmService.createStore(storeName); - - // Check if there is an optional path - - if (path != null) - { - // Split the path - - StringTokenizer tokens = new StringTokenizer(path, AVMPath.AVM_SEPERATOR_STR); - StringList paths = new StringList(); - - while (tokens.hasMoreTokens()) - paths.addString(tokens.nextToken()); - - // Create the path, or folders that do not exist - - AVMPath curPath = new AVMPath(storeName, version, FileName.DOS_SEPERATOR_STR); - AVMNodeDescriptor curDesc = m_avmService.lookup(curPath.getVersion(), curPath.getAVMPath()); - - // Walk the path checking creating each folder as required - - for (int i = 0; i < paths.numberOfStrings(); i++) - { - AVMNodeDescriptor nextDesc = null; - - try - { - // Check if the child folder exists - - nextDesc = m_avmService.lookup(curDesc, paths.getStringAt(i)); - } - catch (AVMNotFoundException ex) - { - } - - // Check if the folder exists - - if (nextDesc == null) - { - // Create the new folder - - m_avmService.createDirectory(curPath.getAVMPath(), paths.getStringAt(i)); - - // Get the details of the new folder - - nextDesc = m_avmService.lookup(curDesc, paths.getStringAt(i)); - } - else if (nextDesc.isFile()) - throw new DeviceContextException("Path element error, not a folder, " - + paths.getStringAt(i)); - - // Step to the next level - - curPath.parsePath(storeName, version, curPath.getRelativePath() - + paths.getStringAt(i) + FileName.DOS_SEPERATOR_STR); - curDesc = nextDesc; - } - } - - // Validate the store path again - - rootNode = m_avmService.lookup(version, storePath); - if (rootNode == null) - throw new DeviceContextException("Failed to create new store " + storePath); - } - - // Enable file state caching - -// context.enableStateCache(serverConfig, true); - } - - // Commit the transaction - - tx.commit(); - tx = null; - } - catch (Exception ex) - { - logger.error("Error during create context", ex); - - // Rethrow the exception - - throw new DeviceContextException("Driver setup error, " + ex.getMessage(), ex); - } - finally - { - // If there is an active transaction then roll it back - - if (tx != null) - { - try - { - tx.rollback(); - } - catch (Exception ex) - { - logger.warn("Failed to rollback transaction", ex); - } - } - } - - // Return the context for this shared filesystem - } - finally - { - AuthenticationUtil.popAuthentication(); - } - } - - /** - * Return a list of the available AVM store names - * - * @return StringList - */ - public final StringList getAVMStoreNames() - { - // Use the system user as the authenticated context to get the AVM store list - - String currentUser = m_authComponent.getCurrentUserName(); - try - { - m_authComponent.setCurrentUser(m_authComponent.getSystemUserName()); - - // Wrap the service request in a transaction - - UserTransaction tx = getTransactionService().getUserTransaction(false); - - StringList storeNames = new StringList(); - - try - { - // Start the transaction - - if (tx != null) - tx.begin(); - - // Get the list of AVM stores - - List storeList = m_avmService.getStores(); - - if (storeList != null) - { - for (AVMStoreDescriptor storeDesc : storeList) - storeNames.addString(storeDesc.getName()); - } - - // Commit the transaction - if (tx != null) - tx.commit(); - tx = null; - } - catch (Exception ex) - { - logger.error("Error getting store names", ex); - } - finally - { - // If there is an active transaction then roll it back - - if (tx != null) - { - try - { - tx.rollback(); - } - catch (Exception ex) - { - logger.warn("Failed to rollback transaction", ex); - } - } - } - - // Return the list of AVM store names - - return storeNames; - } - finally - { - m_authComponent.setCurrentUser(currentUser); - } - } - - /** - * Get the properties for a store - * - * @param storeName - * String - * @return Map - */ - protected final Map getAVMStoreProperties(String storeName) - { - // Use the system user as the authenticated context to get the AVM store properties - - String currentUser = m_authComponent.getCurrentUserName(); - try - { - m_authComponent.setCurrentUser(m_authComponent.getSystemUserName()); - - // Wrap the service request in a transaction - - UserTransaction tx = getTransactionService().getUserTransaction(false); - - Map properties = null; - - try - { - // Start the transaction - - if (tx != null) - tx.begin(); - - // Get the list of properties for AVM store - - properties = m_avmService.getStoreProperties(storeName); - - // Commit the transaction - - if (tx != null) - tx.commit(); - tx = null; - } - catch (Exception ex) - { - logger.error("Error getting store properties", ex); - } - finally - { - // If there is an active transaction then roll it back - - if (tx != null) - { - try - { - tx.rollback(); - } - catch (Exception ex) - { - logger.warn("Failed to rollback transaction", ex); - } - } - } - - // Return the list of AVM store properties - - return properties; - } - finally - { - m_authComponent.setCurrentUser(currentUser); - } - } - - /** - * Build the full store path for a file/folder using the share relative path - * - * @param ctx AVMContext - * @param path String - * @param sess SrvSession - * @return AVMPath - * @exception AccessDeniedException - */ - protected final AVMPath buildStorePath(AVMContext ctx, String path, SrvSession sess) - throws AccessDeniedException - { - // Check if the AVM filesystem is a normal or virtualization view - - AVMPath avmPath = null; - - if (ctx.isVirtualizationView()) - { - // Create a path for the virtualization view - - avmPath = new AVMPath(path); - - // Check that the user has access to the path - - checkPathAccess( avmPath, ctx, sess); - } - else - { - // Create a path to a single store/version - - avmPath = new AVMPath(ctx.getStorePath(), ctx.isVersion(), path); - } - - // Return the path - - return avmPath; - } - - /** - * Close the file. - * - * @param sess - * Server session - * @param tree - * Tree connection. - * @param file - * Network file context. - * @exception java.io.IOException - * If an error occurs. - */ - public void closeFile(final SrvSession sess, final TreeConnection tree, final NetworkFile file) throws java.io.IOException - { - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug("Close file " + file.getFullName()); - - doInWriteTransaction(sess, new CallableIO(){ - - public Void call() throws IOException - { - // Close the file - - file.closeFile(); - - // Check if the file/directory is marked for delete - - if (file.hasDeleteOnClose()) - { - - // Check for a file or directory - - if (file.isDirectory()) - deleteDirectory(sess, tree, file.getFullName()); - else - deleteFile(sess, tree, file.getFullName()); - } - return null; - }}); - } - - /** - * Create a new directory on this file system. - * - * @param sess - * Server session - * @param tree - * Tree connection. - * @param params - * Directory create parameters - * @exception java.io.IOException - * If an error occurs. - */ - public void createDirectory(SrvSession sess, TreeConnection tree, FileOpenParams params) throws java.io.IOException - { - // Check if the filesystem is writable - - AVMContext ctx = (AVMContext) tree.getContext(); - if (ctx.isVersion() != AVMContext.VERSION_HEAD) - throw new AccessDeniedException("Cannot create " + params.getPath() + ", filesys not writable"); - - // Split the path to get the new folder name and relative path - - final String[] paths = FileName.splitPath(params.getPath()); - - // Convert the relative path to a store path - - final AVMPath storePath = buildStorePath(ctx, paths[0], sess); - - // DEBUG - - if (logger.isDebugEnabled()) - logger.debug("Create directory params=" + params + ", storePath=" + storePath + ", name=" + paths[1]); - - // Check if the filesystem is the virtualization view - - if (ctx.isVirtualizationView()) - { - if (storePath.isReadOnlyPseudoPath()) - throw new AccessDeniedException("Cannot create folder in store/version layer, " + params.getPath()); - else if ( storePath.isReadOnlyAccess()) - throw new AccessDeniedException("Cannot create folder " + params.getPath() + ", read-only path"); - } - - // Create a new file - - try - { - doInWriteTransaction(sess, new CallableIO(){ - - public Void call() throws IOException - { - // Create the new file entry - - m_avmService.createDirectory(storePath.getAVMPath(), paths[1]); - - return null; - }}); - } - catch (AVMExistsException ex) - { - throw new FileExistsException(params.getPath()); - } - catch (AVMNotFoundException ex) - { - throw new FileNotFoundException(params.getPath()); - } - catch (AVMWrongTypeException ex) - { - throw new FileNotFoundException(params.getPath()); - } - catch (AVMBadArgumentException ex) - { - throw new FileNotFoundException(params.getPath()); - } - catch (AVMLockingException ex) - { - throw new AccessDeniedException(params.getPath()); - } - catch ( org.alfresco.repo.security.permissions.AccessDeniedException ex) - { - throw new AccessDeniedException(params.getPath()); - } - } - - /** - * Create a new file on the file system. - * - * @param sess - * Server session - * @param tree - * Tree connection - * @param params - * File create parameters - * @return NetworkFile - * @exception java.io.IOException - * If an error occurs. - */ - public NetworkFile createFile(final SrvSession sess, TreeConnection tree, final FileOpenParams params) - throws java.io.IOException - { - // Check if the filesystem is writable - - final AVMContext ctx = (AVMContext) tree.getContext(); - - // Split the path to get the file name and relative path - - final String[] paths = FileName.splitPath(params.getPath()); - - // Convert the relative path to a store path - - final AVMPath storePath = buildStorePath(ctx, paths[0], sess); - - // DEBUG - - if (logger.isDebugEnabled()) - logger.debug("Create file params=" + params + ", storePath=" + storePath + ", name=" + paths[1]); - - // Check if the filesystem is the virtualization view - - if (ctx.isVirtualizationView()) - { - if (storePath.isReadOnlyPseudoPath()) - throw new AccessDeniedException("Cannot create file in store/version layer, " + params.getPath()); - else if ( storePath.isReadOnlyAccess()) - throw new AccessDeniedException("Cannot create file " + params.getPath() + ", read-only path"); - } - else if (storePath.getVersion() != AVMContext.VERSION_HEAD) - { - throw new AccessDeniedException("Cannot create " + params.getPath() + ", filesys not writable"); - } - - - try - { - // Create a new file - return doInWriteTransaction(sess, new CallableIO(){ - - public NetworkFile call() throws IOException - { - // Create the new file entry - - m_avmService.createFile(storePath.getAVMPath(), paths[1]).close(); - - // Get the new file details - - AVMPath fileStorePath = buildStorePath(ctx, params.getPath(), sess); - AVMNodeDescriptor nodeDesc = m_avmService.lookup(fileStorePath.getVersion(), fileStorePath.getAVMPath()); - - if (nodeDesc != null) - { - // Create the network file object for the new file - - AVMNetworkFile netFile = new AVMNetworkFile(nodeDesc, fileStorePath.getAVMPath(), fileStorePath.getVersion(), - m_nodeService, m_avmService); - netFile.setGrantedAccess(NetworkFile.READWRITE); - netFile.setFullName(params.getPath()); - - netFile.setFileId(fileStorePath.generateFileId()); - - // Set the mime-type for the new file - - netFile.setMimeType(m_mimetypeService.guessMimetype(paths[1])); - return netFile; - } - return null; - }}); - } - catch (AVMExistsException ex) - { - throw new FileExistsException(params.getPath()); - } - catch (AVMNotFoundException ex) - { - throw new FileNotFoundException(params.getPath()); - } - catch (AVMWrongTypeException ex) - { - throw new FileNotFoundException(params.getPath()); - } - catch (AVMBadArgumentException ex) - { - throw new FileNotFoundException(params.getPath()); - } - catch (AVMLockingException ex) - { - throw new AccessDeniedException(params.getPath()); - } - catch ( org.alfresco.repo.security.permissions.AccessDeniedException ex) - { - throw new AccessDeniedException(params.getPath()); - } - } - - /** - * Delete the directory from the filesystem. - * - * @param sess - * Server session - * @param tree - * Tree connection - * @param dir - * Directory name. - * @exception java.io.IOException - * The exception description. - */ - public void deleteDirectory(SrvSession sess, TreeConnection tree, final String dir) throws java.io.IOException - { - // Convert the relative path to a store path - - AVMContext ctx = (AVMContext) tree.getContext(); - - final String[] paths = FileName.splitPath(dir); - final AVMPath parentPath = buildStorePath(ctx, paths[0], sess); - final AVMPath dirPath = buildStorePath(ctx, dir, sess); - - // DEBUG - - if (logger.isDebugEnabled()) - logger.debug("Delete directory, path=" + dir + ", dirPath=" + dirPath); - - // Check if the filesystem is the virtualization view - - if (ctx.isVirtualizationView()) - { - if (parentPath.isPseudoPath()) - throw new AccessDeniedException("Cannot delete folder in store/version layer, " + dir); - else if ( parentPath.isReadOnlyAccess()) - throw new AccessDeniedException("Cannot delete folder " + dir + ", read-only path"); - } - - // Make sure the path is to a folder before deleting it - - try - { - doInWriteTransaction(sess, new CallableIO(){ - - public Void call() throws IOException - { - AVMNodeDescriptor nodeDesc = m_avmService.lookup(dirPath.getVersion(), dirPath.getAVMPath()); - if (nodeDesc != null) - { - // Check that we are deleting a folder - - if (nodeDesc.isDirectory()) - { - // Make sure the directory is empty - - SortedMap fileList = m_avmService.getDirectoryListing(nodeDesc); - if (fileList != null && fileList.size() > 0) - throw new DirectoryNotEmptyException(dir); - - // Delete the folder - - m_avmService.removeNode(dirPath.getAVMPath()); - } - else - throw new IOException("Delete directory path is not a directory, " + dir); - } - return null; - }}); - } - catch (AVMNotFoundException ex) - { - throw new IOException("Directory not found, " + dir); - } - catch (AVMWrongTypeException ex) - { - throw new IOException("Invalid path, " + dir); - } - catch ( org.alfresco.repo.security.permissions.AccessDeniedException ex) - { - throw new AccessDeniedException("Access denied, " + dir); - } - } - - /** - * Delete the specified file. - * - * @param sess - * Server session - * @param tree - * Tree connection - * @param file - * NetworkFile - * @exception java.io.IOException - * The exception description. - */ - public void deleteFile(SrvSession sess, TreeConnection tree, final String name) throws java.io.IOException - { - // Convert the relative path to a store path - - AVMContext ctx = (AVMContext) tree.getContext(); - - final String[] paths = FileName.splitPath(name); - final AVMPath parentPath = buildStorePath(ctx, paths[0], sess); - final AVMPath filePath = buildStorePath(ctx, name, sess); - - // DEBUG - - if (logger.isDebugEnabled()) - logger.debug("Delete file, path=" + name + ", filePath=" + filePath); - - // Check if the filesystem is the virtualization view - - if (ctx.isVirtualizationView()) - { - if (parentPath.isPseudoPath()) - throw new AccessDeniedException("Cannot delete file in store/version layer, " + name); - else if ( parentPath.isReadOnlyAccess()) - throw new AccessDeniedException("Cannot delete file " + name + ", read-only path"); - } - - // Make sure the path is to a file before deleting it - - try - { - doInWriteTransaction(sess, new CallableIO(){ - - public Void call() throws IOException - { - AVMNodeDescriptor nodeDesc = m_avmService.lookup(filePath.getVersion(), filePath.getAVMPath()); - if (nodeDesc != null) - { - // Check that we are deleting a file - - if (nodeDesc.isFile()) - { - // Delete the file - - m_avmService.removeNode(filePath.getAVMPath()); - } - else - throw new IOException("Delete file path is not a file, " + name); - } - return null; - }}); - } - catch (AVMNotFoundException ex) - { - throw new IOException("File not found, " + name); - } - catch (AVMWrongTypeException ex) - { - throw new IOException("Invalid path, " + name); - } - catch (AVMLockingException ex) - { - throw new AccessDeniedException("File locked, " + name); - } - catch ( org.alfresco.repo.security.permissions.AccessDeniedException ex) - { - throw new AccessDeniedException("Access denied, " + name); - } - } - - /** - * Check if the specified file exists, and whether it is a file or directory. - * - * @param sess - * Server session - * @param tree - * Tree connection - * @param name - * java.lang.String - * @return int - * @see FileStatus - */ - public int fileExists(SrvSession sess, TreeConnection tree, String name) - { - // Convert the relative path to a store path - - AVMContext ctx = (AVMContext) tree.getContext(); - AVMPath storePath = null; - - try - { - storePath = buildStorePath(ctx, name, sess); - } - catch ( AccessDeniedException ex) - { - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug("File exists check, path=" + name + " Access denied"); - - return FileStatus.NotExist; - } - - // DEBUG - - if (logger.isDebugEnabled()) - logger.debug("File exists check, path=" + name + ", storePath=" + storePath); - - // Check if the path is valid - - int status = FileStatus.NotExist; - - if (storePath.isValid() == false) - return status; - - // Check if the filesystem is the virtualization view - - if (ctx.isVirtualizationView() && storePath.isReadOnlyPseudoPath()) - { - // Find the file state for the pseudo folder - - FileState fstate = findPseudoState(storePath, ctx); - - if (fstate != null) - { - // DEBUG - - if (logger.isDebugEnabled()) - logger.debug(" Found pseudo file " + fstate); - - // Check if the pseudo file is a file or folder - - if (fstate.isDirectory()) - status = FileStatus.DirectoryExists; - else - status = FileStatus.FileExists; - } - else - { - // Invalid pseudo file path - - status = FileStatus.NotExist; - } - - // Return the file status - - return status; - } - - // Search for the file/folder - - beginReadTransaction( sess); - - AVMNodeDescriptor nodeDesc = m_avmService.lookup(storePath.getVersion(), storePath.getAVMPath()); - - if (nodeDesc != null) - { - // Check if the path is to a file or folder - - if (nodeDesc.isDirectory()) - status = FileStatus.DirectoryExists; - else - status = FileStatus.FileExists; - } - - // Return the file status - - return status; - } - - /** - * Flush any buffered output for the specified file. - * - * @param sess - * Server session - * @param tree - * Tree connection - * @param file - * Network file context. - * @exception java.io.IOException - * The exception description. - */ - public void flushFile(SrvSession sess, TreeConnection tree, NetworkFile file) throws java.io.IOException - { - // Flush the file - - file.flushFile(); - } - - /** - * Get the file information for the specified file. - * - * @param sess - * Server session - * @param tree - * Tree connection - * @param name - * File name/path that information is required for. - * @return File information if valid, else null - * @exception java.io.IOException - * The exception description. - */ - public FileInfo getFileInformation(SrvSession sess, TreeConnection tree, String name) throws java.io.IOException - { - // Convert the relative path to a store path - - AVMContext ctx = (AVMContext) tree.getContext(); - AVMPath storePath = null; - - try - { - storePath = buildStorePath( ctx, name, sess); - } - catch ( Exception ex) - { - throw new FileNotFoundException( name); - } - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug("Get file information, path=" + name + ", storePath=" + storePath); - - // Check if hte path is valid - - if ( storePath.isValid() == false) - throw new FileNotFoundException( name); - - // Check if the filesystem is the virtualization view - - if ( ctx.isVirtualizationView() && storePath.isReadOnlyPseudoPath()) - { - // Search for the pseudo path, to check for any new stores - - FileState fstate = findPseudoState( storePath, ctx); - - // Check if the search path is for the root, a store or version folder - - if ( storePath.isRootPath()) - { - // Return dummy file informatiom for the root folder, use cached timestamps - - FileInfo finfo = new FileInfo( name, 0L, FileAttribute.Directory); - - if ( fstate != null) { - finfo.setModifyDateTime( fstate.getModifyDateTime()); - finfo.setChangeDateTime( fstate.getModifyDateTime()); - } - - // Return the root folder file information - - return finfo; - } - else - { - // Find the pseudo file for the store/version folder - - PseudoFile psFile = findPseudoFolder( storePath, ctx); - if ( psFile != null) - { - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug( " Found pseudo file " + psFile); - return psFile.getFileInfo(); - } - else - throw new FileNotFoundException( name); - } - } - - // Search for the file/folder - - beginReadTransaction( sess); - - FileInfo info = null; - - try - { - AVMNodeDescriptor nodeDesc = m_avmService.lookup( storePath.getVersion(), storePath.getAVMPath()); - - if ( nodeDesc != null) - { - // Create, and fill in, the file information - - info = new FileInfo(); - - info.setFileName( nodeDesc.getName()); - - if ( nodeDesc.isFile()) - { - info.setFileSize( nodeDesc.getLength()); - info.setAllocationSize((nodeDesc.getLength() + 512L) & 0xFFFFFFFFFFFFFE00L); - } - else - info.setFileSize( 0L); - - info.setAccessDateTime( nodeDesc.getAccessDate()); - info.setCreationDateTime( nodeDesc.getCreateDate()); - info.setModifyDateTime( nodeDesc.getModDate()); - info.setChangeDateTime( nodeDesc.getModDate()); - - // Build the file attributes - - int attr = 0; - - if ( nodeDesc.isDirectory()) - attr += FileAttribute.Directory; - - if ( nodeDesc.getName().startsWith( ".") || - nodeDesc.getName().equalsIgnoreCase( "Desktop.ini") || - nodeDesc.getName().equalsIgnoreCase( "Thumbs.db")) - attr += FileAttribute.Hidden; - - // Mark the file/folder as read-only if not the head version - - if ( ctx.isVersion() != AVMContext.VERSION_HEAD || storePath.isReadOnlyAccess()) - attr += FileAttribute.ReadOnly; - - if ( attr == 0) - attr = FileAttribute.NTNormal; - - info.setFileAttributes( attr); - - // Set the file id - - info.setFileId( storePath.generateFileId()); - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug(" File info=" + info); - } - } - catch ( AVMNotFoundException ex) - { - throw new FileNotFoundException( name); - } - catch ( AVMWrongTypeException ex) - { - throw new PathNotFoundException( name); - } - - // Return the file information - - return info; - } - - /** - * Determine if the disk device is read-only. - * - * @param sess - * Server session - * @param ctx - * Device context - * @return boolean - * @exception java.io.IOException - * If an error occurs. - */ - public boolean isReadOnly(SrvSession sess, DeviceContext ctx) throws java.io.IOException - { - // Check if the version indicates the head version, only the head is writable - - AVMContext avmCtx = (AVMContext) ctx; - return avmCtx.isVersion() == AVMContext.VERSION_HEAD ? true : false; - } - - /** - * Open a file on the file system. - * - * @param sess - * Server session - * @param tree - * Tree connection - * @param params - * File open parameters - * @return NetworkFile - * @exception java.io.IOException - * If an error occurs. - */ - public NetworkFile openFile(SrvSession sess, TreeConnection tree, FileOpenParams params) throws java.io.IOException - { - // Convert the relative path to a store path - - AVMContext ctx = (AVMContext) tree.getContext(); - AVMPath storePath = buildStorePath(ctx, params.getPath(), sess); - - // DEBUG - - if (logger.isDebugEnabled()) - logger.debug("Open file params=" + params + ", storePath=" + storePath); - - // Check if the filesystem is the virtualization view - - if (ctx.isVirtualizationView() && storePath.isReadOnlyPseudoPath()) - { - // Check if the path is for the root, a store or version folder - - if (storePath.isRootPath()) - { - // Return a dummy file for the root folder - - return new PseudoFolderNetworkFile(FileName.DOS_SEPERATOR_STR); - } - else - { - // Find the pseudo file for the store/version folder - - PseudoFile psFile = findPseudoFolder(storePath, ctx); - if (psFile != null) - { - // DEBUG - - if (logger.isDebugEnabled()) - logger.debug(" Found pseudo file " + psFile); - return psFile.getFile(params.getPath()); - } - else - return null; - } - } - - // Search for the file/folder - - beginReadTransaction( sess); - - AVMNetworkFile netFile = null; - - try - { - // Get the details of the file/folder - - AVMNodeDescriptor nodeDesc = m_avmService.lookup(storePath.getVersion(), storePath.getAVMPath()); - - if (nodeDesc != null) - { - // Check if the filesystem is read-only and write access has been requested - - if (storePath.getVersion() != AVMContext.VERSION_HEAD - && (params.isReadWriteAccess() || params.isWriteOnlyAccess())) - throw new AccessDeniedException("File " + params.getPath() + " is read-only"); - - // Create the network file object for the opened file/folder - - netFile = new AVMNetworkFile(nodeDesc, storePath.getAVMPath(), storePath.getVersion(), m_nodeService, m_avmService); - - if (params.isReadOnlyAccess() || storePath.getVersion() != AVMContext.VERSION_HEAD) - netFile.setGrantedAccess(NetworkFile.READONLY); - else - netFile.setGrantedAccess(NetworkFile.READWRITE); - - netFile.setFullName(params.getPath()); - netFile.setFileId(storePath.generateFileId()); - - // Set the mime-type for the new file - - netFile.setMimeType(m_mimetypeService.guessMimetype(params.getPath())); - } - else - throw new FileNotFoundException(params.getPath()); - } - catch (AVMNotFoundException ex) - { - throw new FileNotFoundException(params.getPath()); - } - catch (AVMWrongTypeException ex) - { - throw new FileNotFoundException(params.getPath()); - } - catch ( org.alfresco.repo.security.permissions.AccessDeniedException ex) - { - throw new FileNotFoundException(params.getPath()); - } - - // Return the file - - return netFile; - } - - /** - * Read a block of data from the specified file. - * - * @param sess - * Session details - * @param tree - * Tree connection - * @param file - * Network file - * @param buf - * Buffer to return data to - * @param bufPos - * Starting position in the return buffer - * @param siz - * Maximum size of data to return - * @param filePos - * File offset to read data - * @return Number of bytes read - * @exception java.io.IOException - * The exception description. - */ - public int readFile(SrvSession sess, TreeConnection tree, NetworkFile file, byte[] buf, int bufPos, int siz, - long filePos) throws java.io.IOException - { - // Check if the file is a directory - - if (file.isDirectory()) - throw new AccessDeniedException(); - - // If the content channel is not open for the file then start a transaction - - AVMNetworkFile avmFile = (AVMNetworkFile) file; - - if (avmFile.hasContentChannel() == false) - beginReadTransaction( sess); - - // Read the file - - int rdlen = file.readFile(buf, siz, bufPos, filePos); - - // If we have reached end of file return a zero length read - - if (rdlen == -1) - rdlen = 0; - - // Return the actual read length - - return rdlen; - } - - /** - * Rename the specified file. - * - * @param sess - * Server session - * @param tree - * Tree connection - * @param oldName - * java.lang.String - * @param newName - * java.lang.String - * @exception java.io.IOException - * The exception description. - */ - public void renameFile(SrvSession sess, TreeConnection tree, String oldName, String newName) - throws java.io.IOException - { - // Split the relative paths into parent and file/folder name pairs - - AVMContext ctx = (AVMContext) tree.getContext(); - - final String[] oldPaths = FileName.splitPath(oldName); - final String[] newPaths = FileName.splitPath(newName); - - // Convert the parent paths to store paths - - final AVMPath oldAVMPath = buildStorePath(ctx, oldPaths[0], sess); - final AVMPath newAVMPath = buildStorePath(ctx, newPaths[0], sess); - - // DEBUG - - if (logger.isDebugEnabled()) - { - logger.debug("Rename from path=" + oldPaths[0] + ", name=" + oldPaths[1]); - logger.debug(" new path=" + newPaths[0] + ", name=" + newPaths[1]); - } - - // Check if the filesystem is the virtualization view - - if (ctx.isVirtualizationView()) - { - if ( oldAVMPath.isReadOnlyPseudoPath()) - throw new AccessDeniedException("Cannot rename folder in store/version layer, " + oldName); - else if ( newAVMPath.isReadOnlyPseudoPath()) - throw new AccessDeniedException("Cannot rename folder to store/version layer, " + newName); - else if ( oldAVMPath.isReadOnlyAccess() ) - throw new AccessDeniedException("Cannot rename read-only folder, " + oldName); - else if ( newAVMPath.isReadOnlyAccess() ) - throw new AccessDeniedException("Cannot rename folder to read-only folder, " + newName); - } - final NodeRef oldNodeRef = AVMNodeConverter.ToNodeRef(-1, buildStorePath(ctx, oldName, sess).getAVMPath()); - final NodeRef newNodeParentRef = AVMNodeConverter.ToNodeRef(-1, newAVMPath.getAVMPath()); - try - { - doInWriteTransaction(sess, new CallableIO(){ - - public Void call() throws IOException - { - // Rename the file/folder - - m_nodeService.moveNode(oldNodeRef, newNodeParentRef, ContentModel.ASSOC_CONTAINS, QName.createQName(newPaths[1])); - return null; - }}); - } - catch (InvalidNodeRefException ex) - { - throw new IOException("Node reference no longer exists"); - } - catch (CyclicChildRelationshipException ex) - { - throw new IOException("Cyclic parent-child relationship"); - } - catch (AVMWrongTypeException ex) - { - throw new IOException("Invalid path, " + oldName); - } - catch ( org.alfresco.repo.security.permissions.AccessDeniedException ex) - { - throw new AccessDeniedException("Access denied, " + oldName); - } - } - - /** - * Seek to the specified file position. - * - * @param sess - * Server session - * @param tree - * Tree connection - * @param file - * Network file. - * @param pos - * Position to seek to. - * @param typ - * Seek type. - * @return New file position, relative to the start of file. - */ - public long seekFile(SrvSession sess, TreeConnection tree, NetworkFile file, long pos, int typ) - throws java.io.IOException - { - // Check if the file is a directory - - if (file.isDirectory()) - throw new AccessDeniedException(); - - // If the content channel is not open for the file then start a transaction - - AVMNetworkFile avmFile = (AVMNetworkFile) file; - - if (avmFile.hasContentChannel() == false) - beginReadTransaction( sess); - - // Set the file position - - return file.seekFile(pos, typ); - } - - /** - * Set the file information for the specified file. - * - * @param sess - * Server session - * @param tree - * Tree connection - * @param name - * java.lang.String - * @param info - * FileInfo - * @exception java.io.IOException - * The exception description. - */ - public void setFileInformation(SrvSession sess, TreeConnection tree, String name, FileInfo info) - throws java.io.IOException - { - // Check if the file is being marked for deletion, check if the file is writable - - if (info.hasSetFlag(FileInfo.SetDeleteOnClose) && info.hasDeleteOnClose()) - { - // If this is not the head version then it's not writable - - AVMContext avmCtx = (AVMContext) tree.getContext(); - - // Parse the path - - AVMPath storePath = buildStorePath(avmCtx, name, sess); - - if (avmCtx.isVersion() != AVMContext.VERSION_HEAD || storePath.isReadOnlyAccess()) - throw new AccessDeniedException("Store not writable, cannot set delete on close"); - } - } - - /** - * Start a new search on the filesystem using the specified searchPath that may contain wildcards. - * - * @param sess - * Server session - * @param tree - * Tree connection - * @param searchPath - * File(s) to search for, may include wildcards. - * @param attrib - * Attributes of the file(s) to search for, see class SMBFileAttribute. - * @return SearchContext - * @exception java.io.FileNotFoundException - * If the search could not be started. - */ - public SearchContext startSearch(SrvSession sess, TreeConnection tree, String searchPath, int attrib) - throws java.io.FileNotFoundException - { - // Access the AVM context - - AVMContext avmCtx = (AVMContext) tree.getContext(); - - // DEBUG - - if (logger.isDebugEnabled()) - logger.debug("Start search path=" + searchPath); - - // Split the search path into relative path and search name - - String[] paths = FileName.splitPath(searchPath); - - // Build the store path to the folder being searched - - AVMPath storePath = null; - - try - { - storePath = buildStorePath(avmCtx, paths[0], sess); - } - catch ( AccessDeniedException ex) - { - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug("Start search access denied"); - - throw new FileNotFoundException("Access denied"); - } - - // Check if the filesystem is the virtualization view - - if (avmCtx.isVirtualizationView()) - { - // Check for a search of a pseudo folder - - if (storePath.isReadOnlyPseudoPath()) - { - // Get the file state for the folder being searched - - FileState fstate = findPseudoState(storePath, avmCtx); - - if (fstate != null) - { - // Get the pseudo file list for the parent directory - - PseudoFileList searchList = null; - - if ( storePath.isLevel() == AVMPath.LevelId.Root) - searchList = filterPseudoFolders(avmCtx, sess, storePath, fstate); - else - searchList = fstate.getPseudoFileList(); - - // Check if the pseudo file list is valid - - if (searchList == null) - searchList = new PseudoFileList(); - - // Check if this is a single file or wildcard search - - if (WildCard.containsWildcards(searchPath)) - { - // Create the search context, wildcard filter will take care of secondary filtering of the - // folder listing - - WildCard wildCardFilter = new WildCard(paths[1], false); - return new PseudoFileListSearchContext(searchList, attrib, wildCardFilter, storePath.isReadOnlyAccess()); - } - else - { - // Search the pseudo file list for the required file - - PseudoFile pseudoFile = searchList.findFile(paths[1], false); - if (pseudoFile != null) - { - // Create a search context using the single file details - - PseudoFileList singleList = new PseudoFileList(); - singleList.addFile(pseudoFile); - - return new PseudoFileListSearchContext(singleList, attrib, null, storePath.isReadOnlyAccess()); - } - } - } - - // File not found - - throw new FileNotFoundException(searchPath); - } - else if (storePath.isLevel() == AVMPath.LevelId.HeadMetaData - || storePath.isLevel() == AVMPath.LevelId.VersionMetaData) - { - // Return an empty file list for now - - PseudoFileList metaFiles = new PseudoFileList(); - - return new PseudoFileListSearchContext(metaFiles, attrib, null, storePath.isReadOnlyAccess()); - } - } - - // Check if the path is a wildcard search - - beginReadTransaction( sess); - SearchContext context = null; - - if (WildCard.containsWildcards(searchPath)) - { - // Get the file listing for the folder - - AVMNodeDescriptor[] fileList = m_avmService.getDirectoryListingArray(storePath.getVersion(), storePath.getAVMPath(), false); - - // Create the search context - - if (fileList != null) - { - - // DEBUG - - if (logger.isDebugEnabled()) - logger.debug(" Wildcard search returned " + fileList.length + " files"); - - // Create the search context, wildcard filter will take care of secondary filtering of the - // folder listing - - WildCard wildCardFilter = new WildCard(paths[1], false); - context = new AVMSearchContext(fileList, attrib, wildCardFilter, storePath.getRelativePath(), storePath.isReadOnlyAccess()); - } - } - else - { - // Single file/folder search, convert the path to a store path - - try - { - storePath = buildStorePath(avmCtx, searchPath, sess); - } - catch ( AccessDeniedException ex) - { - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug("Start search access denied"); - - throw new FileNotFoundException("Access denied"); - } - - // Get the single file/folder details - - AVMNodeDescriptor nodeDesc = m_avmService.lookup(storePath.getVersion(), storePath.getAVMPath()); - - if (nodeDesc != null) - { - // Create the search context for the single file/folder - - context = new AVMSingleFileSearchContext(nodeDesc, storePath.getRelativePath(), storePath.isReadOnlyAccess()); - } - - } - - // Return the search context - - return context; - } - - /** - * Truncate a file to the specified size - * - * @param sess - * Server session - * @param tree - * Tree connection - * @param file - * Network file details - * @param siz - * New file length - * @exception java.io.IOException - * The exception description. - */ - public void truncateFile(SrvSession sess, TreeConnection tree, final NetworkFile file, final long siz) - throws java.io.IOException - { - // Check if the file is a directory, or only has read access - - if (file.getGrantedAccess() <= NetworkFile.READONLY) - throw new AccessDeniedException(); - - // If the content channel is not open for the file then start a transaction - - AVMNetworkFile avmFile = (AVMNetworkFile) file; - - // Truncate or extend the file - if (avmFile.hasContentChannel() == false || avmFile.isWritable() == false) - { - doInWriteTransaction(sess, new CallableIO(){ - - public Void call() throws IOException - { - file.truncateFile(siz); - file.flushFile(); - return null; - }}); - } - else - { - file.truncateFile(siz); - file.flushFile(); - } - - - } - - /** - * Write a block of data to the file. - * - * @param sess - * Server session - * @param tree - * Tree connection - * @param file - * Network file details - * @param buf - * byte[] Data to be written - * @param bufoff - * Offset within the buffer that the data starts - * @param siz - * int Data length - * @param fileoff - * Position within the file that the data is to be written. - * @return Number of bytes actually written - * @exception java.io.IOException - * The exception description. - */ - public int writeFile(SrvSession sess, TreeConnection tree, final NetworkFile file, final byte[] buf, final int bufoff, final int siz, - final long fileoff) throws java.io.IOException - { - // Check if the file is a directory, or only has read access - - if (file.isDirectory() || file.getGrantedAccess() <= NetworkFile.READONLY) - throw new AccessDeniedException(); - - // If the content channel is not open for the file, or the channel is not writable, then start a transaction - - AVMNetworkFile avmFile = (AVMNetworkFile) file; - - // Write the data to the file - if (avmFile.hasContentChannel() == false || avmFile.isWritable() == false) - { - doInWriteTransaction(sess, new CallableIO(){ - - public Void call() throws IOException - { - file.writeFile(buf, siz, bufoff, fileoff); - return null; - }}); - } - else - { - file.writeFile(buf, siz, bufoff, fileoff); - } - - - // Return the actual write length - - return siz; - } - - /** - * Connection opened to this disk device - * - * @param sess - * Server session - * @param tree - * Tree connection - */ - public void treeClosed(SrvSession sess, TreeConnection tree) - { - // Nothing to do - } - - /** - * Connection closed to this device - * - * @param sess - * Server session - * @param tree - * Tree connection - */ - public void treeOpened(SrvSession sess, TreeConnection tree) - { - // Nothing to do - } - - /** - * Find the pseudo file for a virtual path - * - * @param avmPath - * AVMPath - * @param avmCtx - * AVMContext - * @return PseudoFile - */ - private final PseudoFile findPseudoFolder(AVMPath avmPath, AVMContext avmCtx) - { - return findPseudoFolder(avmPath, avmCtx, true); - } - - /** - * Find the pseudo file for a virtual path - * - * @param avmPath - * AVMPath - * @param avmCtx - * AVMContext - * @param generateStates - * boolean - * @return PseudoFile - */ - private final PseudoFile findPseudoFolder(AVMPath avmPath, AVMContext avmCtx, boolean generateStates) - { - // Check if the path is to a store pseudo folder - - if (avmPath.isRootPath()) - return null; - - // Get the file state for the parent of the required folder - - FileState fstate = null; - StringBuilder str = null; - PseudoFile psFile = null; - - switch (avmPath.isLevel()) - { - // Store root folder - - case StoreRoot: - - // Get the root folder file state - - fstate = avmCtx.getStateCache().findFileState(FileName.DOS_SEPERATOR_STR); - - if (fstate != null && fstate.hasPseudoFiles()) - psFile = fstate.getPseudoFileList().findFile(avmPath.getStoreName(), false); - break; - - // Versions root or Head folder - - case VersionRoot: - case Head: - - // Create a path to the parent store - - str = new StringBuilder(); - - str.append(FileName.DOS_SEPERATOR); - str.append(avmPath.getStoreName()); - - // Find/create the file state for the store - - AVMPath storePath = new AVMPath(str.toString()); - fstate = findPseudoState(storePath, avmCtx); - - // Find the version root or head pseudo folder - - if (fstate != null) - { - if (avmPath.isLevel() == AVMPath.LevelId.Head) - psFile = fstate.getPseudoFileList().findFile(AVMPath.VersionNameHead, true); - else - psFile = fstate.getPseudoFileList().findFile(AVMPath.VersionsFolder, true); - } - break; - - // Version folder - - case Version: - - // Create a path to the versions folder - - str = new StringBuilder(); - - str.append(FileName.DOS_SEPERATOR); - str.append(avmPath.getStoreName()); - str.append(FileName.DOS_SEPERATOR); - str.append(AVMPath.VersionsFolder); - - // Find/create the file state for the store - - AVMPath verrootPath = new AVMPath(str.toString()); - fstate = findPseudoState(verrootPath, avmCtx); - - // Find the version pseudo file - - if (fstate != null) - { - // Build the version folder name string - - str.setLength(0); - - str.append(AVMPath.VersionFolderPrefix); - str.append(avmPath.getVersion()); - - // find the version folder pseduo file - - psFile = fstate.getPseudoFileList().findFile(str.toString(), true); - } - break; - - // Head data or metadata folder - - case HeadData: - case HeadMetaData: - - // Create a path to the head folder - - str = new StringBuilder(); - - str.append(FileName.DOS_SEPERATOR); - str.append(avmPath.getStoreName()); - str.append(FileName.DOS_SEPERATOR); - str.append(AVMPath.VersionNameHead); - - // Find/create the file state for the store - - AVMPath headPath = new AVMPath(str.toString()); - fstate = findPseudoState(headPath, avmCtx); - - // Find the data or metadata pseudo folder - - if (fstate != null) - { - // Find the pseudo folder - - if (avmPath.isLevel() == AVMPath.LevelId.HeadData) - { - psFile = fstate.getPseudoFileList().findFile(AVMPath.DataFolder, true); - } - else - { - psFile = fstate.getPseudoFileList().findFile(AVMPath.MetaDataFolder, true); - } - } - break; - - // Version data or metadata folder - - case VersionData: - case VersionMetaData: - - // Create a path to the version folder - - str = new StringBuilder(); - - str.append(FileName.DOS_SEPERATOR); - str.append(avmPath.getStoreName()); - str.append(FileName.DOS_SEPERATOR); - str.append(AVMPath.VersionFolderPrefix); - str.append(avmPath.getVersion()); - - // Find/create the file state for the store - - AVMPath verPath = new AVMPath(str.toString()); - fstate = findPseudoState(verPath, avmCtx); - - // Find the data or metadata pseudo folder - - if (fstate != null) - { - // Find the pseudo folder - - if (avmPath.isLevel() == AVMPath.LevelId.VersionData) - { - psFile = fstate.getPseudoFileList().findFile(AVMPath.DataFolder, true); - } - else - { - psFile = fstate.getPseudoFileList().findFile(AVMPath.MetaDataFolder, true); - } - } - break; - } - - // Check if the pseudo file was not found but file states should be generated - - if (psFile == null && generateStates == true) - { - // Generate the file states for the path, this is required if a request is made to a path without - // walking the folder tree - - generatePseudoFolders(avmPath, avmCtx); - - // Try and find the pseudo file again - - psFile = findPseudoFolder(avmPath, avmCtx, false); - } - - // Return the pseudo file, or null if not found - - return psFile; - } - - /** - * Find the file state for a pseudo folder path - * - * @param avmPath - * AVMPath - * @param avmCtx - * AVMContext - * @return FileState - */ - protected final FileState findPseudoState(AVMPath avmPath, AVMContext avmCtx) - { - // Make sure the is to a pseudo file/folder - - if ( avmPath.isPseudoPath() == false) - return null; - - // Check if there are any new stores to be added to the virtualization view - - if ( avmCtx.hasNewStoresQueued()) { - - // Get the new stores list, there is a chance another thread might get the queue, if the queue is empty - // another thread is processing it - - StringList storeNames = avmCtx.getNewStoresQueue(); - - while ( storeNames.numberOfStrings() > 0) { - - // Get the current store name - - String curStoreName = storeNames.removeStringAt( 0); - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug("Adding new store " + curStoreName); - - // Add the current store to the virtualization view - - addNewStore( avmCtx, curStoreName); - } - - // Get the root folder file state, update the modification timestamp - - FileState rootState = avmCtx.getStateCache().findFileState( FileName.DOS_SEPERATOR_STR); - if ( rootState != null) - rootState.updateModifyDateTime(); - } - - // Check if the path is to a store pseudo folder - - FileState fstate = null; - StringBuilder str = null; - String relPath = null; - - switch ( avmPath.isLevel()) - { - // Root of the hieararchy - - case Root: - - // Get the root path file state - - fstate = avmCtx.getStateCache().findFileState( FileName.DOS_SEPERATOR_STR); - - // Check if the root file state is valid - - if ( fstate == null) - { - // Create a file state for the root folder - - fstate = avmCtx.getStateCache().findFileState( FileName.DOS_SEPERATOR_STR, true); - fstate.setExpiryTime( FileState.NoTimeout); - fstate.setFileStatus( DirectoryExists); - - // Set the modification timestamp for the root folder - - fstate.updateModifyDateTime(); - - // Get a list of the available AVM stores - - List storeList = m_avmService.getStores(); - - if ( storeList != null && storeList.size() > 0) - { - // Add pseudo files for the stores - - for ( AVMStoreDescriptor storeDesc : storeList) - { - // Get the properties for the current store - - String storeName = storeDesc.getName(); - Map props = m_avmService.getStoreProperties( storeName); - - // Check if the store is a main web project - - if ( props.containsKey( SandboxConstants.PROP_SANDBOX_STAGING_MAIN)) - { - // Get the noderef for the web project - - PropertyValue prop = props.get( SandboxConstants.PROP_WEB_PROJECT_NODE_REF); - if ( prop != null) { - - // Get the web project noderef - - NodeRef webNodeRef = new NodeRef( prop.getStringValue()); - - if (m_nodeService.exists(webNodeRef)) - { - // Create the web project pseudo folder - - WebProjectStorePseudoFile webProjFolder = new WebProjectStorePseudoFile( storeDesc, FileName.DOS_SEPERATOR_STR + storeName, webNodeRef); - fstate.addPseudoFile( webProjFolder); - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug( "Found web project " + webProjFolder.getFileName()); - - // Get the list of content managers for this web project - - List mgrAssocs = m_nodeService.getChildAssocs( webNodeRef, WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL); - - for ( ChildAssociationRef mgrRef : mgrAssocs) - { - // Get the child node and see if it is a content manager association - - NodeRef childRef = mgrRef.getChildRef(); - - if ( m_nodeService.getProperty( childRef, WCMAppModel.PROP_WEBUSERROLE).equals(ROLE_CONTENT_MANAGER)) - { - // Get the user name add it to the web project pseudo folder - - String userName = (String) m_nodeService.getProperty( childRef, WCMAppModel.PROP_WEBUSERNAME); - - webProjFolder.addUserRole( userName, WebProjectStorePseudoFile.RoleContentManager); - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug(" Added content manager " + userName); - } - } - } - else - { - logger.warn("AVM Store '"+storeName+"' with webProjectNodeRef that does not exist: "+webNodeRef); - } - } - } - else - { - // Check if this store is a web project sandbox - - int storeType = StoreType.Normal; - String webProjName = null; - String userName = null; - - if ( props.containsKey( SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN)) - { - // Sandbox store, linked to a web project - - storeType = StoreType.WebAuthorMain; - - // Get the associated web project name - - webProjName = props.get( SandboxConstants.PROP_WEBSITE_NAME).getStringValue(); - - // Get the user name from the store name - - userName = storeName.substring( webProjName.length() + 2); - } - else if ( props.containsKey( SandboxConstants.PROP_SANDBOX_AUTHOR_PREVIEW)) - { - // Author preview sandbox store, linked to a web project - - storeType = StoreType.WebAuthorPreview; - - // Get the associated web project name - - String projPlusUser = storeName.substring( 0, storeName.length() - "--preview".length()); - int pos = projPlusUser.lastIndexOf("--"); - if ( pos != -1) - { - webProjName = projPlusUser.substring( 0, pos); - userName = projPlusUser.substring(pos + 2); - } - } - else if ( props.containsKey( SandboxConstants.PROP_SANDBOX_WORKFLOW_PREVIEW)) - { - // Staging preview sandbox store, linked to a web project - - storeType = StoreType.WebStagingPreview; - } - else if ( props.containsKey( SandboxConstants.PROP_SANDBOX_STAGING_PREVIEW)) - { - // Staging preview sandbox store, linked to a web project - - storeType = StoreType.WebStagingPreview; - - // Get the associated web project name - - webProjName = storeName.substring( 0, storeName.length() - "--preview".length()); - } - else if ( props.containsKey(QName.createQName(null, ".sitestore"))) - { - // Site data store type - - storeType = StoreType.SiteStore; - } - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug( "Store " + storeDesc.getName() + ", type=" + StoreType.asString( storeType) + ", webproj=" + webProjName + ", username=" + userName); - - // Add a pseudo file for the current store - - if ( avmCtx.showStoreType( storeType)) - { - // Create the pseudo folder for the store - - StorePseudoFile storeFolder = new StorePseudoFile( storeDesc, FileName.DOS_SEPERATOR_STR + storeName, storeType); - if (storeType == StoreType.WebAuthorMain || storeType == StoreType.WebAuthorPreview || - storeType == StoreType.WebStagingMain || storeType == StoreType.WebStagingPreview) - { - storeFolder.setWebProject( webProjName); - storeFolder.setUserName( userName); - } - - // Add the store pseudo folder to the root folder file list - - fstate.addPseudoFile( storeFolder); - } - } - } - } - - // Scan the pseudo folder list and add all publisher/reviewer user names to the web project roles list - - PseudoFileList folderList = fstate.getPseudoFileList(); - if ( folderList != null && folderList.numberOfFiles() > 0) - { - // Scan the pseudo folder list - - for ( int i = 0; i < folderList.numberOfFiles(); i++) - { - // Check if the current pseduo file is a store folder - - if ( folderList.getFileAt( i) instanceof StorePseudoFile) - { - // Check if the store has an associated web project - - StorePseudoFile curFile = (StorePseudoFile) folderList.getFileAt( i); - if ( curFile.hasWebProject()) - { - // Find the associated web project pseudo folder - - WebProjectStorePseudoFile webProj = (WebProjectStorePseudoFile) folderList.findFile( curFile.getWebProject(), true); - - if (webProj == null) - { - logger.warn("Missing web project for: "+curFile.getFileName()+" ("+curFile.getWebProject()+")"); - } - else - { - // Strip the web project name from the sandbox store name and extract the user name. - // Add the user as a publisher/reviewer to the web project roles list - - String userName = curFile.getFileName().substring( webProj.getFileName().length() + 2); - - // If the user does not have a content manager role then add as a publisher - - if ( webProj.getUserRole( userName) == WebProjectStorePseudoFile.RoleNone) - { - webProj.addUserRole( userName, WebProjectStorePseudoFile.RolePublisher); - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug( "Added publisher " + userName + " to " + webProj.getFileName()); - } - } - } - } - } - } - } - break; - - // Store folder - - case StoreRoot: - - // Build the path to the parent store folder - - str = new StringBuilder(); - - str.append( FileName.DOS_SEPERATOR); - str.append( avmPath.getStoreName()); - - // Search for the file state for the store pseudo folder - - relPath = str.toString(); - fstate = avmCtx.getStateCache().findFileState( relPath); - - if ( fstate == null) - { - // Create a file state for the store path - - fstate = avmCtx.getStateCache().findFileState( str.toString(), true); - fstate.setFileStatus( DirectoryExists); - - // Add a pseudo file for the head version - - str.append( FileName.DOS_SEPERATOR); - str.append( AVMPath.VersionNameHead); - - fstate.addPseudoFile( new VersionPseudoFile( AVMPath.VersionNameHead, str.toString())); - - // Add a pseudo file for the version root folder - - str.setLength( relPath.length() + 1); - str.append( AVMPath.VersionsFolder); - - fstate.addPseudoFile( new DummyFolderPseudoFile( AVMPath.VersionsFolder, str.toString())); - } - break; - - // Head folder - - case Head: - - // Build the path to the store head version folder - - str = new StringBuilder(); - - str.append( FileName.DOS_SEPERATOR); - str.append( avmPath.getStoreName()); - str.append( FileName.DOS_SEPERATOR); - str.append( AVMPath.VersionNameHead); - - // Search for the file state for the store head version pseudo folder - - relPath = str.toString(); - - fstate = avmCtx.getStateCache().findFileState( relPath); - - if ( fstate == null) - { - // Create a file state for the store head folder path - - fstate = avmCtx.getStateCache().findFileState( str.toString(), true); - fstate.setFileStatus( DirectoryExists); - - // Add a pseudo file for the data pseudo folder - - str.append( FileName.DOS_SEPERATOR); - str.append( AVMPath.DataFolder); - - fstate.addPseudoFile( new DummyFolderPseudoFile( AVMPath.DataFolder, str.toString())); - - // Add a pseudo file for the metadata pseudo folder - - str.setLength( relPath.length() + 1); - str.append( AVMPath.MetaDataFolder); - - fstate.addPseudoFile( new DummyFolderPseudoFile( AVMPath.MetaDataFolder, str.toString())); - } - break; - - // Version root folder - - case VersionRoot: - - // Get the list of AVM store versions - - try - { - // Build the path to the parent store folder - - str = new StringBuilder(); - - str.append( FileName.DOS_SEPERATOR); - str.append( avmPath.getStoreName()); - str.append( FileName.DOS_SEPERATOR); - str.append( AVMPath.VersionsFolder); - - // Create a file state for the store path - - relPath = str.toString(); - fstate = avmCtx.getStateCache().findFileState( relPath, true); - fstate.setFileStatus( DirectoryExists); - - // Add pseudo folders if the list is empty - - if ( fstate.hasPseudoFiles() == false) - { - // Build the version folder name for the head version - - StringBuilder verStr = new StringBuilder( AVMPath.VersionFolderPrefix); - verStr.append( "-1"); - - // Add a pseudo file for the head version - - str.append( FileName.DOS_SEPERATOR); - str.append( verStr.toString()); - - fstate.addPseudoFile( new VersionPseudoFile( verStr.toString(), str.toString())); - - // Get the list of versions for the store - - List verList = m_avmService.getStoreVersions( avmPath.getStoreName()); - - // Add pseudo files for the versions to the store state - - if ( verList.size() > 0) - { - for ( VersionDescriptor verDesc : verList) - { - // Generate the version string - - String verName = null; - - verStr.setLength( AVMPath.VersionFolderPrefix.length()); - verStr.append( verDesc.getVersionID()); - - verName = verStr.toString(); - - str.setLength( relPath.length() + 1); - str.append( verName); - - // Add the version pseudo folder - - fstate.addPseudoFile( new VersionPseudoFile ( verName, verDesc, str.toString())); - } - } - } - } - catch ( AVMNotFoundException ex) - { - // Invalid store name - } - break; - - // Version folder - - case Version: - - // Build the path to the store version folder - - str = new StringBuilder(); - - str.append( FileName.DOS_SEPERATOR); - str.append( avmPath.getStoreName()); - str.append( FileName.DOS_SEPERATOR); - str.append( AVMPath.VersionFolderPrefix); - str.append( avmPath.getVersion()); - - // Search for the file state for the version pseudo folder - - relPath = str.toString(); - fstate = avmCtx.getStateCache().findFileState( relPath); - - if ( fstate == null) - { - // Create a file state for the version folder path - - fstate = avmCtx.getStateCache().findFileState( str.toString(), true); - fstate.setFileStatus( DirectoryExists); - - // Add a pseudo file for the data pseudo folder - - str.append( FileName.DOS_SEPERATOR); - str.append( AVMPath.DataFolder); - - fstate.addPseudoFile( new DummyFolderPseudoFile( AVMPath.DataFolder, str.toString())); - - // Add a pseudo file for the metadata pseudo folder - - str.setLength( relPath.length() + 1); - str.append( AVMPath.MetaDataFolder); - - fstate.addPseudoFile( new DummyFolderPseudoFile( AVMPath.MetaDataFolder, str.toString())); - } - break; - } - - // Return the file state - - return fstate; - } - - /** - * Generate the pseudo folders for the specified path - * - * @param avmPath - * AVMPath - * @param avmCtx - * AVMContext - */ - private final void generatePseudoFolders(AVMPath avmPath, AVMContext avmCtx) - { - // Create the root file state - - AVMPath createPath = new AVMPath(); - StringBuilder pathStr = new StringBuilder(); - - pathStr.append(FileName.DOS_SEPERATOR); - createPath.parsePath(pathStr.toString()); - - FileState rootState = findPseudoState(createPath, avmCtx); - - // Check if the path has a store name - - if (avmPath.getStoreName() != null) - { - // Check if the store name is valid - - if (rootState.hasPseudoFiles() - && rootState.getPseudoFileList().findFile(avmPath.getStoreName(), false) != null) - { - // Create the store file state - - pathStr.append(avmPath.getStoreName()); - pathStr.append(FileName.DOS_SEPERATOR); - - createPath.parsePath(pathStr.toString()); - - findPseudoState(createPath, avmCtx); - - // Add the head and version root pseudo folders - - createPath.parsePath(pathStr.toString() + AVMPath.VersionNameHead); - findPseudoState(createPath, avmCtx); - - createPath.parsePath(pathStr.toString() + AVMPath.VersionsFolder); - findPseudoState(createPath, avmCtx); - - // Check if the path is to a version folder - - if (avmPath.isLevel().ordinal() >= AVMPath.LevelId.Version.ordinal()) - { - // Build the path - - pathStr.append(AVMPath.VersionsFolder); - pathStr.append(FileName.DOS_SEPERATOR); - pathStr.append(AVMPath.VersionFolderPrefix); - pathStr.append(avmPath.getVersion()); - - createPath.parsePath(pathStr.toString()); - - // Generate the version folders - - findPseudoState(createPath, avmCtx); - } - } - } - } - - /** - * Check that the user has access to the path - * - * @param avmPath AVMPath - * @param avmCtx AVMContext - * @param sess SrvSession - * @exception AccessDeniedException - */ - private final void checkPathAccess( AVMPath avmPath, AVMContext avmCtx, SrvSession sess) - throws AccessDeniedException { - - // Only enforce access checks on virtualization views - - if ( avmCtx.isVirtualizationView() == false) - return; - - // Get the client details for the session - - ClientInfo cInfo = sess.getClientInformation(); - if ( cInfo == null || cInfo.getUserName() == null || cInfo.getUserName().length() == 0) - throw new AccessDeniedException(); - - // Allow access to the root folder - - if ( avmPath.isLevel() == AVMPath.LevelId.Root || avmPath.isLevel() == AVMPath.LevelId.HeadData || avmPath.isLevel() == AVMPath.LevelId.StoreRootPath ) { - - // Allow read only access to the root, www and avm_webapps folders - avmPath.setReadOnlyAccess(true); - return; - } - - // Get root file state, get the store pseudo folder details - - FileState rootState = avmCtx.getStateCache().findFileState( FileName.DOS_SEPERATOR_STR); - if ( rootState == null){ - - // Recreate the root file state, new stores may have been added - - rootState = findPseudoState( new AVMPath( FileName.DOS_SEPERATOR_STR), avmCtx); - } - - // Check if there are any store pseudo folders - - if ( rootState != null && rootState.hasPseudoFiles()) - { - PseudoFile pseudoFolder = rootState.getPseudoFileList().findFile( avmPath.getStoreName(), false); - if ( pseudoFolder != null) - { - // Check if the pseudo folder is a web project folder or sandbox within a web project - - String curUserName = m_authComponent.getCurrentUserName(); - - if ( pseudoFolder instanceof WebProjectStorePseudoFile) - { - // Check the users role within the web project - - WebProjectStorePseudoFile webFolder = (WebProjectStorePseudoFile) pseudoFolder; - - int role = webFolder.getUserRole( curUserName); - - if ( role == WebProjectStorePseudoFile.RoleNone) - { - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug("User " + curUserName + " has no access to web project, " + webFolder.getFileName()); - - // User does not have access to this web project - - throw new AccessDeniedException("User " + curUserName + " has no access to web project, " + webFolder.getFileName()); - } - else if ( avmCtx.allowAdminStagingWrites() && cInfo.isAdministrator()) - { - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug("User " + curUserName + " granted write access to web project, " + webFolder.getFileName()); - - // Allow admin write access - - avmPath.setReadOnlyAccess( false); - } - else - { - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug("User " + curUserName + " granted read-only access to web project, " + webFolder.getFileName()); - - // Only allow read-only access to the staging area - - avmPath.setReadOnlyAccess( true); - } - } - else if ( pseudoFolder instanceof StorePseudoFile) - { - // Check the store type - - StorePseudoFile storeFolder = (StorePseudoFile) pseudoFolder; - if ( storeFolder.isStoreType() == StoreType.Normal) - return; - else if ( storeFolder.hasWebProject()) - { - // Get the web project that the sandbox is linked to - - WebProjectStorePseudoFile webFolder = (WebProjectStorePseudoFile) rootState.getPseudoFileList().findFile( storeFolder.getWebProject(), false); - - int role = webFolder.getUserRole( curUserName); - - if ( role == WebProjectStorePseudoFile.RoleNone) - { - // User does not have access to this web project - - throw new AccessDeniedException("User " + curUserName + " has no access to web project, " + webFolder.getFileName() + "/" + storeFolder.getFileName()); - } - else if ( role == WebProjectStorePseudoFile.RolePublisher && - storeFolder.getUserName().equalsIgnoreCase( curUserName) == false) - { - // User does not have access to this web project - - throw new AccessDeniedException("User " + curUserName + " has no access to web project, " + webFolder.getFileName() + "/" + storeFolder.getFileName()); - } - } - } - } - } - else - { - // Store does not exist - - throw new AccessDeniedException("Store does not exist, " + avmPath.getStoreName()); - } - - // DEBUG - - if (logger.isDebugEnabled()) - logger.debug( "Check access " + avmPath); - } - - /** - * Filter the list of pseudo folders returned in a search - * - * @param avmCtx AVMContext - * @param sess SrvSession - * @param avmPath AVMPath - * @param fstate FileState - * @return PseudoFileList - */ - private final PseudoFileList filterPseudoFolders( AVMContext avmCtx, SrvSession sess, AVMPath avmPath, FileState fstate) - { - // Check if the root folder file state has any store pseudo folders - - if ( fstate.hasPseudoFiles() == false) - return null; - - // Get the client details for the session - - ClientInfo cInfo = sess.getClientInformation(); - if ( cInfo == null || cInfo.getUserName() == null || cInfo.getUserName().length() == 0) - return null; - - // Check for the admin user, no need to filter the list - - PseudoFileList fullList = fstate.getPseudoFileList(); - if ( cInfo.isAdministrator()) - return fullList; - - // Create a filtered list of store pseudo folders that the user has access to - - PseudoFileList filterList = new PseudoFileList(); - String userName = m_authComponent.getCurrentUserName(); - - for ( int i = 0; i < fullList.numberOfFiles(); i++) - { - // Get the current store pseudo folder - - PseudoFile pseudoFolder = fullList.getFileAt( i); - - // Check if the pseudo folder is a web project folder or sandbox within a web project - - if ( pseudoFolder instanceof WebProjectStorePseudoFile) - { - // Check the users role within the web project - - WebProjectStorePseudoFile webFolder = (WebProjectStorePseudoFile) pseudoFolder; - - if ( avmCtx.showStagingStores() && webFolder.getUserRole( userName) != WebProjectStorePseudoFile.RoleNone) - { - // User has access to this store - - filterList.addFile( pseudoFolder); - } - } - else if ( pseudoFolder instanceof StorePseudoFile) - { - // Check if the store type should be included in the visible list - - StorePseudoFile storeFolder = (StorePseudoFile) pseudoFolder; - if ( avmCtx.showStoreType( storeFolder.isStoreType())) - { - // Check if the user has access to this store - - if ( storeFolder.hasWebProject()) - { - // Get the web project that the sandbox is linked to - - WebProjectStorePseudoFile webFolder = (WebProjectStorePseudoFile) fullList.findFile( storeFolder.getWebProject(), false); - - if ( webFolder != null) { - int role = webFolder.getUserRole( userName); - - if ( role == WebProjectStorePseudoFile.RoleContentManager && avmCtx.showStoreType( storeFolder.isStoreType())) - { - // User is a content manager, allow access to the store - - filterList.addFile( storeFolder); - } - else if ( role == WebProjectStorePseudoFile.RolePublisher && avmCtx.showStoreType( storeFolder.isStoreType())) - { - // Allow access if the user owns the current folder - - if ( storeFolder.getUserName().equalsIgnoreCase( userName)) - filterList.addFile( storeFolder); - } - } - else if ( logger.isDebugEnabled()) - logger.debug("Cannot find associated web folder for store " + storeFolder.getFileName()); - - } - else if ( avmCtx.showNormalStores() || avmCtx.showSiteStores()) - { - // Store is not linked to a web project, allow access to the store - - filterList.addFile( storeFolder); - } - } - } - } - - // Return the filtered list - - return filterList; - } - - /** - * Add a new store to the top level folder list - * - * @param avmCtx AVMContext - * @param storeName String - */ - protected void addNewStore( AVMContext avmCtx, String storeName) { - - // Get the root folder file state - - FileState fstate = avmCtx.getStateCache().findFileState( FileName.DOS_SEPERATOR_STR, true); - if ( fstate == null) - return; - - // Get the properties for the store - - AVMStoreDescriptor storeDesc = m_avmService.getStore( storeName); - if ( storeDesc == null) - return; - - Map props = m_avmService.getStoreProperties( storeName); - - // Check if the store is a main web project - - if ( props.containsKey( SandboxConstants.PROP_SANDBOX_STAGING_MAIN)) - { - // Get the noderef for the web project - - PropertyValue prop = props.get( SandboxConstants.PROP_WEB_PROJECT_NODE_REF); - if ( prop != null) { - - // Get the web project noderef - - NodeRef webNodeRef = new NodeRef( prop.getStringValue()); - - if (m_nodeService.exists(webNodeRef)) - { - // Create the web project pseudo folder - - WebProjectStorePseudoFile webProjFolder = new WebProjectStorePseudoFile( storeDesc, FileName.DOS_SEPERATOR_STR + storeName, webNodeRef); - fstate.addPseudoFile( webProjFolder); - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug( " Found web project " + webProjFolder.getFileName()); - - // Get the list of content managers for this web project - - List mgrAssocs = m_nodeService.getChildAssocs( webNodeRef, WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL); - - for ( ChildAssociationRef mgrRef : mgrAssocs) - { - // Get the child node and see if it is a content manager association - - NodeRef childRef = mgrRef.getChildRef(); - - if ( m_nodeService.getProperty( childRef, WCMAppModel.PROP_WEBUSERROLE).equals(ROLE_CONTENT_MANAGER)) - { - // Get the user name add it to the web project pseudo folder - - String userName = (String) m_nodeService.getProperty( childRef, WCMAppModel.PROP_WEBUSERNAME); - - webProjFolder.addUserRole( userName, WebProjectStorePseudoFile.RoleContentManager); - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug(" Added content manager " + userName); - } - } - } - else - { - logger.warn("AVM Store '"+storeName+"' with webProjectNodeRef that does not exist: "+webNodeRef); - } - } - } - else - { - // Check if this store is a web project sandbox - - int storeType = StoreType.Normal; - String webProjName = null; - String userName = null; - - if ( props.containsKey( SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN)) - { - // Sandbox store, linked to a web project - - storeType = StoreType.WebAuthorMain; - - // Get the associated web project name - - webProjName = props.get( SandboxConstants.PROP_WEBSITE_NAME).getStringValue(); - - // Get the user name from teh store name - - userName = storeName.substring( webProjName.length() + 2); - } - else if ( props.containsKey( SandboxConstants.PROP_SANDBOX_AUTHOR_PREVIEW)) - { - // Author preview sandbox store, linked to a web project - - storeType = StoreType.WebAuthorPreview; - - // Get the associated web project name - - String projPlusUser = storeName.substring( 0, storeName.length() - "--preview".length()); - int pos = projPlusUser.lastIndexOf("--"); - if ( pos != -1) - { - webProjName = projPlusUser.substring( 0, pos); - userName = projPlusUser.substring(pos + 2); - } - } - else if ( props.containsKey( SandboxConstants.PROP_SANDBOX_WORKFLOW_PREVIEW)) - { - // Staging preview sandbox store, linked to a web project - - storeType = StoreType.WebStagingPreview; - } - else if ( props.containsKey( SandboxConstants.PROP_SANDBOX_STAGING_PREVIEW)) - { - // Staging preview sandbox store, linked to a web project - - storeType = StoreType.WebStagingPreview; - - // Get the associated web project name - - webProjName = storeName.substring( 0, storeName.length() - "--preview".length()); - } - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug( " Store " + storeDesc.getName() + ", type=" + StoreType.asString( storeType) + ", webproj=" + webProjName + ", username=" + userName); - - // Add a pseudo file for the current store - - if ( avmCtx.showStoreType( storeType)) - { - // Create the pseudo folder for the store - - StorePseudoFile storeFolder = new StorePseudoFile( storeDesc, FileName.DOS_SEPERATOR_STR + storeName, storeType); - if ( storeType != StoreType.Normal) - { - storeFolder.setWebProject( webProjName); - storeFolder.setUserName( userName); - - // Add all publisher/reviewer user names to the web project roles list - - if ( storeFolder.hasWebProject()) - { - // Find the associated web project pseudo folder - - PseudoFileList folderList = fstate.getPseudoFileList(); - if ( folderList != null) { - - // Find the associated web project - - WebProjectStorePseudoFile webProj = (WebProjectStorePseudoFile) folderList.findFile( storeFolder.getWebProject(), true); - - if ( webProj != null) { - - // Strip the web project name from the sandbox store name and extract the user name. - // Add the user as a publisher/reviewer to the web project roles list - - userName = storeFolder.getFileName().substring( webProj.getFileName().length() + 2); - - // If the user does not have a content manager role then add as a publisher - - if ( webProj.getUserRole( userName) == WebProjectStorePseudoFile.RoleNone) - { - webProj.addUserRole( userName, WebProjectStorePseudoFile.RolePublisher); - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug( " Added publisher " + userName + " to " + webProj.getFileName()); - } - } - } - } - } - - // Add the store pseudo folder to the root folder file list - - fstate.addPseudoFile( storeFolder); - } - } - } -} diff --git a/source/java/org/alfresco/filesys/avm/AVMNetworkFile.java b/source/java/org/alfresco/filesys/avm/AVMNetworkFile.java deleted file mode 100644 index 800922534d..0000000000 --- a/source/java/org/alfresco/filesys/avm/AVMNetworkFile.java +++ /dev/null @@ -1,565 +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 . */ - -package org.alfresco.filesys.avm; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.filesys.alfresco.AlfrescoNetworkFile; -import org.alfresco.jlan.server.filesys.AccessDeniedException; -import org.alfresco.jlan.server.filesys.DiskFullException; -import org.alfresco.jlan.server.filesys.FileAttribute; -import org.alfresco.jlan.server.filesys.NetworkFile; -import org.alfresco.jlan.smb.SeekType; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.repo.transaction.AlfrescoTransactionSupport; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.TransactionListenerAdapter; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMService; -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.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.usage.ContentQuotaException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * AVM Network File Class - * - *

Holds the details of an open file, and provides access to the file data. - * - * @author GKSpencer - */ -public class AVMNetworkFile extends AlfrescoNetworkFile { - - // Logging - - private static final Log logger = LogFactory.getLog(AVMNetworkFile.class); - - // Node Service - - private NodeService m_nodeService; - - // AVM service - - private AVMService m_avmService; - - // AVM path to the file/folder and store version - - private String m_avmPath; - private int m_avmVersion; - - // Flag to indicate if the file has been modified - - private boolean m_modified; - - // Access to the file data, flag to indicate if the file channel is writable - - private FileChannel m_channel; - private ContentWriter m_content; - - private boolean m_writable; - - // Mime type, if a writer is opened - - private String m_mimeType; - - /** - * Class constructor - * - * @param details AVMNodeDescriptor - * @param avmPath String - * @param avmVersion int - * @param nodeService NodeService - * @param avmService AVMService - */ - public AVMNetworkFile( AVMNodeDescriptor details, String avmPath, int avmVersion, NodeService nodeService, AVMService avmService) - { - super( details.getName()); - - // Save the service, apth and version - - m_nodeService = nodeService; - m_avmService = avmService; - m_avmPath = avmPath; - m_avmVersion = avmVersion; - - // Copy the file details - - setAccessDate( details.getAccessDate()); - setCreationDate( details.getCreateDate()); - setModifyDate( details.getModDate()); - - if ( details.isFile()) - setFileSize( details.getLength()); - else - setFileSize( 0L); - - int attr = 0; - - if ( details.isDirectory()) - attr += FileAttribute.Directory; - - if ( avmVersion != AVMContext.VERSION_HEAD) - attr += FileAttribute.ReadOnly; - - setAttributes( attr); - } - - /** - * Check if there is an open file channel to the content - * - * @return boolean - */ - public final boolean hasContentChannel() - { - return m_channel != null ? true : false; - } - - /** - * Return the mime type - * - * @return String - */ - public final String getMimeType() - { - return m_mimeType; - } - - /** - * Set the mime type - * - * @param mimeType String - */ - public final void setMimeType(String mimeType) - { - m_mimeType = mimeType; - } - - /** - * Open the file - * - * @param createFlag boolean - * @exception IOException - */ - public void openFile(boolean createFlag) - throws IOException - { - // Nothing to do, content is opened on first read/write - } - - /** - * Read from the file. - * - * @param buf byte[] - * @param len int - * @param pos int - * @param fileOff long - * @return Length of data read. - * @exception IOException - */ - public int readFile(byte[] buf, int len, int pos, long fileOff) - throws java.io.IOException - { - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug("Read file " + getName() + ", len=" + len + ", offset=" + fileOff); - - // Open the channel for reading - - openContent(false, false); - - // Read from the channel - - ByteBuffer byteBuffer = ByteBuffer.wrap(buf, pos, len); - int count = m_channel.read(byteBuffer, fileOff); - if (count < 0) - { - // Return a zero count at end of file - - count = 0; - } - - // Return the length of data read - - return count; - } - - /** - * Write a block of data to the file. - * - * @param buf byte[] - * @param len int - * @param pos int - * @param fileOff long - * @exception IOException - */ - public void writeFile(byte[] buf, int len, int pos, long fileOff) - throws java.io.IOException - { - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug("Write file " + getName() + ", len=" + len + ", offset=" + fileOff); - - // Open the channel for writing - - openContent(true, false); - - // Write to the channel - - ByteBuffer byteBuffer = ByteBuffer.wrap(buf, pos, len); - m_channel.write(byteBuffer, fileOff); - - // Set modification flag - - m_modified = true; - incrementWriteCount(); - - // Update the current file size - - setFileSize( m_channel.size()); - } - - /** - * Seek to the specified file position. - * - * @param pos long - * @param typ int - * @return int - * @exception IOException - */ - public long seekFile(long pos, int typ) - throws IOException - { - // Open the file, if not already open - - openContent( false, false); - - // Check if the current file position is the required file position - - long curPos = m_channel.position(); - - switch (typ) { - - // From start of file - - case SeekType.StartOfFile : - if (curPos != pos) - m_channel.position( pos); - break; - - // From current position - - case SeekType.CurrentPos : - m_channel.position( curPos + pos); - break; - - // From end of file - - case SeekType.EndOfFile : - { - long newPos = m_channel.size() + pos; - m_channel.position(newPos); - } - break; - } - - // Return the new file position - - return m_channel.position(); - } - - /** - * Flush any buffered output to the file - * - * @throws IOException - */ - public void flushFile() - throws IOException - { - // If the file channel is open for write then flush the channel - - if ( m_channel != null && m_writable) - m_channel.force( false); - } - - /** - * Truncate the file to the specified file size - * - * @param siz long - * @exception IOException - */ - public void truncateFile(long siz) - throws IOException - { - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug("Truncate file " + getName() + ", size=" + siz); - - // If the content data channel has not been opened yet and the requested size is zero - // then this is an open for overwrite so the existing content data is not copied - - if ( m_channel == null && siz == 0L) - { - // Open content for overwrite, no need to copy existing content data - - openContent(true, true); - } - else - { - // Normal open for write - - openContent(true, false); - - // Truncate or extend the channel - - m_channel.truncate(siz); - } - - // Set modification flag - - m_modified = true; - incrementWriteCount(); - } - - /** - * Close the database file - */ - public void closeFile() - throws IOException - { - // If the file is a directory or the file channel has not been opened then there is nothing to do - - if ( isDirectory() || m_channel == null && m_content == null) - return; - - // We may be in a retry block, in which case this section will already have executed and channel will be null - if (m_channel != null) - { - // Close the file channel - - try - { - m_channel.close(); - m_channel = null; - } - catch ( IOException ex) - { - if (RetryingTransactionHelper.extractRetryCause(ex) != null) - { - throw ex; - } - logger.error("Failed to close file channel for " + getName(), ex); - } - - } - - if (m_content != null) - { - // Retrieve the content data and stop the content URL from being 'eagerly deleted', in case we need to - // retry the transaction - - final ContentData contentData = m_content.getContentData(); - - try - { - NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, m_avmPath); - m_nodeService.setProperty(nodeRef, ContentModel.PROP_CONTENT, contentData); - } - catch (ContentQuotaException qe) - { - throw new DiskFullException(qe.getMessage()); - } - - // Tidy up after ourselves after a successful commit. Otherwise leave things to allow a - AlfrescoTransactionSupport.bindListener(new TransactionListenerAdapter() - { - @Override - public void afterCommit() - { - m_content = null; - } - }); - } - } - - /** - * Open a file channel to the file content, switching to a writable file channel if required. - * - * @param write boolean - * @param trunc boolean - * @throws AccessDeniedException If this network file is read only - * @throws AlfrescoRuntimeException If this network file represents a directory - */ - private void openContent(boolean write, boolean trunc) - throws AccessDeniedException, AlfrescoRuntimeException - { - // Check if this network file is a directory, no content to open - - if ( isDirectory()) - throw new AlfrescoRuntimeException("Unable to open channel for a directory network file: " + this); - - // Check if write access is required and the current channel is read-only - - long curPos = 0L; - - if ( write && m_writable == false && m_channel != null) - { - // Close the existing read-only channel - - try - { - // Save the current file position - - curPos = m_channel.position(); - - // Close the read-only file channel - - m_channel.close(); - m_channel = null; - } - catch (IOException ex) - { - logger.error("Error closing read-only channel", ex); - } - - // Debug - - if ( logger.isDebugEnabled()) - logger.debug("Switching to writable channel for " + getName()); - } - else if ( m_channel != null) - { - // File channel already open - - return; - } - - // We need to create the channel - - if (write && getGrantedAccess() <= NetworkFile.READONLY) - throw new AccessDeniedException("The network file was created for read-only: " + this); - - // Access the content data and get a file channel to the data - - if ( write ) - { - // Access the content data for write - - m_content = null; - - try { - - // Create a writer to access the file data - - m_content = m_avmService.getContentWriter(m_avmPath, false); - - // Set the mime-type - - m_content.setMimetype( getMimeType()); - } - catch (Exception ex) { - logger.debug( ex); - ex.printStackTrace(); - - // Rethrow exception, convert to access denied - - throw new AccessDeniedException("Failed to open file for write access, " + m_avmPath); - } - - // Indicate that we have a writable channel to the file - - m_writable = true; - - // Get the writable channel, do not copy existing content data if the file is to be truncated - - m_channel = m_content.getFileChannel( trunc); - - // Reset the file position to match the read-only file channel position, unless we truncated the file - - if ( curPos != 0L && trunc == false) - { - try - { - m_channel.position( curPos); - } - catch (IOException ex) - { - logger.error("Failed to set file position for " + getName(), ex); - } - } - } - else - { - // Access the content data for read - - ContentReader cReader = m_avmService.getContentReader( m_avmVersion, m_avmPath); - - // Indicate that we only have a read-only channel to the data - - m_writable = false; - - // Get the read-only channel - - m_channel = cReader.getFileChannel(); - } - } - - /** - * Return the writable state of the content channel - * - * @return boolean - */ - public final boolean isWritable() - { - return m_writable; - } - - /** - * Return the network file details as a string - * - * @return String - */ - public String toString() - { - StringBuilder str = new StringBuilder(); - - str.append( "["); - str.append( getName()); - str.append( ":"); - str.append( isDirectory() ? "Dir," : "File,"); - str.append( getFileSize()); - str.append( "-Channel="); - str.append( m_channel); - str.append( m_writable ? ",Write" : ",Read"); - str.append( m_modified ? ",Modified" : ""); - str.append( "]"); - - return str.toString(); - } -} diff --git a/source/java/org/alfresco/filesys/avm/AVMPath.java b/source/java/org/alfresco/filesys/avm/AVMPath.java deleted file mode 100644 index 62c26e56d1..0000000000 --- a/source/java/org/alfresco/filesys/avm/AVMPath.java +++ /dev/null @@ -1,727 +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 . */ - -package org.alfresco.filesys.avm; - -import org.alfresco.jlan.server.filesys.FileName; - -/** - * AVM Path Class - * - *

Parses a share relative path into store, version and remaining path values. - * - * @author gkspencer - */ -public class AVMPath { - - // Constants - // - // Invalid version id value - - private static final int InvalidVersionId = -2; - - // Version id string for the head version - - public static final String VersionNameHead = "HEAD"; - - // Folder name for the versions folder - - public static final String VersionsFolder = "VERSION"; - - // Head and version sub-folders - - public static final String DataFolder = "DATA"; - public static final String MetaDataFolder = "METADATA"; - - // Version folder prefix - - public static final String VersionFolderPrefix = "v"; - - // AVM path seperator - - public static final char AVM_SEPERATOR = '/'; - public static final String AVM_SEPERATOR_STR = "/"; - - // Level identifiers - - public enum LevelId { Invalid, Root, StoreRoot, Head, HeadData, HeadMetaData, VersionRoot, Version, VersionData, VersionMetaData, StoreRootPath, StorePath }; - - // Level identifier for this path - - private LevelId m_levelId = LevelId.Invalid; - - // Store name - - private String m_storeName; - - // Version id - - private int m_version = InvalidVersionId; - - // Remaining path - - private String m_path; - - // AVM style path - - private String m_avmPath; - - // Path is read-only access - - private boolean m_readOnly; - - /** - * Default constructor - */ - public AVMPath() - { - } - - /** - * Class constructor - * - *

Construct an AVM path for the virtualization view, with store and version folders - * - * @param shrPath String - */ - public AVMPath(String shrPath) - { - // Parse the path - - parsePath( shrPath); - } - - /** - * Class constructor - * - *

Construct an AVM path for a standard view onto a store/version - * - * @param storeName String - * @param version int - * @param path String - */ - public AVMPath(String storeName, int version, String path) - { - // Parse the path - - parsePath( storeName, version, path); - } - - /** - * Return the level id for the path - * - * @return LevelId - */ - public LevelId isLevel() - { - return m_levelId; - } - - /** - * Check if the path is read-only - * - * @return boolean - */ - public final boolean isReadOnlyAccess() { - return m_readOnly; - } - - /** - * Return the store name - * - * @return String - */ - public final String getStoreName() - { - return m_storeName; - } - - /** - * Check if the version id was specified in the path - * - * @return boolean - */ - public final boolean hasVersion() - { - return m_version != InvalidVersionId ? true : false; - } - - /** - * Return the version id - * - * @return int - */ - public final int getVersion() - { - return m_version; - } - - /** - * Return the version as a string - * - * @return String - */ - public final String getVersionString() - { - if ( m_version == -1) - return VersionNameHead; - return "" + m_version; - } - - /** - * Check if there is a share relative path - * - * @return boolean - */ - public final boolean hasRelativePath() - { - return m_path != null ? true : false; - } - - /** - * Return the share relative path - * - * @return String - */ - public final String getRelativePath() - { - return m_path; - } - - /** - * Return the AVM style path, in :/ format - * - * @return String - */ - public final String getAVMPath() - { - return m_avmPath; - } - - /** - * Check if the path is valid - * - * @return boolean - */ - public final boolean isValid() - { - return m_levelId == LevelId.Invalid ? false : true; - } - - /** - * Check if the path is to a pseudo folder in the virtualization view - * - * @return boolean - */ - public final boolean isPseudoPath() - { - return m_levelId == LevelId.Invalid || m_levelId == LevelId.StorePath || m_levelId == LevelId.StoreRootPath ? false : true; - } - - /** - * Check if hte path is a read-only part of the pseudo folder tree - * - * @return boolean - */ - public final boolean isReadOnlyPseudoPath() - { - if ( isLevel() == LevelId.Root || isLevel() == LevelId.StoreRoot || isLevel() == LevelId.VersionRoot || - isLevel() == LevelId.Head || isLevel() == LevelId.Version) - return true; - return false; - } - - /** - * Check if the path is the root path - * - * @return boolean - */ - public final boolean isRootPath() - { - return m_levelId == LevelId.Root ? true : false; - } - - /** - * Parse the path, for the virtualization view onto all stores/versions - * - * @param path String - */ - public final void parsePath( String path) - { - // Clear current settings - - m_storeName = null; - m_version = InvalidVersionId; - m_path = null; - m_avmPath = null; - - // Split the path - - String[] paths = FileName.splitAllPaths(path); - - if ( paths == null || paths.length == 0) - { - m_path = FileName.DOS_SEPERATOR_STR; - m_levelId = LevelId.Root; - return; - } - - // Set the store name - - m_storeName = paths[0]; - m_levelId = LevelId.StoreRoot; - - if ( paths.length > 1) - { - // Validate the next element, should be either the HEAD or VERSIONS folder - - String levelStr = paths[1]; - - if ( levelStr.equalsIgnoreCase( VersionNameHead)) - { - m_version = -1; - m_levelId = LevelId.Head; - } - else if ( levelStr.equalsIgnoreCase( VersionsFolder)) - { - m_levelId = LevelId.VersionRoot; - } - else - { - // Invalid folder at the current level - - m_levelId = LevelId.Invalid; - return; - } - - // Check the next level, if available - - if ( paths.length > 2) - { - // If the previous level is the versions root then the next level should be a - // version id folder - - String folderName = paths[2]; - int pathIdx = 3; - - if ( isLevel() == LevelId.VersionRoot) - { - // Check that the folder name starts with the version folder prefix - - if ( folderName != null && folderName.startsWith( VersionFolderPrefix) && - folderName.length() > VersionFolderPrefix.length()) - { - try - { - // Parse the version id - - m_version = Integer.parseInt( folderName.substring( VersionFolderPrefix.length())); - m_levelId = LevelId.Version; - - // Validate the version id - - if ( m_version < -1) - { - // Invalid version id - - m_levelId = LevelId.Invalid; - return; - } - } - catch ( NumberFormatException ex) - { - m_levelId = LevelId.Invalid; - return; - } - - // Check for the next level - - if ( paths.length > 3) - { - // Get the next level name - - folderName = paths[3]; - pathIdx++; - - // Check for the data folder - - if ( folderName.equalsIgnoreCase( DataFolder)) - { - m_levelId = LevelId.VersionData; - - // Set the path to the root of the store - - m_path = FileName.DOS_SEPERATOR_STR; - } - else if ( folderName.equalsIgnoreCase( MetaDataFolder)) - { - m_levelId = LevelId.VersionMetaData; - - // Set the path to the root of the metadata - - m_path = FileName.DOS_SEPERATOR_STR; - } - else - { - m_levelId = LevelId.Invalid; - return; - } - } - } - else - { - m_levelId = LevelId.Invalid; - return; - } - } - - // If the previous level is head the next level should be the data or metadata folder - - else if ( isLevel() == LevelId.Head) - { - // Check for the data folder - - if ( folderName.equalsIgnoreCase( DataFolder)) - { - m_levelId = LevelId.HeadData; - - // Set the path to the root of the store - - m_path = FileName.DOS_SEPERATOR_STR; - } - else if ( folderName.equalsIgnoreCase( MetaDataFolder)) - { - m_levelId = LevelId.HeadMetaData; - - // Set the path to the root of the metadata - - m_path = FileName.DOS_SEPERATOR_STR; - } - else - { - m_levelId = LevelId.Invalid; - return; - } - } - - // If there are remaining paths then build a relative path - if ( paths.length > pathIdx) - { - StringBuilder pathStr = new StringBuilder(); - - for ( int i = pathIdx; i < paths.length; i++) - { - pathStr.append( FileName.DOS_SEPERATOR); - pathStr.append( paths[i]); - } - - m_path = pathStr.toString(); - - // ALF-1719: make "www" and "avm_webapps" read only by setting their level to - // StoreRootPath (which is checked in AVMDiskDriver.checkPathAccess). - String lastPath = paths[paths.length-1].toLowerCase(); - if(lastPath.equals("www") || lastPath.equals("avm_webapps")) - { - // Set the level to indicate a store root path i.e. "www", - // "avm_webapps" - m_levelId = LevelId.StoreRootPath; - } - else - { - // Set the level to indicate a store relative path - m_levelId = LevelId.StorePath; - } - } - - // Build the AVM path, in :/ format - - if ( m_path != null) - { - StringBuilder pathStr = new StringBuilder(); - - pathStr.append( m_storeName); - pathStr.append( ":"); - pathStr.append( m_path.replace( FileName.DOS_SEPERATOR, AVM_SEPERATOR)); - - m_avmPath = pathStr.toString(); - } - } - } - } - - /** - * Parse the path, to generate a path for a single store/version - * - * @param storeName String - * @param version int - * @param path String - */ - public final void parsePath( String storeName, int version, String path) - { - // Clear current settings - - m_levelId = LevelId.Invalid; - - m_storeName = null; - m_version = InvalidVersionId; - m_path = null; - m_avmPath = null; - - // Set the store/version - - m_storeName = storeName; - m_version = version; - - // Save the relative path - - m_path = path; - - // Build the store path - - StringBuilder avmPath = new StringBuilder(); - avmPath.append( m_storeName); - - if ( storeName.indexOf( ":") == -1) - avmPath.append( ":"); - - if ( path == null || path.length() == 0) - { - avmPath.append( AVM_SEPERATOR); - - // Set the share relative path as the root path - - m_path = FileName.DOS_SEPERATOR_STR; - } - else - { - if ( path.startsWith( FileName.DOS_SEPERATOR_STR) == false) - avmPath.append( AVM_SEPERATOR); - - avmPath.append( path.replace( FileName.DOS_SEPERATOR, AVM_SEPERATOR)); - } - - m_avmPath = avmPath.toString(); - - // Indicate that the path is to a store relative path - - String lowerPath = path.toLowerCase(); - String[] paths = FileName.splitAllPaths(lowerPath); - if(paths[paths.length - 1].equals("www") || paths[paths.length - 1].equals("avm_webapps")) - { - // Set the level to indicate a store root path i.e. "www", - // "avm_webapps" - m_levelId = LevelId.StoreRootPath; - } - else - { - m_levelId = LevelId.StorePath; - } - } - - /** - * Generate a file id for the path - * - * @return int - */ - public final int generateFileId() - { - // Check if the path is a store path or pseudo path - - int fid = -1; - - if ( isLevel() == LevelId.StorePath || isLevel() == LevelId.StoreRootPath) - { - // Use the share relative path to generate the file id - - fid = getRelativePath().hashCode(); - } - else if ( isPseudoPath()) - { - // Create a relative path to the pseudo folder - - StringBuilder relStr = new StringBuilder(); - relStr.append( FileName.DOS_SEPERATOR); - - switch( isLevel()) - { - case StoreRoot: - relStr.append( getStoreName()); - break; - case Head: - relStr.append( getStoreName()); - relStr.append( FileName.DOS_SEPERATOR); - relStr.append( AVMPath.VersionNameHead); - break; - case HeadData: - relStr.append( getStoreName()); - relStr.append( FileName.DOS_SEPERATOR); - relStr.append( AVMPath.VersionNameHead); - relStr.append( FileName.DOS_SEPERATOR); - relStr.append( AVMPath.DataFolder); - break; - case HeadMetaData: - relStr.append( getStoreName()); - relStr.append( FileName.DOS_SEPERATOR); - relStr.append( AVMPath.VersionNameHead); - relStr.append( FileName.DOS_SEPERATOR); - relStr.append( AVMPath.MetaDataFolder); - break; - case VersionRoot: - relStr.append( getStoreName()); - relStr.append( FileName.DOS_SEPERATOR); - relStr.append( AVMPath.VersionsFolder); - break; - case Version: - relStr.append( getStoreName()); - relStr.append( FileName.DOS_SEPERATOR); - relStr.append( AVMPath.VersionsFolder); - relStr.append( FileName.DOS_SEPERATOR); - relStr.append( AVMPath.VersionFolderPrefix); - relStr.append( getVersion()); - break; - case VersionData: - relStr.append( getStoreName()); - relStr.append( FileName.DOS_SEPERATOR); - relStr.append( AVMPath.VersionsFolder); - relStr.append( FileName.DOS_SEPERATOR); - relStr.append( AVMPath.VersionFolderPrefix); - relStr.append( getVersion()); - relStr.append( FileName.DOS_SEPERATOR); - relStr.append( AVMPath.DataFolder); - break; - case VersionMetaData: - relStr.append( getStoreName()); - relStr.append( FileName.DOS_SEPERATOR); - relStr.append( AVMPath.VersionsFolder); - relStr.append( FileName.DOS_SEPERATOR); - relStr.append( AVMPath.VersionFolderPrefix); - relStr.append( getVersion()); - relStr.append( FileName.DOS_SEPERATOR); - relStr.append( AVMPath.MetaDataFolder); - break; - } - - // Generate the file id using the pseudo folder relative path - - fid = relStr.toString().hashCode(); - } - - // Return the file id - - return fid; - } - - /** - * Set the path access, true for read-only access - * - * @param access boolean - */ - public final void setReadOnlyAccess( boolean readOnly) - { - m_readOnly = readOnly; - } - - /** - * Return the AVM path details as a string - * - * @return String - */ - public String toString() - { - StringBuilder str = new StringBuilder(); - - switch ( m_levelId) - { - case Invalid: - str.append("[Invalid"); - break; - case Root: - str.append("[Root"); - break; - case StoreRoot: - str.append("[StoresRoot"); - break; - case Head: - str.append("["); - str.append(getStoreName()); - str.append(":HEAD"); - break; - case HeadData: - str.append("["); - str.append(getStoreName()); - str.append(":HEAD\\"); - str.append( DataFolder); - break; - case HeadMetaData: - str.append("["); - str.append(getStoreName()); - str.append(":HEAD\\"); - str.append( MetaDataFolder); - break; - case VersionRoot: - str.append("["); - str.append(getStoreName()); - str.append(":Versions"); - break; - case Version: - str.append("["); - str.append(getStoreName()); - str.append(":"); - str.append(VersionFolderPrefix); - str.append(getVersion()); - break; - case VersionData: - str.append("["); - str.append(getStoreName()); - str.append(":"); - str.append(VersionFolderPrefix); - str.append(getVersion()); - str.append("\\"); - str.append( DataFolder); - break; - case VersionMetaData: - str.append("["); - str.append(getStoreName()); - str.append(":"); - str.append(VersionFolderPrefix); - str.append(getVersion()); - str.append("\\"); - str.append( MetaDataFolder); - break; - case StoreRootPath: - case StorePath: - str.append("["); - str.append(getStoreName()); - str.append(":"); - str.append(VersionFolderPrefix); - str.append(getVersion()); - str.append(","); - str.append(getRelativePath()); - str.append(":"); - str.append(getAVMPath()); - break; - } - - if ( isReadOnlyAccess()) - str.append("-ReadOnly"); - - str.append("]"); - - return str.toString(); - } -} diff --git a/source/java/org/alfresco/filesys/avm/AVMSearchContext.java b/source/java/org/alfresco/filesys/avm/AVMSearchContext.java deleted file mode 100644 index 232626335d..0000000000 --- a/source/java/org/alfresco/filesys/avm/AVMSearchContext.java +++ /dev/null @@ -1,324 +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 . */ - -package org.alfresco.filesys.avm; - -import org.alfresco.jlan.server.filesys.FileAttribute; -import org.alfresco.jlan.server.filesys.FileInfo; -import org.alfresco.jlan.server.filesys.FileName; -import org.alfresco.jlan.server.filesys.SearchContext; -import org.alfresco.jlan.util.WildCard; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; - -/** - * AVM Filesystem Search Context Class - * - *

Contains the details of a wildcard folder search. - * - * @author GKSpencer - */ -public class AVMSearchContext extends SearchContext { - - // File list and current index - - private AVMNodeDescriptor[] m_fileList; - private int m_fileIdx; - - // File attributes - - private int m_attrib; - - // Optional wildcard filter - - private WildCard m_filter; - - // Relative path to the parent folder being searched - - private String m_parentPath; - - // Mark all files/folders as read-only - - private boolean m_readOnly; - - /** - * Class constructor - * - * @param fileList SortedMap - * @param attrib int - * @param filter WildCard - * @param parentPath String - * @param readOnly boolean - */ - public AVMSearchContext( AVMNodeDescriptor[] fileList, int attrib, WildCard filter, String parentPath, boolean readOnly) - { - m_attrib = attrib; - m_filter = filter; - m_fileList = fileList; - - m_parentPath = parentPath; - if ( m_parentPath != null && m_parentPath.endsWith( FileName.DOS_SEPERATOR_STR) == false) - m_parentPath = m_parentPath + FileName.DOS_SEPERATOR_STR; - - m_readOnly = readOnly; - } - - /** - * Determine if there are more files for the active search. - * - * @return boolean - */ - public boolean hasMoreFiles() - { - return m_fileIdx < m_fileList.length ? true : false; - } - - /** - * Return file information for the next file in the active search. Returns false if the search - * is complete. - * - * @param info FileInfo to return the file information. - * @return true if the file information is valid, else false - */ - public boolean nextFileInfo(FileInfo info) - { - // Check if there is another file record to return - - if ( m_fileIdx >= m_fileList.length) - return false; - - // Search for the next valid file - - boolean foundMatch = false; - AVMNodeDescriptor curFile = null; - - while (foundMatch == false && m_fileIdx < m_fileList.length) - { - // Get the next file from the list - - curFile = m_fileList[ m_fileIdx++]; - - // Check if the file name matches the search pattern - - if ( m_filter.matchesPattern(curFile.getName()) == true) - { - - // Check if the file matches the search attributes - - if (FileAttribute.hasAttribute(m_attrib, FileAttribute.Directory) && - curFile.isDirectory()) - { - - // Found a match - - foundMatch = true; - } - else if ( curFile.isFile()) - { - - // Found a match - - foundMatch = true; - } - - // Check if we found a match - - if ( foundMatch == false) - { - - // Get the next file from the list - - if ( ++m_fileIdx < m_fileList.length) - curFile = m_fileList[ m_fileIdx]; - } - } - } - - // If we found a match then fill in the file information - - if ( foundMatch) - { - // Fill in the file information - - info.setFileName( curFile.getName()); - - if ( curFile.isFile()) - { - info.setFileSize( curFile.getLength()); - info.setAllocationSize((curFile.getLength() + 512L) & 0xFFFFFFFFFFFFFE00L); - } - else - info.setFileSize( 0L); - - info.setAccessDateTime( curFile.getAccessDate()); - info.setCreationDateTime( curFile.getCreateDate()); - info.setModifyDateTime( curFile.getModDate()); - - // Build the file attributes - - int attr = 0; - - if ( curFile.isDirectory()) - attr += FileAttribute.Directory; - - if ( curFile.getName().startsWith( ".") || - curFile.getName().equalsIgnoreCase( "Desktop.ini") || - curFile.getName().equalsIgnoreCase( "Thumbs.db")) - attr += FileAttribute.Hidden; - - if ( isReadOnly()) - attr += FileAttribute.ReadOnly; - - if ( attr == 0) - attr = FileAttribute.NTNormal; - - info.setFileAttributes( attr); - - // Generate a file id for the current file - - StringBuilder pathStr = new StringBuilder( m_parentPath); - pathStr.append ( curFile.getName()); - - info.setFileId( pathStr.toString().hashCode()); - } - - // Indicate if the file information is valid - - return foundMatch; - } - - /** - * Return the file name of the next file in the active search. Returns null is the search is - * complete. - * - * @return String - */ - public String nextFileName() - { - // Check if there is another file record to return - - // Find the next matching file name - - while ( m_fileIdx < m_fileList.length) { - - // Check if the current file name matches the search pattern - - String fname = m_fileList[m_fileIdx++].getName(); - - if ( m_filter.matchesPattern(fname)) - return fname; - } - - // No more matching file names - - return null; - } - - /** - * Return the total number of file entries for this search if known, else return -1 - * - * @return int - */ - public int numberOfEntries() - { - return m_fileList.length; - } - - /** - * Return the resume id for the current file/directory in the search. - * - * @return int - */ - public int getResumeId() - { - return m_fileIdx; - } - - /** - * Restart a search at the specified resume point. - * - * @param resumeId Resume point id. - * @return true if the search can be restarted, else false. - */ - public boolean restartAt(int resumeId) - { - // Range check the resume id - - int resId = resumeId - 1; - - if ( resId < 0 || resId >= m_fileList.length) - return false; - - // Reset the current file index - - m_fileIdx = resId; - return true; - } - - /** - * Restart the current search at the specified file. - * - * @param info File to restart the search at. - * @return true if the search can be restarted, else false. - */ - public boolean restartAt(FileInfo info) - { - // Search backwards from the current file - - int curFileIdx = m_fileIdx; - - if (m_fileIdx >= m_fileList.length) - { - m_fileIdx = m_fileList.length - 1; - } - - while ( m_fileIdx > 0) { - - // Check if the current file is the required search restart point - - if ( m_fileList[ m_fileIdx].getName().equals( info.getFileName())) - return true; - else - m_fileIdx--; - } - - // Failed to find the restart file - - m_fileIdx = curFileIdx; - return false; - } - - /** - * Check if all files/folders returned by the search should be marked as read-only - * - * @return boolean - */ - public final boolean isReadOnly() - { - return m_readOnly; - } - - /** - * Set all files/folders returned by the search as read-only - * - * @param readOnly boolean - */ - public final void setReadOnly( boolean readOnly) - { - m_readOnly = readOnly; - } -} diff --git a/source/java/org/alfresco/filesys/avm/AVMShareMapper.java b/source/java/org/alfresco/filesys/avm/AVMShareMapper.java deleted file mode 100644 index bd72faa1f4..0000000000 --- a/source/java/org/alfresco/filesys/avm/AVMShareMapper.java +++ /dev/null @@ -1,393 +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 . */ - -package org.alfresco.filesys.avm; - -import java.util.Enumeration; - -import org.springframework.extensions.config.ConfigElement; -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.filesys.config.ServerConfigurationBean; -import org.alfresco.jlan.server.SrvSession; -import org.alfresco.jlan.server.config.InvalidConfigurationException; -import org.alfresco.jlan.server.config.ServerConfiguration; -import org.alfresco.jlan.server.core.InvalidDeviceInterfaceException; -import org.alfresco.jlan.server.core.ShareMapper; -import org.alfresco.jlan.server.core.ShareType; -import org.alfresco.jlan.server.core.SharedDevice; -import org.alfresco.jlan.server.core.SharedDeviceList; -import org.alfresco.jlan.server.filesys.DiskSharedDevice; -import org.alfresco.jlan.server.filesys.FilesystemsConfigSection; -import org.alfresco.jlan.util.StringList; -import org.alfresco.service.cmr.avm.AVMNotFoundException; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.avm.AVMWrongTypeException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; - -/** - * AVM Filesystem Share Mapper Class - * - *

Provides access to store versions using the share name '_'. - * - * @author gkspencer - */ -public class AVMShareMapper implements ShareMapper, InitializingBean { - - // Logging - - private static final Log logger = LogFactory.getLog("org.alfresco.smb.protocol"); - - // Regular expression to test for AVM versioned share name - - private static final String AVM_SHAREPATTERN = "[a-zA-Z0-9-]*_[0-9]+"; - - // Server configuration - - private ServerConfiguration m_config; - private FilesystemsConfigSection m_filesysConfig; - - // List of available AVM shares - - private StringList m_avmShareNames; - - // Filesystem driver to be used to create home shares - - private AVMDiskDriver m_driver; - - // Debug enable flag - - private boolean m_debug; - - /** - * Default constructor - */ - public AVMShareMapper() - { - } - - public void setServerConfiguration(ServerConfiguration config) - { - this.m_config = config; - } - - public void setDebug(boolean debug) - { - this.m_debug = debug; - } - - /** - * Initialize the share mapper - * - * @param config ServerConfiguration - * @param params ConfigElement - * @exception InvalidConfigurationException - */ - public void initializeMapper(ServerConfiguration config, ConfigElement params) throws InvalidConfigurationException - { - // Save the server configuration - - setServerConfiguration(config); - - // Check if debug is enabled - - if (params != null && params.getChild("debug") != null) - setDebug(true); - - // Complete the initialization - afterPropertiesSet(); - } - - public void afterPropertiesSet() - { - // Save the server configuration - - m_filesysConfig = (FilesystemsConfigSection) m_config.getConfigSection(FilesystemsConfigSection.SectionName); - - - // Build the list of available AVM share names - - m_avmShareNames = new StringList(); - - SharedDeviceList shrList = m_filesysConfig.getShares(); - Enumeration shrEnum = shrList.enumerateShares(); - - while ( shrEnum.hasMoreElements()) - { - // Get the current shared device and check if it is an AVM filesystem device - - SharedDevice curShare = shrEnum.nextElement(); - - try - { - if ( curShare.getInterface() instanceof AVMDiskDriver) - { - // Add the shared filesystem name to the list of AVM shares - - m_avmShareNames.addString( curShare.getName()); - - // Set the AVM filesystem driver to be used when creating dynamic shares - - if ( m_driver == null) - m_driver = (AVMDiskDriver) curShare.getInterface(); - } - } - catch ( InvalidDeviceInterfaceException ex) - { - } - } - } - - /** - * Check if debug output is enabled - * - * @return boolean - */ - public final boolean hasDebug() - { - return m_debug; - } - - /** - * Return the list of available shares. - * - * @param host String - * @param sess SrvSession - * @param allShares boolean - * @return SharedDeviceList - */ - public SharedDeviceList getShareList(String host, SrvSession sess, boolean allShares) - { - // Make a copy of the global share list and add the per session dynamic shares - - SharedDeviceList shrList = new SharedDeviceList(m_filesysConfig.getShares()); - - if ( sess != null && sess.hasDynamicShares()) { - - // Add the per session dynamic shares - - shrList.addShares(sess.getDynamicShareList()); - } - - // Remove unavailable shares from the list and return the list - - if ( allShares == false) - shrList.removeUnavailableShares(); - return shrList; - } - - /** - * Find a share using the name and type for the specified client. - * - * @param host String - * @param name String - * @param typ int - * @param sess SrvSession - * @param create boolean - * @return SharedDevice - * @exception InvalidUserException - */ - public SharedDevice findShare(String tohost, String name, int typ, SrvSession sess, boolean create) - throws Exception - { - // Find the required share by name/type. Use a case sensitive search first, if that fails use a case - // insensitive search. - - SharedDevice share = m_filesysConfig.getShares().findShare(name, typ, false); - - if ( share == null) - { - - // Try a case insensitive search for the required share - - share = m_filesysConfig.getShares().findShare(name, typ, true); - } - - // If the share was not found then check if the share is in the AVM versioned share format - '_' - - if ( share == null && ( typ == ShareType.DISK || typ == ShareType.UNKNOWN)) - { - // Check if the share has already been created for the session - - if ( sess.hasDynamicShares()) - { - - // Check if the required share exists in the sessions dynamic share list - - share = sess.getDynamicShareList().findShare(name, typ, false); - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug(" Reusing existing dynamic share for " + name); - } - - // Check if the share name matches the AVM versioned share name pattern - - if ( share == null && create == true && name.matches( AVM_SHAREPATTERN)) - { - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug("Map dynamic share " + name + ", type=" + ShareType.TypeAsString(typ)); - - // Split the store name and version id from the share name - - int pos = name.indexOf( '_'); - - String storePath = name.substring(0, pos) + ":/"; - int storeVersion = -1; - - try - { - String storeVer = name.substring( pos + 1); - storeVersion = Integer.parseInt( storeVer); - - if ( storeVersion < 0) - storeVersion = -1; - } - catch ( NumberFormatException ex) - { - logger.error( "Invalid store version id, name=" + name); - } - - // Create the disk driver and context - - if ( storePath.length() > 0 && storeVersion != -1) - { - // Validate the store name and version - - AVMService avmService = m_driver.getAvmService(); - - m_driver.beginReadTransaction( sess); - - try - { - // Validate the store name/version - - avmService.lookup( storeVersion, storePath); - - // Create a dynamic share mapped to the AVM store/version - - AVMContext avmCtx = new AVMContext( name, storePath, storeVersion); - - if(m_config instanceof ServerConfigurationBean) - { - ServerConfigurationBean config = (ServerConfigurationBean)m_config; - - config.initialiseRuntimeContext("cifs.avm" + name, avmCtx); - - // Enable file state caching - // diskCtx.enableStateCache(serverConfigurationBean, true); - } - else - { - throw new AlfrescoRuntimeException("configuration error, unknown configuration bean"); - } - - // Create a dynamic shared device for the store version - - DiskSharedDevice diskShare = new DiskSharedDevice( name, m_driver, avmCtx, SharedDevice.Temporary); - - // Add the new share to the sessions dynamic share list - - sess.addDynamicShare(diskShare); - share = diskShare; - - // DEBUG - - if (logger.isDebugEnabled()) - logger.debug(" Mapped share " + name + " - " + diskShare); - } - catch ( AVMNotFoundException ex) - { - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug( "Failed to map share to " + name + ", not such store/version"); - } - catch ( AVMWrongTypeException ex) - { - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug( "Failed to map share to " + name + ", wrong type"); - } - } - } - } - - // Check if the share is available - - if ( share != null && share.getContext() != null && share.getContext().isAvailable() == false) - share = null; - - // Return the shared device, or null if no matching device was found - - return share; - } - - /** - * Delete temporary shares for the specified session - * - * @param sess SrvSession - */ - public void deleteShares(SrvSession sess) - { - - // Check if the session has any dynamic shares - - if ( sess.hasDynamicShares() == false) - return; - - // Delete the dynamic shares - - SharedDeviceList shares = sess.getDynamicShareList(); - Enumeration enm = shares.enumerateShares(); - - while ( enm.hasMoreElements()) { - - // Get the current share from the list - - SharedDevice shr = (SharedDevice) enm.nextElement(); - - // Close the shared device - - shr.getContext().CloseContext(); - - // DEBUG - - if (logger.isDebugEnabled()) - logger.debug("Deleted dynamic share " + shr); - } - - // Clear the dynamic share list - - shares.removeAllShares(); - } - - /** - * Close the share mapper, release any resources. - */ - public void closeMapper() - { - // TODO Auto-generated method stub - - } -} diff --git a/source/java/org/alfresco/filesys/avm/AVMSingleFileSearchContext.java b/source/java/org/alfresco/filesys/avm/AVMSingleFileSearchContext.java deleted file mode 100644 index 5164de6721..0000000000 --- a/source/java/org/alfresco/filesys/avm/AVMSingleFileSearchContext.java +++ /dev/null @@ -1,196 +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 . */ - -package org.alfresco.filesys.avm; - -import org.alfresco.jlan.server.filesys.FileAttribute; -import org.alfresco.jlan.server.filesys.FileInfo; -import org.alfresco.jlan.server.filesys.SearchContext; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; - -/** - * AVM Filesystem Single File Search Context Class - * - *

Contains the details of a non-wildcard file/folder search, where there is only one result to return. - * - * @author GKSpencer - */ -public class AVMSingleFileSearchContext extends SearchContext { - - // Details of the single file/folder - - private AVMNodeDescriptor m_fileDetails; - - // Flag to indicate file details have been returned - - private boolean m_endOfSearch; - - // Relative path to the file/folder - - private String m_relativePath; - - // Mark thel file/folder as read-only - - private boolean m_readOnly; - - /** - * Class constructor - * - * @param fileDetails AVMNodeDescriptor - * @param relPath String - * @param readOnly boolean - */ - public AVMSingleFileSearchContext( AVMNodeDescriptor fileDetails, String relPath, boolean readOnly) - { - m_fileDetails = fileDetails; - m_relativePath = relPath; - - m_readOnly = readOnly; - } - - /** - * Determine if there are more files for the active search. - * - * @return boolean - */ - public boolean hasMoreFiles() - { - return m_endOfSearch == false ? true : false; - } - - /** - * Return file information for the next file in the active search. Returns false if the search - * is complete. - * - * @param info FileInfo to return the file information. - * @return true if the file information is valid, else false - */ - public boolean nextFileInfo(FileInfo info) - { - // Check if the file details have been returned - - if ( m_endOfSearch == true) - return false; - - // Fill in the file information details - - info.setFileName( m_fileDetails.getName()); - - if ( m_fileDetails.isFile()) - { - info.setFileSize( m_fileDetails.getLength()); - info.setAllocationSize((m_fileDetails.getLength() + 512L) & 0xFFFFFFFFFFFFFE00L); - } - else - info.setFileSize( 0L); - - info.setAccessDateTime( m_fileDetails.getAccessDate()); - info.setCreationDateTime( m_fileDetails.getCreateDate()); - info.setModifyDateTime( m_fileDetails.getModDate()); - - // Build the file attributes - - int attr = 0; - - if ( m_fileDetails.isDirectory()) - attr += FileAttribute.Directory; - - if ( m_fileDetails.getName().startsWith( ".") || - m_fileDetails.getName().equalsIgnoreCase( "Desktop.ini") || - m_fileDetails.getName().equalsIgnoreCase( "Thumbs.db")) - attr += FileAttribute.Hidden; - - if ( m_readOnly == true) - attr += FileAttribute.ReadOnly; - - info.setFileAttributes( attr); - info.setFileId( m_relativePath.hashCode()); - - // Set the end of search flag, indicate that the file informatin is valid - - m_endOfSearch = true; - return true; - } - - /** - * Return the file name of the next file in the active search. Returns null is the search is - * complete. - * - * @return String - */ - public String nextFileName() - { - // Check if the file details have been returned - - if ( m_endOfSearch == true) - return null; - - // Return the file/folder name, set the end of search flag - - m_endOfSearch = true; - return m_fileDetails.getName(); - } - - /** - * Return the total number of file entries for this search if known, else return -1 - * - * @return int - */ - public int numberOfEntries() - { - return 1; - } - - /** - * Return the resume id for the current file/directory in the search. - * - * @return int - */ - public int getResumeId() - { - return 1; - } - - /** - * Restart a search at the specified resume point. - * - * @param resumeId Resume point id. - * @return true if the search can be restarted, else false. - */ - public boolean restartAt(int resumeId) - { - // Validate the resume id and clear the end of search flag - - if ( resumeId == 1) - m_endOfSearch = false; - else - return false; - return true; - } - - /** - * Restart the current search at the specified file. - * - * @param info File to restart the search at. - * @return true if the search can be restarted, else false. - */ - public boolean restartAt(FileInfo info) - { - return true; - } -} diff --git a/source/java/org/alfresco/filesys/avm/DummyFolderPseudoFile.java b/source/java/org/alfresco/filesys/avm/DummyFolderPseudoFile.java deleted file mode 100644 index 5f34acd485..0000000000 --- a/source/java/org/alfresco/filesys/avm/DummyFolderPseudoFile.java +++ /dev/null @@ -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 . */ -package org.alfresco.filesys.avm; - -import org.alfresco.jlan.server.filesys.FileAttribute; -import org.alfresco.jlan.server.filesys.FileInfo; -import org.alfresco.jlan.server.filesys.FileName; -import org.alfresco.jlan.server.filesys.NetworkFile; -import org.alfresco.jlan.server.filesys.pseudo.PseudoFile; -import org.alfresco.jlan.server.filesys.pseudo.PseudoFolderNetworkFile; - - -/** - * Dummy Folder Pseudo File Class - * - *

Represents a dummy folder within the virtualization filesystem view. - * - * @author gkspencer - */ -public class DummyFolderPseudoFile extends PseudoFile { - - /** - * Class constructor - * - * @param fname String - * @param relPath String - */ - public DummyFolderPseudoFile( String fname, String relPath) - { - super( fname, FileAttribute.Directory + FileAttribute.ReadOnly); - - // Create static file information from the folder details - - FileInfo fInfo = new FileInfo( fname, 0L, FileAttribute.Directory + FileAttribute.ReadOnly); - fInfo.setCreationDateTime( System.currentTimeMillis()); - - fInfo.setPath( relPath); - fInfo.setFileId( relPath.hashCode()); - - long timeNow = System.currentTimeMillis(); - fInfo.setCreationDateTime( timeNow); - fInfo.setModifyDateTime( timeNow); - fInfo.setAccessDateTime( timeNow); - fInfo.setChangeDateTime( timeNow); - - setFileInfo( fInfo); - } - - /** - * Return a network file for reading/writing the pseudo file - * - * @param netPath String - * @return NetworkFile - */ - @Override - public NetworkFile getFile(String netPath) { - - // Split the path to get the name - - String[] paths = FileName.splitPath( netPath); - - // Create a network file for the folder - - return new PseudoFolderNetworkFile( paths[1], netPath); - } - - /** - * Return the file information for the pseudo file - * - * @return FileInfo - */ - @Override - public FileInfo getFileInfo() { - return getInfo(); - } -} diff --git a/source/java/org/alfresco/filesys/avm/PseudoFileListSearchContext.java b/source/java/org/alfresco/filesys/avm/PseudoFileListSearchContext.java deleted file mode 100644 index 402786760b..0000000000 --- a/source/java/org/alfresco/filesys/avm/PseudoFileListSearchContext.java +++ /dev/null @@ -1,296 +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 . */ - -package org.alfresco.filesys.avm; - -import org.alfresco.jlan.server.filesys.FileAttribute; -import org.alfresco.jlan.server.filesys.FileInfo; -import org.alfresco.jlan.server.filesys.SearchContext; -import org.alfresco.jlan.server.filesys.pseudo.PseudoFile; -import org.alfresco.jlan.server.filesys.pseudo.PseudoFileList; -import org.alfresco.jlan.util.WildCard; - - -/** - * Pseudo File List Search Context Class - * - *

Returns files from a pseudo file list for a wildcard search. - * - * @author gkspencer - */ -public class PseudoFileListSearchContext extends SearchContext { - - // Pseudo file list and current index - - private PseudoFileList m_fileList; - private int m_fileIdx; - - // File attributes - - private int m_attrib; - - // Optional wildcard filter - - private WildCard m_filter; - - // Mark all files/folders as read-only - - private boolean m_readOnly; - - /** - * Class constructor - * - * @param fileList PseudoFileList - * @param attrib int - * @param filter WildCard - * @param readOnly boolean - */ - public PseudoFileListSearchContext( PseudoFileList fileList, int attrib, WildCard filter, boolean readOnly) - { - m_attrib = attrib; - m_filter = filter; - m_fileList = fileList; - m_readOnly = readOnly; - } - - /** - * Determine if there are more files for the active search. - * - * @return boolean - */ - public boolean hasMoreFiles() - { - return m_fileIdx < m_fileList.numberOfFiles() ? true : false; - } - - /** - * Return file information for the next file in the active search. Returns false if the search - * is complete. - * - * @param info FileInfo to return the file information. - * @return true if the file information is valid, else false - */ - public boolean nextFileInfo(FileInfo info) - { - // Check if there is another file record to return - - if ( m_fileIdx >= m_fileList.numberOfFiles()) - return false; - - // Search for the next valid file - - boolean foundMatch = false; - PseudoFile curFile = null; - - while (foundMatch == false && m_fileIdx < m_fileList.numberOfFiles()) - { - // Get the next file from the list - - curFile = m_fileList.getFileAt( m_fileIdx++); - - // Check if the file name matches the search pattern - - if ( m_filter != null) - { - // Check if the current file matches the wildcard pattern - - if ( m_filter.matchesPattern(curFile.getFileName()) == true) - { - // Check if the file matches the search attributes - - if (FileAttribute.hasAttribute(m_attrib, FileAttribute.Directory) && - curFile.isDirectory()) - { - - // Found a match - - foundMatch = true; - } - else if ( curFile.isFile()) - { - - // Found a match - - foundMatch = true; - } - - // Check if we found a match - - if ( foundMatch == false) - { - - // Get the next file from the list - - if ( ++m_fileIdx < m_fileList.numberOfFiles()) - curFile = m_fileList.getFileAt( m_fileIdx); - } - } - } - else - foundMatch = true; - } - - // If we found a match then fill in the file information - - if ( foundMatch) - { - // Fill in the file information - - info.setFileName( curFile.getFileName()); - - // Get the file information from the pseudo file - - FileInfo pfInfo = curFile.getFileInfo(); - - if ( curFile.isFile()) - { - info.setFileSize( pfInfo.getSize()); - info.setAllocationSize( pfInfo.getAllocationSize()); - } - else - info.setFileSize( 0L); - - info.setAccessDateTime( pfInfo.getAccessDateTime()); - info.setCreationDateTime( pfInfo.getCreationDateTime()); - info.setModifyDateTime( pfInfo.getModifyDateTime()); - - // Build the file attributes - - int attr = pfInfo.getFileAttributes(); - - if ( pfInfo.isHidden() == false && - curFile.getFileName().startsWith( ".") || - curFile.getFileName().equalsIgnoreCase( "Desktop.ini") || - curFile.getFileName().equalsIgnoreCase( "Thumbs.db")) - attr += FileAttribute.Hidden; - - // Check if the file/folder should be marked as read-only - - if ( m_readOnly && pfInfo.isReadOnly() == false) - attr += FileAttribute.ReadOnly; - - info.setFileAttributes( attr); - info.setFileId( pfInfo.getFileId()); - } - - // Indicate if the file information is valid - - return foundMatch; - } - - /** - * Return the file name of the next file in the active search. Returns null is the search is - * complete. - * - * @return String - */ - public String nextFileName() - { - // Check if there is another file record to return - - // Find the next matching file name - - while ( m_fileIdx < m_fileList.numberOfFiles()) { - - // Check if the current file name matches the search pattern - - String fname = m_fileList.getFileAt( m_fileIdx++).getFileName(); - - if ( m_filter.matchesPattern(fname)) - return fname; - } - - // No more matching file names - - return null; - } - - /** - * Return the total number of file entries for this search if known, else return -1 - * - * @return int - */ - public int numberOfEntries() - { - return m_fileList.numberOfFiles(); - } - - /** - * Return the resume id for the current file/directory in the search. - * - * @return int - */ - public int getResumeId() - { - return m_fileIdx; - } - - /** - * Restart a search at the specified resume point. - * - * @param resumeId Resume point id. - * @return true if the search can be restarted, else false. - */ - public boolean restartAt(int resumeId) - { - // Range check the resume id - - int resId = resumeId - 1; - - if ( resId < 0 || resId >= m_fileList.numberOfFiles()) - return false; - - // Reset the current file index - - m_fileIdx = resId; - return true; - } - - /** - * Restart the current search at the specified file. - * - * @param info File to restart the search at. - * @return true if the search can be restarted, else false. - */ - public boolean restartAt(FileInfo info) - { - // Search backwards from the current file - - int curFileIdx = m_fileIdx; - - if (m_fileIdx >= m_fileList.numberOfFiles()) - { - m_fileIdx = m_fileList.numberOfFiles() - 1; - } - - while ( m_fileIdx > 0) { - - // Check if the current file is the required search restart point - - if ( m_fileList.getFileAt( m_fileIdx).getFileName().equals( info.getFileName())) - return true; - else - m_fileIdx--; - } - - // Failed to find the restart file - - m_fileIdx = curFileIdx; - return false; - } -} diff --git a/source/java/org/alfresco/filesys/avm/StorePseudoFile.java b/source/java/org/alfresco/filesys/avm/StorePseudoFile.java deleted file mode 100644 index 27ca113b1f..0000000000 --- a/source/java/org/alfresco/filesys/avm/StorePseudoFile.java +++ /dev/null @@ -1,211 +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 . */ - -package org.alfresco.filesys.avm; - -import org.alfresco.jlan.server.filesys.FileAttribute; -import org.alfresco.jlan.server.filesys.FileInfo; -import org.alfresco.jlan.server.filesys.FileName; -import org.alfresco.jlan.server.filesys.NetworkFile; -import org.alfresco.jlan.server.filesys.pseudo.PseudoFile; -import org.alfresco.jlan.server.filesys.pseudo.PseudoFolderNetworkFile; -import org.alfresco.service.cmr.avm.AVMStoreDescriptor; - -/** - * Store Pseudo File Class - * - *

Represents an AVM store as a folder. - * - * @author gkspencer - */ -public class StorePseudoFile extends PseudoFile { - - // Store type - - private int m_storeType = StoreType.Normal; - - // Web project this sandbox links to, or null if this store is not linked - - private String m_webProject; - - // User name if this is an author sandbox for a web project - - private String m_userName; - - /** - * Class constructor - * - * @param storeDesc AVMStoreDescriptor - * @param relPath String - * @param storeType int - */ - public StorePseudoFile( AVMStoreDescriptor storeDesc, String relPath, int storeType) - { - super( storeDesc.getName(), FileAttribute.Directory + FileAttribute.ReadOnly); - - // Create static file information from the store details - - FileInfo fInfo = new FileInfo( storeDesc.getName(), 0L, FileAttribute.Directory + FileAttribute.ReadOnly); - - fInfo.setCreationDateTime( storeDesc.getCreateDate()); - fInfo.setModifyDateTime( storeDesc.getCreateDate()); - fInfo.setAccessDateTime( storeDesc.getCreateDate()); - fInfo.setChangeDateTime( storeDesc.getCreateDate()); - - fInfo.setPath( relPath); - fInfo.setFileId( relPath.hashCode()); - - setFileInfo( fInfo); - - setStoreType( storeType); - } - - /** - * Class constructor - * - * @param storeName String - * @param relPath String - */ - public StorePseudoFile( String storeName, String relPath) - { - super( storeName, FileAttribute.Directory + FileAttribute.ReadOnly); - - // Create static file information from the store details - - FileInfo fInfo = new FileInfo( storeName, 0L, FileAttribute.Directory + FileAttribute.ReadOnly); - - long timeNow = System.currentTimeMillis(); - fInfo.setCreationDateTime( timeNow); - fInfo.setModifyDateTime( timeNow); - fInfo.setAccessDateTime( timeNow); - fInfo.setChangeDateTime( timeNow); - - fInfo.setPath( relPath); - fInfo.setFileId( relPath.hashCode()); - - setFileInfo( fInfo); - } - - /** - * Return a network file for reading/writing the pseudo file - * - * @param netPath String - * @return NetworkFile - */ - @Override - public NetworkFile getFile(String netPath) { - - // Split the path to get the name - - String[] paths = FileName.splitPath( netPath); - - // Create a network file for the folder - - return new PseudoFolderNetworkFile( paths[1], netPath); - } - - /** - * Return the file information for the pseudo file - * - * @return FileInfo - */ - @Override - public FileInfo getFileInfo() { - return getInfo(); - } - - /** - * Return the store type - * - * @return int - */ - public final int isStoreType() - { - return m_storeType; - } - - /** - * Check if this store is linked to a web project - * - * @return boolean - */ - public final boolean hasWebProject() - { - return m_webProject != null ? true : false; - } - - /** - * Get the web project that this store links to, or null if not linked - * - * @return String - */ - public final String getWebProject() - { - return m_webProject; - } - - /** - * Set the web project that this store is linked to - * - * @param webProject String - */ - public final void setWebProject(String webProject) - { - m_webProject = webProject; - } - - /** - * Check if this store is an author sandbox - * - * @return boolean - */ - public final boolean hasUserName() - { - return m_userName != null ? true : false; - } - - /** - * Get the owner of this sandbox - * - * @return String - */ - public final String getUserName() - { - return m_userName; - } - - /** - * Set the owner of this sandbox - * - * @param userName String - */ - public final void setUserName(String userName) - { - m_userName = userName; - } - - /** - * Set the store type - * - * @param storeType int - */ - public final void setStoreType(int storeType) - { - m_storeType = storeType; - } -} diff --git a/source/java/org/alfresco/filesys/avm/StoreType.java b/source/java/org/alfresco/filesys/avm/StoreType.java deleted file mode 100644 index d32477e93a..0000000000 --- a/source/java/org/alfresco/filesys/avm/StoreType.java +++ /dev/null @@ -1,59 +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 . - */ -package org.alfresco.filesys.avm; - -/** - * Store Types Class - * - * @author gkspencer - */ -public class StoreType { - - // Store types - - public static final int Normal = 0; - - // Site data store types - - public static final int SiteStore = 1; - - // Web project store types - - public static final int WebAuthorMain = 2; - public static final int WebAuthorPreview = 3; - public static final int WebStagingPreview = 4; - public static final int WebStagingMain = 5; - - // Store type strings - - private static final String[] _types = { "Normal", "SiteStore", "AuthorMain", "AuthorPreview", "StagingPreview", "StagingMain" }; - - /** - * Return a store type as a string - * - * @param typ int - * @return String - */ - public final static String asString( int typ) - { - if ( typ < 0 || typ > _types.length) - return "Invalid"; - return _types[ typ]; - } -} diff --git a/source/java/org/alfresco/filesys/avm/VersionPseudoFile.java b/source/java/org/alfresco/filesys/avm/VersionPseudoFile.java deleted file mode 100644 index cc48fe22fa..0000000000 --- a/source/java/org/alfresco/filesys/avm/VersionPseudoFile.java +++ /dev/null @@ -1,119 +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 . */ - -package org.alfresco.filesys.avm; - -import org.alfresco.jlan.server.filesys.FileAttribute; -import org.alfresco.jlan.server.filesys.FileInfo; -import org.alfresco.jlan.server.filesys.FileName; -import org.alfresco.jlan.server.filesys.NetworkFile; -import org.alfresco.jlan.server.filesys.pseudo.PseudoFile; -import org.alfresco.jlan.server.filesys.pseudo.PseudoFolderNetworkFile; -import org.alfresco.service.cmr.avm.VersionDescriptor; - -/** - * Version Pseudo File Class - * - *

Represents an AVM store version as a folder. - * - * @author gkspencer - */ -public class VersionPseudoFile extends PseudoFile { - - /** - * Class constructor - * - * @param name String - * @param relPath String - */ - public VersionPseudoFile( String name, String relPath) - { - super( name, FileAttribute.Directory + FileAttribute.ReadOnly); - - // Create static file information from the store details - - FileInfo fInfo = new FileInfo( name, 0L, FileAttribute.Directory + FileAttribute.ReadOnly); - - fInfo.setPath( relPath); - fInfo.setFileId( relPath.hashCode()); - - long timeNow = System.currentTimeMillis(); - fInfo.setCreationDateTime( timeNow); - fInfo.setModifyDateTime( timeNow); - fInfo.setAccessDateTime( timeNow); - fInfo.setChangeDateTime( timeNow); - - setFileInfo( fInfo); - } - - /** - * Class constructor - * - * @param name String - * @param verDesc VersionDescriptor - * @param relPath String - */ - public VersionPseudoFile( String name, VersionDescriptor verDesc, String relPath) - { - super( name, FileAttribute.Directory + FileAttribute.ReadOnly); - - // Create static file information from the store details - - FileInfo fInfo = new FileInfo( name, 0L, FileAttribute.Directory + FileAttribute.ReadOnly); - fInfo.setCreationDateTime( verDesc.getCreateDate()); - - fInfo.setPath( relPath); - fInfo.setFileId( relPath.hashCode()); - - long timeNow = System.currentTimeMillis(); - fInfo.setCreationDateTime( timeNow); - fInfo.setModifyDateTime( timeNow); - fInfo.setAccessDateTime( timeNow); - fInfo.setChangeDateTime( timeNow); - - setFileInfo( fInfo); - } - - /** - * Return a network file for reading/writing the pseudo file - * - * @param netPath String - * @return NetworkFile - */ - @Override - public NetworkFile getFile(String netPath) { - - // Split the path to get the name - - String[] paths = FileName.splitPath( netPath); - - // Create a network file for the folder - - return new PseudoFolderNetworkFile( paths[1], netPath); - } - - /** - * Return the file information for the pseudo file - * - * @return FileInfo - */ - @Override - public FileInfo getFileInfo() { - return getInfo(); - } -} diff --git a/source/java/org/alfresco/filesys/avm/WebProjectStorePseudoFile.java b/source/java/org/alfresco/filesys/avm/WebProjectStorePseudoFile.java deleted file mode 100644 index 21a3799bb0..0000000000 --- a/source/java/org/alfresco/filesys/avm/WebProjectStorePseudoFile.java +++ /dev/null @@ -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 . */ - -package org.alfresco.filesys.avm; - -import java.util.Hashtable; - -import org.alfresco.jlan.server.filesys.FileAttribute; -import org.alfresco.jlan.server.filesys.FileInfo; -import org.alfresco.service.cmr.avm.AVMStoreDescriptor; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Web Project Store Pseudo File Class - * - *

Represents an AVM store as a folder. - * - * @author gkspencer - */ -public class WebProjectStorePseudoFile extends StorePseudoFile { - - // Store/web project user access roles - - public static final int RoleNone = 0; - public static final int RolePublisher = 1; - public static final int RoleContentManager = 2; - - // Node ref for this store - - private NodeRef m_noderef; - - // List of users that are content managers/publishers for this web project store - - private Hashtable m_users; - - /** - * Class constructor - * - * @param storeDesc AVMStoreDescriptor - * @param relPath String - * @param nodeRef NodeRef - */ - public WebProjectStorePseudoFile( AVMStoreDescriptor storeDesc, String relPath, NodeRef nodeRef) - { - super( storeDesc, relPath, StoreType.WebStagingMain); - - // Create static file information from the store details - - FileInfo fInfo = new FileInfo( storeDesc.getName(), 0L, FileAttribute.Directory + FileAttribute.ReadOnly); - - fInfo.setCreationDateTime( storeDesc.getCreateDate()); - fInfo.setModifyDateTime( storeDesc.getCreateDate()); - fInfo.setAccessDateTime( storeDesc.getCreateDate()); - fInfo.setChangeDateTime( storeDesc.getCreateDate()); - - fInfo.setPath( relPath); - fInfo.setFileId( relPath.hashCode()); - - setFileInfo( fInfo); - - // Set the associated node ref for the web project - - m_noderef = nodeRef; - } - - /** - * Class constructor - * - * @param storeName String - * @param relPath String - * @param nodeRef NodeRef - */ - public WebProjectStorePseudoFile( String storeName, String relPath, NodeRef nodeRef) - { - super( storeName, relPath); - - // Create static file information from the store details - - FileInfo fInfo = new FileInfo( storeName, 0L, FileAttribute.Directory + FileAttribute.ReadOnly); - - long timeNow = System.currentTimeMillis(); - fInfo.setCreationDateTime( timeNow); - fInfo.setModifyDateTime( timeNow); - fInfo.setAccessDateTime( timeNow); - fInfo.setChangeDateTime( timeNow); - - fInfo.setPath( relPath); - fInfo.setFileId( relPath.hashCode()); - - setFileInfo( fInfo); - - // Set the associated node ref for the web project - - m_noderef = nodeRef; - } - - /** - * Check if the associated node ref is valid - * - * @return boolean - */ - public final boolean hasNodeRef() - { - return m_noderef != null ? true : false; - } - - /** - * Get the associated node ref for the store - * - * @return NodeRef - */ - public final NodeRef getNodeRef() - { - return m_noderef; - } - - /** - * Set the associated node ref for the store - * - * @param node NodeRef - */ - public final void setNodeRef(NodeRef node) - { - m_noderef = node; - } - - /** - * Return the role for the specified user within this web project - * - * @param userName String - * @return int - */ - public final int getUserRole(String userName) - { - if ( m_users == null) - return RoleNone; - - Integer role = m_users.get( userName); - return role != null ? role.intValue() : RoleNone; - } - - /** - * Add a user role for this web project - * - * @param userName String - * @param role int - */ - public final void addUserRole(String userName, int role) - { - if ( m_users == null) - m_users = new Hashtable(); - - m_users.put(userName, Integer.valueOf(role)); - } - - /** - * Remove a user role for this project - * - * @param userName String - */ - public final void removeUserRole(String userName) - { - if ( m_users != null) - m_users.remove(userName); - } -} diff --git a/source/java/org/alfresco/filesys/avm/package-info.java b/source/java/org/alfresco/filesys/avm/package-info.java deleted file mode 100644 index 301b0d456d..0000000000 --- a/source/java/org/alfresco/filesys/avm/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - */ -@PackageMarker -package org.alfresco.filesys.avm; -import org.alfresco.util.PackageMarker; diff --git a/source/java/org/alfresco/filesys/config/ServerConfigurationBean.java b/source/java/org/alfresco/filesys/config/ServerConfigurationBean.java index 934920e8b5..b9744b1a7b 100644 --- a/source/java/org/alfresco/filesys/config/ServerConfigurationBean.java +++ b/source/java/org/alfresco/filesys/config/ServerConfigurationBean.java @@ -40,8 +40,6 @@ import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.filesys.AbstractServerConfigurationBean; import org.alfresco.filesys.alfresco.AlfrescoContext; import org.alfresco.filesys.alfresco.ExtendedDiskInterface; -import org.alfresco.filesys.avm.AVMContext; -import org.alfresco.filesys.avm.AVMDiskDriver; import org.alfresco.filesys.config.acl.AccessControlListBean; import org.alfresco.filesys.repo.BufferedContentDiskDriver; import org.alfresco.filesys.repo.ContentContext; @@ -107,7 +105,6 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp private FTPConfigBean ftpConfigBean; private NFSConfigBean nfsConfigBean; private List filesystemContexts; - private boolean avmAllStores; private SecurityConfigBean securityConfigBean; private CoreServerConfigBean coreServerConfigBean; @@ -153,11 +150,6 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp this.filesystemContexts = filesystemContexts; } - public void setAvmAllStores(boolean avmAllStores) - { - this.avmAllStores = avmAllStores; - } - public void setSecurityConfigBean(SecurityConfigBean securityConfigBean) { this.securityConfigBean = securityConfigBean; @@ -1742,133 +1734,86 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp DiskSharedDevice filesys = null; - if (filesystem instanceof AVMContext) + // Create a new filesystem driver instance and register a context for + // the new filesystem + + ExtendedDiskInterface filesysDriver = getRepoDiskInterface(); + ContentContext filesysContext = (ContentContext) filesystem; + + if(clusterConfigBean != null && clusterConfigBean.getClusterEnabled()) { - // Create a new filesystem driver instance and register a context for - // the new filesystem - - ExtendedDiskInterface filesysDriver = getAvmDiskInterface(); - DiskDeviceContext diskCtx = (DiskDeviceContext) filesystem; - - if(clusterConfigBean != null && clusterConfigBean.getClusterEnabled()) + if(logger.isDebugEnabled()) { - if(logger.isDebugEnabled()) - { - logger.debug("start hazelcast cache : " + clusterConfigBean.getClusterName() + ", shareName: "+ diskCtx.getShareName()); - } - GenericConfigElement hazelConfig = createClusterConfig("cifs.avm."+diskCtx.getShareName()); - HazelCastClusterFileStateCache hazel = new HazelCastClusterFileStateCache(); - hazel.initializeCache(hazelConfig, this); - diskCtx.setStateCache(hazel); + logger.debug("start hazelcast cache : " + clusterConfigBean.getClusterName() + ", shareName: "+ filesysContext.getShareName()); } - else - { - // Check if the filesystem uses the file state cache, if so then add to the file state reaper - StandaloneFileStateCache standaloneCache = new StandaloneFileStateCache(); - standaloneCache.initializeCache( new GenericConfigElement( ""), this); - diskCtx.setStateCache(standaloneCache); - } - - if ( diskCtx.hasStateCache()) { - - // Register the state cache with the reaper thread - - fsysConfig.addFileStateCache( filesystem.getDeviceName(), diskCtx.getStateCache()); - } - - filesysDriver.registerContext(filesystem); - - // Create the shared filesystem - - filesys = new DiskSharedDevice(filesystem.getDeviceName(), filesysDriver, (AVMContext)filesystem); - filesys.setConfiguration( this); - // Start the filesystem - - ((AVMContext)filesystem).startFilesystem(filesys); + GenericConfigElement hazelConfig = createClusterConfig("cifs.filesys."+filesysContext.getShareName()); + HazelCastClusterFileStateCache hazel = new HazelCastClusterFileStateCache(); + hazel.initializeCache(hazelConfig, this); + filesysContext.setStateCache(hazel); } else { - // Create a new filesystem driver instance and register a context for - // the new filesystem - - ExtendedDiskInterface filesysDriver = getRepoDiskInterface(); - ContentContext filesysContext = (ContentContext) filesystem; - - if(clusterConfigBean != null && clusterConfigBean.getClusterEnabled()) - { - if(logger.isDebugEnabled()) - { - logger.debug("start hazelcast cache : " + clusterConfigBean.getClusterName() + ", shareName: "+ filesysContext.getShareName()); - } - GenericConfigElement hazelConfig = createClusterConfig("cifs.filesys."+filesysContext.getShareName()); - HazelCastClusterFileStateCache hazel = new HazelCastClusterFileStateCache(); - hazel.initializeCache(hazelConfig, this); - filesysContext.setStateCache(hazel); - } - else - { - // Create state cache here and inject - StandaloneFileStateCache standaloneCache = new StandaloneFileStateCache(); - standaloneCache.initializeCache( new GenericConfigElement( ""), this); - filesysContext.setStateCache(standaloneCache); - } - - if ( filesysContext.hasStateCache()) { - - // Register the state cache with the reaper thread - // has many side effects including initialisation of the cache - fsysConfig.addFileStateCache( filesystem.getDeviceName(), filesysContext.getStateCache()); - - // Create the lock manager for the context. - FileStateLockManager lockMgr = new FileStateLockManager(filesysContext.getStateCache()); - filesysContext.setLockManager(lockMgr); - filesysContext.setOpLockManager(lockMgr); - } - - if ((!cifsConfigBean.getServerEnabled() && !ftpConfigBean.getServerEnabled()) - && isContentDiskDriver2(filesysDriver)) - { - ((ContentContext) filesystem).setDisableNodeMonitor(true); - } - - filesysDriver.registerContext(filesystem); - - // Check if an access control list has been specified - - AccessControlList acls = null; - AccessControlListBean accessControls = filesysContext.getAccessControlList(); - if (accessControls != null) - { - // Parse the access control list - acls = accessControls.toAccessControlList(secConfig); - } - else if (secConfig.hasGlobalAccessControls()) - { - - // Use the global access control list for this disk share - acls = secConfig.getGlobalAccessControls(); - } - - // Create the shared filesystem - - filesys = new DiskSharedDevice(filesystem.getDeviceName(), filesysDriver, filesysContext); - filesys.setConfiguration( this); - - // Add any access controls to the share - - filesys.setAccessControlList(acls); - - - - // Check if change notifications should be enabled - - if ( filesysContext.getDisableChangeNotifications() == false) - filesysContext.enableChangeHandler( true); - - // Start the filesystem - - filesysContext.startFilesystem(filesys); + // Create state cache here and inject + StandaloneFileStateCache standaloneCache = new StandaloneFileStateCache(); + standaloneCache.initializeCache( new GenericConfigElement( ""), this); + filesysContext.setStateCache(standaloneCache); } + + if ( filesysContext.hasStateCache()) { + + // Register the state cache with the reaper thread + // has many side effects including initialisation of the cache + fsysConfig.addFileStateCache( filesystem.getDeviceName(), filesysContext.getStateCache()); + + // Create the lock manager for the context. + FileStateLockManager lockMgr = new FileStateLockManager(filesysContext.getStateCache()); + filesysContext.setLockManager(lockMgr); + filesysContext.setOpLockManager(lockMgr); + } + + if ((!cifsConfigBean.getServerEnabled() && !ftpConfigBean.getServerEnabled()) + && isContentDiskDriver2(filesysDriver)) + { + ((ContentContext) filesystem).setDisableNodeMonitor(true); + } + + filesysDriver.registerContext(filesystem); + + // Check if an access control list has been specified + + AccessControlList acls = null; + AccessControlListBean accessControls = filesysContext.getAccessControlList(); + if (accessControls != null) + { + // Parse the access control list + acls = accessControls.toAccessControlList(secConfig); + } + else if (secConfig.hasGlobalAccessControls()) + { + + // Use the global access control list for this disk share + acls = secConfig.getGlobalAccessControls(); + } + + // Create the shared filesystem + + filesys = new DiskSharedDevice(filesystem.getDeviceName(), filesysDriver, filesysContext); + filesys.setConfiguration( this); + + // Add any access controls to the share + + filesys.setAccessControlList(acls); + + + + // Check if change notifications should be enabled + + if ( filesysContext.getDisableChangeNotifications() == false) + filesysContext.enableChangeHandler( true); + + // Start the filesystem + + filesysContext.startFilesystem(filesys); // Add the new filesystem @@ -1891,50 +1836,6 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp logger.warn("No filesystems defined"); } - // Check if shares should be added for all AVM stores - if (this.avmAllStores && getAvmDiskInterface() != null) - { - // Get the list of store names - - AVMDiskDriver avmDriver = (AVMDiskDriver) getAvmDiskInterface(); - StringList storeNames = avmDriver.getAVMStoreNames(); - - // Add shares for each of the store names, if the share name does not already exist - - if (storeNames != null && storeNames.numberOfStrings() > 0) - { - // Add a share for each store - - for (int i = 0; i < storeNames.numberOfStrings(); i++) - { - String storeName = storeNames.getStringAt(i); - - // Check if a share of the same name already exists - - if (fsysConfig.getShares().findShare(storeName, ShareType.DISK, true) == null) - { - // Create the new share for the store - - AVMContext avmContext = new AVMContext(storeName, storeName + ":/", AVMContext.VERSION_HEAD); -// avmContext.enableStateCache(this, true); - - // Create the shared filesystem - - DiskSharedDevice filesys = new DiskSharedDevice(storeName, avmDriver, avmContext); - filesys.setConfiguration( this); - - fsysConfig.addShare( filesys); - - // DEBUG - - if (logger.isDebugEnabled()) - logger.debug("Added AVM share " + storeName); - } - } - } - } - - // home folder share mapper could be declared in security config } diff --git a/source/java/org/alfresco/model/WCMAppModel.java b/source/java/org/alfresco/model/WCMAppModel.java deleted file mode 100644 index 12d722e69e..0000000000 --- a/source/java/org/alfresco/model/WCMAppModel.java +++ /dev/null @@ -1,167 +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 . - */ -package org.alfresco.model; - -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - -/** - * @author Kevin Roast - */ -public interface WCMAppModel -{ - // AVM web folder - static final QName TYPE_AVMWEBFOLDER = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "webfolder"); - static final QName PROP_AVMSTORE = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "avmstore"); - static final QName PROP_DEFAULTWEBAPP = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "defaultwebapp"); - static final QName PROP_DEPLOYTO = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployto"); - static final QName PROP_SELECTEDDEPLOYTO = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "selecteddeployto"); - static final QName PROP_SELECTEDDEPLOYVERSION = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "selecteddeployversion"); - static final QName PROP_ISSOURCE = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "issource"); - static final QName PROP_PREVIEW_PROVIDER = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "previewprovidername"); - static final QName ASSOC_WEBUSER = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "webuser"); - static final QName ASSOC_WEBFORM = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "webform"); - static final QName ASSOC_WEBWORKFLOWDEFAULTS = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "webworkflowdefaults"); - static final QName ASSOC_DEPLOYMENTSERVER = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deploymentserver"); - static final QName ASSOC_DEPLOYMENTATTEMPT = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deploymentattempt"); - static final QName ASSOC_DEPLOYMENTREPORT = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deploymentreport"); - - // AVM web user reference - static final QName TYPE_WEBUSER = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "webuser"); - static final QName PROP_WEBUSERNAME = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "username"); - static final QName PROP_WEBUSERROLE = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "role"); - - // AVM web form - static final QName TYPE_WEBFORM = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "webform"); - static final QName PROP_FORMNAME = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "formname"); - static final QName ASSOC_WEBFORMTEMPLATE = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "webformtemplate"); - static final QName ASSOC_WORKFLOWDEFAULTS = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "workflowdefaults"); - - // AVM web form template - static final QName TYPE_WEBFORMTEMPLATE = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "webformtemplate"); - static final QName PROP_BASE_RENDERING_ENGINE_TEMPLATE_NAME = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "baserenderingenginetemplatename"); - - // AVM workflow defaults - static final QName TYPE_WORKFLOW_DEFAULTS = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "workflowdefaults"); - static final QName PROP_WORKFLOW_NAME = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "workflowname"); - static final QName PROP_WORKFLOW_DEFAULT_PROPERTIES = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "workflowdefaultproperties"); - - // AVM web workflow defaults - static final QName TYPE_WEBWORKFLOWDEFAULTS = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "webworkflowdefaults"); - - // AVM website deployment server - static final String CONSTRAINT_ALFDEPLOY = "alfresco"; - static final String CONSTRAINT_FILEDEPLOY = "file"; - static final String CONSTRAINT_LIVESERVER = "live"; - static final String CONSTRAINT_TESTSERVER = "test"; - static final QName TYPE_DEPLOYMENTSERVER = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deploymentserver"); - static final QName PROP_DEPLOYTYPE = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deploytype"); - static final QName PROP_DEPLOYSERVERTYPE = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployservertype"); - static final QName PROP_DEPLOYSERVERHOST = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployserverhost"); - static final QName PROP_DEPLOYSERVERPORT = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployserverport"); - static final QName PROP_DEPLOYSERVERNAME = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployservername"); - static final QName PROP_DEPLOYSERVERUSERNAME = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployserverusername"); - static final QName PROP_DEPLOYSERVERPASSWORD = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployserverpassword"); - static final QName PROP_DEPLOYSERVERGROUP = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployservergroup"); - static final QName PROP_DEPLOYSERVERADPTERNAME = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployserveradaptername"); - static final QName PROP_DEPLOYSERVERURL = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployserverurl"); - static final QName PROP_DEPLOYSERVERTARGET = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployservertarget"); - static final QName PROP_DEPLOYSOURCEPATH = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deploysourcepath"); - static final QName PROP_DEPLOYEXCLUDES = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployexcludes"); - static final QName PROP_DEPLOYSERVERALLOCATEDTO = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployserverallocatedto"); - static final QName PROP_DEPLOYONAPPROVAL = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployonapproval"); - - // AVM website deployment attempt - static final QName TYPE_DEPLOYMENTATTEMPT = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deploymentattempt"); - static final QName PROP_DEPLOYATTEMPTID = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployattemptid"); - static final QName PROP_DEPLOYATTEMPTTYPE = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployattempttype"); - static final QName PROP_DEPLOYATTEMPTSTORE = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployattemptstore"); - static final QName PROP_DEPLOYATTEMPTVERSION = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployattemptversion"); - static final QName PROP_DEPLOYATTEMPTSERVERS = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployattemptservers"); - static final QName PROP_DEPLOYATTEMPTTIME = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployattempttime"); - static final QName ASSOC_DEPLOYMENTREPORTS = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deploymentreports"); - - // AVM website deployment report - static final QName TYPE_DEPLOYMENTREPORT = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deploymentreport"); - static final QName PROP_DEPLOYSERVER = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployserver"); - static final QName PROP_DEPLOYVERSION = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployversion"); - static final QName PROP_DEPLOYSUCCESSFUL = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deploysuccessful"); - static final QName PROP_DEPLOYFAILEDREASON = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployfailedreason"); - static final QName PROP_DEPLOYSTARTTIME = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deploystarttime"); - static final QName PROP_DEPLOYENDTIME = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployendtime"); - static final QName PROP_DEPLOYSERVERNAMEUSED = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployservernameused"); - static final QName PROP_DEPLOYSERVERUSERNAMEUSED = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployserverusernameused"); - static final QName PROP_DEPLOYSERVERTARGETUSED = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployservertargetused"); - static final QName PROP_DEPLOYSOURCEPATHUSED = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deploysourcepathused"); - static final QName PROP_DEPLOYEXCLUDESUSED = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployexcludesused"); - static final QName PROP_DEPLOYSERVERURLUSED = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployserverurlused"); - - // AVM webapp aspect - static final QName ASPECT_WEBAPP = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "webapp"); - - // AVM filename pattern aspect - static final QName ASPECT_FILENAMEPATTERN = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "filenamepattern"); - static final QName PROP_FILENAMEPATTERN = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "filenamepattern"); - - // AVM output path pattern aspect - static final QName ASPECT_OUTPUT_PATH_PATTERN = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "outputpathpattern"); - static final QName PROP_OUTPUT_PATH_PATTERN = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "outputpathpattern"); - - // The XForms data capture form aspect. - static final QName TYPE_FORMFOLDER = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "formfolder"); - static final QName ASPECT_FORM = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "form"); - - /** - * there was a mismapping between this definition of PROP_XML_SCHEMA here and in wcmAppModel.xml. - * leaving in this definition for now as a failover. - */ - static final QName PROP_XML_SCHEMA_OLD = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "schema"); - static final QName PROP_XML_SCHEMA = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "xmlschema"); - static final QName PROP_XML_SCHEMA_ROOT_ELEMENT_NAME = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "xmlschemarootelementname"); - static final QName ASSOC_RENDERING_ENGINE_TEMPLATES = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "renderingenginetemplates"); - static final QName ASSOC_FORM_WORKFLOW_DEFAULTS = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "formworkflowdefaults"); - - // An XML to something else tranformer aspect. - static final QName ASPECT_RENDERING_ENGINE_TEMPLATE = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "renderingenginetemplate"); - static final QName PROP_PARENT_RENDERING_ENGINE_NAME = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "parentrenderingenginename"); - static final QName PROP_FORM_SOURCE = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "formsource"); - static final QName ASSOC_RENDITION_PROPERTIES = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "renditionproperties"); - - static final QName ASPECT_FORM_INSTANCE_DATA = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "forminstancedata"); - static final QName PROP_PARENT_FORM_NAME = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "parentformname"); - static final QName PROP_RENDITIONS = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "renditions"); - static final QName PROP_ORIGINAL_PARENT_PATH = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "orginalparentpath"); - - static final QName ASPECT_RENDITION = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "rendition"); - static final QName PROP_PARENT_RENDERING_ENGINE_TEMPLATE = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "parentrenderingenginetemplate"); - static final QName PROP_PARENT_RENDITION_PROPERTIES = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "parentrenditionproperties"); - static final QName PROP_PRIMARY_FORM_INSTANCE_DATA = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "primaryforminstancedata"); - - static final QName TYPE_RENDITION_PROPERTIES = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "renditionproperties"); - static final QName PROP_MIMETYPE_FOR_RENDITION = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "mimetypeforrendition"); - - // Aspect to track content that expires - static final QName ASPECT_EXPIRES = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "expires"); - static final QName PROP_EXPIRATIONDATE = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "expirationDate"); - - // Aspect to track dm deployed content - static final QName ASPECT_DEPLOYED = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "deployed"); - static final QName PROP_GUID = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "guid"); - -} diff --git a/source/java/org/alfresco/model/WCMModel.java b/source/java/org/alfresco/model/WCMModel.java deleted file mode 100644 index 929d9c3467..0000000000 --- a/source/java/org/alfresco/model/WCMModel.java +++ /dev/null @@ -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 . */ -package org.alfresco.model; - -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - -/** - * QName definitions for WCM. - * @author britt - */ -public interface WCMModel -{ - // content - static final QName TYPE_AVM_CONTENT = QName.createQName(NamespaceService.WCM_MODEL_1_0_URI, "avmcontent"); - static final QName TYPE_AVM_PLAIN_CONTENT = QName.createQName(NamespaceService.WCM_MODEL_1_0_URI, "avmplaincontent"); - static final QName TYPE_AVM_LAYERED_CONTENT = QName.createQName(NamespaceService.WCM_MODEL_1_0_URI, "avmlayeredcontent"); - static final QName PROP_AVM_FILE_INDIRECTION = QName.createQName(NamespaceService.WCM_MODEL_1_0_URI, "avmfileindirection"); - - // folders - static final QName TYPE_AVM_FOLDER = QName.createQName(NamespaceService.WCM_MODEL_1_0_URI, "avmfolder"); - static final QName TYPE_AVM_PLAIN_FOLDER = QName.createQName(NamespaceService.WCM_MODEL_1_0_URI, "avmplainfolder"); - static final QName TYPE_AVM_LAYERED_FOLDER = QName.createQName(NamespaceService.WCM_MODEL_1_0_URI, "avmlayeredfolder"); - static final QName PROP_AVM_DIR_INDIRECTION = QName.createQName(NamespaceService.WCM_MODEL_1_0_URI, "avmdirindirection"); - - // Reverted Aspect. - static final QName ASPECT_REVERTED = QName.createQName(NamespaceService.WCM_MODEL_1_0_URI, "reverted"); - static final QName PROP_REVERTED_ID = QName.createQName(NamespaceService.WCM_MODEL_1_0_URI, "revertedid"); -} diff --git a/source/java/org/alfresco/model/WCMWorkflowModel.java b/source/java/org/alfresco/model/WCMWorkflowModel.java deleted file mode 100644 index ea15e0e693..0000000000 --- a/source/java/org/alfresco/model/WCMWorkflowModel.java +++ /dev/null @@ -1,36 +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 . - */ -package org.alfresco.model; - -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - -/** - * @author Gavin Cornwell - */ -public interface WCMWorkflowModel -{ - // submission workflow properties and aspects - static final QName PROP_FROM_PATH = QName.createQName(NamespaceService.WCMWF_MODEL_1_0_URI, "fromPath"); - static final QName PROP_LABEL = QName.createQName(NamespaceService.WCMWF_MODEL_1_0_URI, "label"); - static final QName PROP_LAUNCH_DATE = QName.createQName(NamespaceService.WCMWF_MODEL_1_0_URI, "launchDate"); - static final QName PROP_AUTO_DEPLOY = QName.createQName(NamespaceService.WCMWF_MODEL_1_0_URI, "autoDeploy"); - static final QName PROP_WEBAPP = QName.createQName(NamespaceService.WCMWF_MODEL_1_0_URI, "webapp"); - static final QName ASSOC_WEBPROJECT = QName.createQName(NamespaceService.WCMWF_MODEL_1_0_URI, "webproject"); -} diff --git a/source/java/org/alfresco/repo/admin/IndexConfigurationCheckerImpl.java b/source/java/org/alfresco/repo/admin/IndexConfigurationCheckerImpl.java index f1b3a37dd4..bf45a6cfbe 100644 --- a/source/java/org/alfresco/repo/admin/IndexConfigurationCheckerImpl.java +++ b/source/java/org/alfresco/repo/admin/IndexConfigurationCheckerImpl.java @@ -81,22 +81,6 @@ public class IndexConfigurationCheckerImpl implements IndexConfigurationChecker this.searchService = searchService; } - /** - * avm trigger - * @param avmSnapShotTriggeredIndexingMethodInterceptor - */ - /* Sparta: remove WCM/AVM - public void setAvmSnapShotTriggeredIndexingMethodInterceptor(AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor) - { - this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor; - } - */ - - - - /* (non-Javadoc) - * @see org.alfresco.repo.admin.IndexConfigurationChecker#checkIndexConfiguration() - */ @Override public List checkIndexConfiguration() { @@ -105,7 +89,6 @@ public class IndexConfigurationCheckerImpl implements IndexConfigurationChecker List missingIndexStoreRefs = new ArrayList(0); for (StoreRef storeRef : storeRefs) { - @SuppressWarnings("unused") NodeRef rootNodeRef = null; try { @@ -127,32 +110,6 @@ public class IndexConfigurationCheckerImpl implements IndexConfigurationChecker if (indexRecoveryMode != RecoveryMode.FULL) { - if (storeRef.getProtocol().equals(StoreRef.PROTOCOL_AVM)) - { - /* Sparta: remove WCM/AVM - if (avmSnapShotTriggeredIndexingMethodInterceptor.isIndexingEnabled()) - { - IndexMode storeIndexMode = avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(storeRef.getIdentifier()); - if (storeIndexMode.equals(IndexMode.UNINDEXED)) - { - if (logger.isDebugEnabled()) - { - logger.debug("Skipping index check for store: " + storeRef + " (unindexed AVM store)"); - } - continue; - } - } - else - { - if (logger.isDebugEnabled()) - { - logger.debug("Skipping index check for store: " + storeRef + " (AVM indexing is disabled)"); - } - continue; - } - */ - } - if (logger.isDebugEnabled()) { logger.debug("Checking index for store: " + storeRef); diff --git a/source/java/org/alfresco/repo/admin/patch/impl/AVMPermissionDataPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/AVMPermissionDataPatch.java deleted file mode 100644 index 0d4aee2ea9..0000000000 --- a/source/java/org/alfresco/repo/admin/patch/impl/AVMPermissionDataPatch.java +++ /dev/null @@ -1,58 +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 . - */ -package org.alfresco.repo.admin.patch.impl; - -import org.springframework.extensions.surf.util.I18NUtil; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - - -/** - * The roles defined in permissionsDefinition.xml moved from wca:webfolder to cm:cmobject. - * This effects the data stored in the permission table. - *

- * - */ -public class AVMPermissionDataPatch extends AbstractPermissionChangePatch -{ - private static final String MSG_SUCCESS = "patch.updateAvmPermissionData.result"; - - private static final QName TYPE_QNAME_OLD = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "webfolder"); - private static final QName TYPE_QNAME_NEW = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "cmobject"); - private static final String[] NAMES = new String[] {"ContentManager", "ContentPublisher", "ContentContributor", "ContentReviewer"}; - - @Override - protected String applyInternal() throws Exception - { - int updateCount = 0; - for (String permissionName : NAMES) - { - updateCount += super.renamePermission( - AVMPermissionDataPatch.TYPE_QNAME_OLD, - permissionName, - AVMPermissionDataPatch.TYPE_QNAME_NEW, - permissionName); - } - - // build the result message - String msg = I18NUtil.getMessage(MSG_SUCCESS, updateCount); - // done - return msg; - } -} diff --git a/source/java/org/alfresco/repo/admin/patch/impl/AVMToADMRemoteStorePatch.java b/source/java/org/alfresco/repo/admin/patch/impl/AVMToADMRemoteStorePatch.java deleted file mode 100644 index 1537629262..0000000000 --- a/source/java/org/alfresco/repo/admin/patch/impl/AVMToADMRemoteStorePatch.java +++ /dev/null @@ -1,697 +0,0 @@ -/* - * Copyright (C) 2005-2011 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 . - */ -package org.alfresco.repo.admin.patch.impl; - -import java.io.IOException; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedMap; -import java.util.StringTokenizer; -import java.util.TreeMap; -import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.admin.patch.AbstractPatch; -import org.alfresco.repo.batch.BatchProcessWorkProvider; -import org.alfresco.repo.batch.BatchProcessor; -import org.alfresco.repo.batch.BatchProcessor.BatchProcessWorker; -import org.alfresco.repo.model.filefolder.HiddenAspect; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.model.FileExistsException; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.model.FileFolderUtil; -import org.alfresco.service.cmr.model.FileInfo; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException; -import org.alfresco.service.cmr.repository.InvalidNodeRefException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.rule.RuleService; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.dao.ConcurrencyFailureException; -import org.springframework.extensions.surf.util.I18NUtil; -import org.springframework.extensions.surf.util.URLDecoder; - -/** - * Patch to migrate the AVM 'sitestore' Remote Store content to the new ADM - * location for surf-configuration under the Sites folder in 4.0. - * - * @see org.alfresco.repo.web.scripts.bean.ADMRemoteStore - * @author Kevin Roast - * @since 4.0 - */ -public class AVMToADMRemoteStorePatch extends AbstractPatch -{ - private static final Log logger = LogFactory.getLog(AVMToADMRemoteStorePatch.class); - - private static final String MSG_MIGRATION_COMPLETE = "patch.avmToAdmRemoteStore.complete"; - private static final String SITE_CACHE_ID = "_SITE_CACHE"; - - // patterns used to match site and user specific configuration locations - // @see org.alfresco.repo.web.scripts.bean.ADMRemoteStore - private static final Pattern USER_PATTERN_1 = Pattern.compile(".*/components/.*\\.user~(.*)~.*"); - private static final Pattern USER_PATTERN_2 = Pattern.compile(".*/pages/user/(.*?)(/.*)?$"); - private static final Pattern SITE_PATTERN_1 = Pattern.compile(".*/components/.*\\.site~(.*)~.*"); - private static final Pattern SITE_PATTERN_2 = Pattern.compile(".*/pages/site/(.*?)(/.*)?$"); - // name of the surf config folder - private static final String SURF_CONFIG = "surf-config"; - - private static final int SITE_BATCH_THREADS = 4; - private static final int SITE_BATCH_SIZE = 250; - private static final int MIGRATE_BATCH_THREADS = 4; - private static final int MIGRATE_BATCH_SIZE = 250; - - private static final String SEPARATOR = "@"; - - private Map siteReferenceCache = null; - private SortedMap paths; - private SortedMap retryPaths; - private NodeRef surfConfigRef = null; - private ThreadLocal> lastFolderCache = new ThreadLocal>() - { - protected Pair initialValue() - { - return new Pair("", null); - }; - }; - - private ContentService contentService; - private FileFolderService fileFolderService; - private SiteService siteService; - private AVMService avmService; - private RuleService ruleService; - private HiddenAspect hiddenAspect; - private String avmStore; - private String avmRootPath = "/"; - - - /** - * @param contentService the ContentService to set - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * @param fileFolderService the FileFolderService to set - */ - public void setFileFolderService(FileFolderService fileFolderService) - { - this.fileFolderService = fileFolderService; - } - - /** - * @param siteService the SiteService to set - */ - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - /** - * @param avmService the avmService to set - */ - public void setAvmService(AVMService avmService) - { - this.avmService = avmService; - } - - /** - * @param ruleService the rule service to set - */ - public void setRuleService(RuleService ruleService) - { - this.ruleService = ruleService; - } - - /** - * @param avmStore the avmStore to set - */ - public void setAvmStore(String avmStore) - { - this.avmStore = avmStore; - } - - /** - * @param avmRootPath the avmRootPath to set - */ - public void setAvmRootPath(String avmRootPath) - { - if (avmRootPath != null && avmRootPath.length() != 0) - { - this.avmRootPath = avmRootPath; - } - } - - public void setHiddenAspect(HiddenAspect hiddenAspect) - { - this.hiddenAspect = hiddenAspect; - } - - @Override - protected void checkProperties() - { - super.checkProperties(); - checkPropertyNotNull(avmService, "avmService"); - checkPropertyNotNull(avmStore, "avmStore"); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.admin.patch.AbstractPatch#applyInternal() - */ - @Override - protected String applyInternal() throws Exception - { - this.retryPaths = new TreeMap(); - - // get user names that will be used to RunAs and set permissions later - final String systemUser = AuthenticationUtil.getSystemUserName(); - - // firstly retrieve all AVM paths and descriptors that we need to process - // execute in a single transaction to retrieve the stateless object list - RetryingTransactionCallback work = new RetryingTransactionCallback() - { - public String execute() throws Exception - { - long start = System.currentTimeMillis(); - paths = retrieveAVMPaths(); - logger.info("Retrieved: " + paths.size() + " AVM paths in " + (System.currentTimeMillis()-start) + "ms"); - - // also calculate the surf-config reference under the Sites folder while in the txn - surfConfigRef = getSurfConfigNodeRef(siteService.getSiteRoot()); - - // pre-create folders that may cause contention later during multi-threaded batch processing - List folderPath = new ArrayList(4); - folderPath.add("components"); - FileFolderUtil.makeFolders(fileFolderService, surfConfigRef, folderPath, ContentModel.TYPE_FOLDER); - folderPath.clear(); - folderPath.add("pages"); - folderPath.add("user"); - FileFolderUtil.makeFolders(fileFolderService, surfConfigRef, folderPath, ContentModel.TYPE_FOLDER); - - // return the tenant system user name while in the txn - return tenantAdminService.getDomainUser(systemUser, tenantAdminService.getCurrentUserDomain()); - } - }; - final String tenantSystemUser = this.transactionHelper.doInTransaction(work, false, true); - - try - { - // init the siteid to surf-config noderef cache - this.siteReferenceCache = new ConcurrentHashMap(16384); - - // build a set of unique site names - final Set sites = new HashSet(paths.size()); - Matcher matcher; - for (String path: paths.keySet()) - { - String siteName = null; - if ((matcher = SITE_PATTERN_1.matcher(path)).matches()) - { - siteName = matcher.group(1); - } - else if ((matcher = SITE_PATTERN_2.matcher(path)).matches()) - { - siteName = matcher.group(1); - } - if (siteName != null) - { - sites.add(siteName); - } - } - - // retrieve the sites for the batch work provider - final Iterator siteItr = sites.iterator(); - - // the work provider for the site 'surf-config' folder pre-create step - BatchProcessWorkProvider siteWorkProvider = new BatchProcessWorkProvider() - { - @Override - public synchronized Collection getNextWork() - { - int batchCount = 0; - - List siteBatch = new ArrayList(SITE_BATCH_SIZE); - while (siteItr.hasNext() && batchCount++ != SITE_BATCH_SIZE) - { - siteBatch.add(siteItr.next()); - } - return siteBatch; - } - - @Override - public synchronized int getTotalEstimatedWorkSize() - { - return sites.size(); - } - }; - - // batch process the sites in the set and pre-create the 'surf-config' folders for each site - // add each config folder noderef to our cache ready for the config file migration processing - BatchProcessor siteBatchProcessor = new BatchProcessor( - "AVMToADMRemoteStorePatch", - this.transactionHelper, - siteWorkProvider, - SITE_BATCH_THREADS, - SITE_BATCH_SIZE, - this.applicationEventPublisher, - logger, - SITE_BATCH_SIZE * 10); - - BatchProcessWorker siteWorker = new BatchProcessWorker() - { - @Override - public void beforeProcess() throws Throwable - { - ruleService.disableRules(); - AuthenticationUtil.setRunAsUser(tenantSystemUser); - } - - @Override - public void afterProcess() throws Throwable - { - ruleService.enableRules(); - AuthenticationUtil.clearCurrentSecurityContext(); - } - - @Override - public String getIdentifier(String entry) - { - return entry; - } - - @Override - public void process(String siteName) throws Throwable - { - // get the Site NodeRef - SiteInfo siteInfo = AVMToADMRemoteStorePatch.this.siteService.getSite(siteName); - - // ALF-16256: We've actually looked up the site by case insensitive name. But there may actually be - // paths in existence for the same site name but with different cases. We are only interested in the - // site whose name matches EXACTLY. - if (siteInfo != null && siteInfo.getShortName().equals(siteName)) - { - // create the 'surf-config' folder for the site and cache the NodeRef to it - NodeRef surfConfigRef = getSurfConfigNodeRef(siteInfo.getNodeRef()); - siteReferenceCache.put(siteName, surfConfigRef); - - // pre-create folders that may cause contention later during multi-threaded batch processing - List folderPath = new ArrayList(4); - folderPath.add("components"); - FileFolderUtil.makeFolders(fileFolderService, surfConfigRef, folderPath, ContentModel.TYPE_FOLDER); - folderPath.clear(); - folderPath.add("pages"); - folderPath.add("site"); - FileFolderUtil.makeFolders(fileFolderService, surfConfigRef, folderPath, ContentModel.TYPE_FOLDER); - } - else - { - logger.info("WARNING: unable to find site id: " + siteName); - } - } - }; - long start = System.currentTimeMillis(); - siteBatchProcessor.process(siteWorker, true); - logger.info("Created 'surf-config' folders for: " + this.siteReferenceCache.size() + " sites in " + (System.currentTimeMillis()-start) + "ms"); - - // retrieve AVM NodeDescriptor objects for the paths - final Iterator pathItr = this.paths.keySet().iterator(); - - // the work provider for the config file migration - BatchProcessWorkProvider migrateWorkProvider = new BatchProcessWorkProvider() - { - @Override - public synchronized Collection getNextWork() - { - int batchCount = 0; - - List nodes = new ArrayList(MIGRATE_BATCH_SIZE); - while (pathItr.hasNext() && batchCount++ != MIGRATE_BATCH_SIZE) - { - nodes.add(paths.get(pathItr.next())); - } - return nodes; - } - - @Override - public synchronized int getTotalEstimatedWorkSize() - { - return paths.size(); - } - }; - - // prepare the batch processor and worker object - BatchProcessor batchProcessor = new BatchProcessor( - "AVMToADMRemoteStorePatch", - this.transactionHelper, - migrateWorkProvider, - MIGRATE_BATCH_THREADS, - MIGRATE_BATCH_SIZE, - this.applicationEventPublisher, - logger, - MIGRATE_BATCH_SIZE * 10); - - BatchProcessWorker worker = new BatchProcessWorker() - { - @Override - public void beforeProcess() throws Throwable - { - ruleService.disableRules(); - AuthenticationUtil.setRunAsUser(tenantSystemUser); - } - - @Override - public void afterProcess() throws Throwable - { - ruleService.enableRules(); - AuthenticationUtil.clearCurrentSecurityContext(); - } - - @Override - public String getIdentifier(AVMNodeDescriptor entry) - { - return entry.getPath(); - } - - @Override - public void process(AVMNodeDescriptor entry) throws Throwable - { - migrateNode(entry); - } - }; - batchProcessor.process(worker, true); - - // retry the paths that were blocked due to multiple threads attemping to create - // the same folder at the same time - these are dealt with now in a single thread! - if (this.retryPaths.size() != 0) - { - logger.info("Retrying " + this.retryPaths.size() + " paths..."); - RetryingTransactionCallback retrywork = new RetryingTransactionCallback() - { - public Void execute() throws Exception - { - for (String path : retryPaths.keySet()) - { - migrateNode(retryPaths.get(path)); - } - return null; - } - }; - this.transactionHelper.doInTransaction(retrywork, false, true); - } - - logger.info("Migrated: " + this.paths.size() + " AVM nodes to DM in " + (System.currentTimeMillis()-start) + "ms"); - } - finally - { - // dispose of our cache - this.siteReferenceCache = null; - } - - return I18NUtil.getMessage(MSG_MIGRATION_COMPLETE); - } - - /** - * Migrate a single AVM node. Match, convert and copy the AVM surf config path to - * the new ADM surf-config folder location, creating appropriate sub-folders and - * finally copying the content from the AVM to the DM. - * - * @param avmNode AVMNodeDescriptor - */ - private void migrateNode(final AVMNodeDescriptor avmNode) - { - String path = avmNode.getPath(); - - final boolean debug = logger.isDebugEnabled(); - // what type of path is this? - int index = path.indexOf(this.avmRootPath); - if (index != -1) - { - // crop path removing the early paths we are not interested in - path = path.substring(index + this.avmRootPath.length()); - if (debug) logger.debug("...processing path: " + path); - - // break down the path into its component elements to generate the parent folders - List pathElements = new ArrayList(4); - final StringTokenizer t = new StringTokenizer(path, "/"); - // the remainining path is of the form /[/]/.xml - while (t.hasMoreTokens()) - { - pathElements.add(t.nextToken()); - } - - // match path against generic, user and site - String userId = null; - String siteName = null; - Matcher matcher; - if ((matcher = USER_PATTERN_1.matcher(path)).matches()) - { - userId = URLDecoder.decode(matcher.group(1)); - } - else if ((matcher = USER_PATTERN_2.matcher(path)).matches()) - { - userId = URLDecoder.decode(matcher.group(1)); - } - else if ((matcher = SITE_PATTERN_1.matcher(path)).matches()) - { - siteName = matcher.group(1); - } - else if ((matcher = SITE_PATTERN_2.matcher(path)).matches()) - { - siteName = matcher.group(1); - } - - NodeRef surfConfigRef; - if (siteName != null) - { - if (debug) logger.debug("...resolved site id: " + siteName); - surfConfigRef = siteReferenceCache.get(siteName); - if (surfConfigRef == null) - { - logger.info("WARNING: unable to migrate path as site id cannot be found: " + siteName); - } - } - else if (userId != null) - { - if (debug) logger.debug("...resolved user id: " + userId); - surfConfigRef = this.surfConfigRef; - } - else - { - if (debug) logger.debug("...resolved generic path."); - surfConfigRef = this.surfConfigRef; - } - - // ensure folders exist down to the specified parent - List folderPath = pathElements.subList(0, pathElements.size() - 1); - NodeRef parentFolder = null; - Pair lastFolderCache = this.lastFolderCache.get(); - String folderKey = (siteName != null) ? siteName + folderPath.toString() : folderPath.toString(); - if (folderKey.equals(lastFolderCache.getFirst())) - { - // found match to last used folder NodeRef - if (debug) logger.debug("...cache hit - matched last folder reference: " + folderKey); - parentFolder = lastFolderCache.getSecond(); - } - if (parentFolder == null) - { - try - { - parentFolder = FileFolderUtil.makeFolders( - this.fileFolderService, - surfConfigRef, - folderPath, - ContentModel.TYPE_FOLDER).getNodeRef(); - } - catch (FileExistsException fe) - { - // this occurs if a different thread running a separate txn has created a folder - // that we expected to exist - save a reference to this path to retry it again later - logger.warn("Unable to create folder: " + fe.getName() + " for path: " + avmNode.getPath() + - " - as another txn is busy, will retry later."); - retryPaths.put(avmNode.getPath(), avmNode); - return; - } - // save in last folder cache - lastFolderCache.setFirst(folderKey); - lastFolderCache.setSecond(parentFolder); - } - - try - { - if (userId != null) - { - // run as the appropriate user id to execute - AuthenticationUtil.pushAuthentication(); - AuthenticationUtil.setFullyAuthenticatedUser(userId); - try - { - // create new node and perform writer content copy of the content from the AVM to the DM store - FileInfo fileInfo = fileFolderService.create( - parentFolder, avmNode.getName(), ContentModel.TYPE_CONTENT); - Map aspectProperties = new HashMap(1, 1.0f); - aspectProperties.put(ContentModel.PROP_IS_INDEXED, false); - nodeService.addAspect(fileInfo.getNodeRef(), ContentModel.ASPECT_INDEX_CONTROL, aspectProperties); - ContentWriter writer = contentService.getWriter( - fileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true); - writer.guessMimetype(fileInfo.getName()); - writer.putContent(avmService.getContentReader(-1, avmNode.getPath())); - } - finally - { - AuthenticationUtil.popAuthentication(); - } - } - else - { - // create new node and perform writer content copy of the content from the AVM to the DM store - FileInfo fileInfo = fileFolderService.create( - parentFolder, avmNode.getName(), ContentModel.TYPE_CONTENT); - Map aspectProperties = new HashMap(1, 1.0f); - aspectProperties.put(ContentModel.PROP_IS_INDEXED, false); - nodeService.addAspect(fileInfo.getNodeRef(), ContentModel.ASPECT_INDEX_CONTROL, aspectProperties); - ContentWriter writer = contentService.getWriter( - fileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true); - writer.guessMimetype(fileInfo.getName()); - writer.putContent(avmService.getContentReader(-1, avmNode.getPath())); - } - } - catch (InvalidNodeRefException refErr) - { - // this occurs if a different thread running a separate txn has not yet created a folder - // that we expected to exist - save a reference to this path to retry it again later - logger.warn("Parent folder does not exist yet: " + refErr.getNodeRef() + " for path: " + avmNode.getPath() + - " - as another txn is busy, will retry later."); - retryPaths.put(avmNode.getPath(), avmNode); - } - } - } - - /** - * Return the "surf-config" noderef under the given root. Create the folder if it - * does not exist yet. - * - * @param rootRef Parent node reference where the "surf-config" folder should be - * - * @return surf-config folder ref - */ - private NodeRef getSurfConfigNodeRef(final NodeRef rootRef) - { - NodeRef surfConfigRef = this.nodeService.getChildByName( - rootRef, ContentModel.ASSOC_CONTAINS, SURF_CONFIG); - if (surfConfigRef == null) - { - if (logger.isDebugEnabled()) - logger.debug("'surf-config' folder not found under current path, creating..."); - QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, SURF_CONFIG); - Map properties = new HashMap(1, 1.0f); - properties.put(ContentModel.PROP_NAME, (Serializable) SURF_CONFIG); - try - { - ChildAssociationRef ref = this.nodeService.createNode( - rootRef, ContentModel.ASSOC_CONTAINS, assocQName, ContentModel.TYPE_FOLDER, properties); - surfConfigRef = ref.getChildRef(); - - // surf-config needs to be hidden - applies index control aspect as part of the hidden aspect - hiddenAspect.hideNode(ref.getChildRef(), false, false, false); - } - catch (DuplicateChildNodeNameException dupErr) - { - // This exception is excepted in multi-threaded creation scenarios - but since fix for - // ALF-10280 rev 30468 - it no longer automatically retries in the txn - therefore we - // throw out an exception that does retry instead. - throw new ConcurrencyFailureException("Forcing batch retry due to DuplicateChildNodeNameException" , dupErr); - } - } - return surfConfigRef; - } - - /** - * @return the AVM paths for surf config object in the AVM sitestore - */ - private SortedMap retrieveAVMPaths() throws Exception - { - logger.info("Retrieving paths from AVM store: " + this.avmStore + ":" + this.avmRootPath); - - SortedMap paths = new TreeMap(); - - String avmPath; - if (this.tenantAdminService.getCurrentUserDomain().isEmpty()) - { - avmPath = this.avmStore + ":" + this.avmRootPath; - } - else - { - avmPath = SEPARATOR + this.tenantAdminService.getCurrentUserDomain() + SEPARATOR + this.avmStore + ":" + this.avmRootPath; - } - - AVMNodeDescriptor node = this.avmService.lookup(-1, avmPath); - if (node != null) - { - traverseNode(paths, node); - } - - logger.info("Found: " + paths.size() + " AVM files nodes to migrate"); - - return paths; - } - - private void traverseNode(final SortedMap paths, final AVMNodeDescriptor node) - throws IOException - { - final boolean debug = logger.isDebugEnabled(); - final SortedMap listing = this.avmService.getDirectoryListing(node); - for (final AVMNodeDescriptor n : listing.values()) - { - if (n.isFile()) - { - if (debug) logger.debug("...adding path: " + n.getPath()); - paths.put(n.getPath(), n); - if (paths.size() % 10000 == 0) - { - logger.info("Collected " + paths.size() + " AVM paths..."); - } - } - else if (n.isDirectory()) - { - traverseNode(paths, n); - } - } - } -} diff --git a/source/java/org/alfresco/repo/admin/patch/impl/AVMWebProjectInheritPermissionsPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/AVMWebProjectInheritPermissionsPatch.java deleted file mode 100644 index 00ce065b76..0000000000 --- a/source/java/org/alfresco/repo/admin/patch/impl/AVMWebProjectInheritPermissionsPatch.java +++ /dev/null @@ -1,105 +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 . - */ -package org.alfresco.repo.admin.patch.impl; - -import java.util.List; - -import org.alfresco.model.WCMAppModel; -import org.alfresco.repo.admin.patch.AbstractPatch; -import org.alfresco.repo.importer.ImporterBootstrap; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.ResultSetRow; -import org.alfresco.service.cmr.search.SearchParameters; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Patch to break the inheritance of permissions on AVM Web Project Folders. - * This removes the need for admins to write a script or similar to by default hide web folders - * to all users except those explicitly invited (given permissions) to the project. - * - * @author Kevin Roast - */ -public class AVMWebProjectInheritPermissionsPatch extends AbstractPatch -{ - private static final String MSG_SUCCESS = "patch.avmWebProjectInheritPermissions.result"; - - private ImporterBootstrap spacesImporterBootstrap; - private PermissionService permissionService; - - public void setSpacesImporterBootstrap(ImporterBootstrap spacesImporterBootstrap) - { - this.spacesImporterBootstrap = spacesImporterBootstrap; - } - - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - /* (non-Javadoc) - * @see org.alfresco.repo.admin.patch.AbstractPatch#applyInternal() - */ - @Override - protected String applyInternal() throws Exception - { - SearchParameters sp = new SearchParameters(); - sp.setLanguage(SearchService.LANGUAGE_LUCENE); - sp.setQuery("TYPE:\"wca:webfolder\""); - sp.addStore(spacesImporterBootstrap.getStoreRef()); - ResultSet rs = null; - try - { - rs = searchService.query(sp); - for (ResultSetRow row : rs) - { - // break permission inheritance for the Web Project nodes - this.permissionService.setInheritParentPermissions(row.getNodeRef(), false); - - // ensure that permissions are explicitly assigned for all Content Manager roles - List userInfoRefs = this.nodeService.getChildAssocs( - row.getNodeRef(), WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef ref : userInfoRefs) - { - NodeRef userInfoRef = ref.getChildRef(); - String username = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME); - String userrole = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE); - - if ("ContentManager".equals(userrole)) - { - this.permissionService.setPermission(row.getNodeRef(), username, "ContentManager", true); - } - } - } - } - finally - { - if (rs != null) - { - rs.close(); - } - } - - return I18NUtil.getMessage(MSG_SUCCESS); - } -} diff --git a/source/java/org/alfresco/repo/admin/patch/impl/AuthorityDefaultZonesPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/AuthorityDefaultZonesPatch.java index 33134be336..1ed0ac13bd 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/AuthorityDefaultZonesPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/AuthorityDefaultZonesPatch.java @@ -25,8 +25,6 @@ import java.util.Set; import org.alfresco.repo.admin.patch.AbstractPatch; import org.alfresco.repo.admin.patch.PatchExecuter; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.avm.AVMStoreDescriptor; import org.alfresco.service.cmr.security.AuthorityService; import org.alfresco.service.cmr.security.AuthorityType; import org.alfresco.service.cmr.site.SiteInfo; @@ -50,7 +48,6 @@ public class AuthorityDefaultZonesPatch extends AbstractPatch /** The authority service. */ private AuthorityService authorityService; - private AVMService avmService; private SiteService siteService; /** @@ -64,18 +61,8 @@ public class AuthorityDefaultZonesPatch extends AbstractPatch this.authorityService = authorityService; } - /** - * Set the avm service - * @param avmService - */ - public void setAvmService(AVMService avmService) - { - this.avmService = avmService; - } - /** * Set the site service - * @param siteService */ public void setSiteService(SiteService siteService) { @@ -126,17 +113,9 @@ public class AuthorityDefaultZonesPatch extends AbstractPatch shareZones.add(AuthorityService.ZONE_APP_SHARE); shareZones.add(AuthorityService.ZONE_AUTH_ALFRESCO); - List stores = avmService.getStores(); List sites = siteService.listSites(null, null); - List groupActions = new ArrayList(stores.size() * 4 + sites.size() * 5 + 1); - for (AVMStoreDescriptor store : stores) - { - groupActions.add(new Action("GROUP_"+store.getName()+"-ContentManager", wcmZones, ActionType.SET)); - groupActions.add(new Action("GROUP_"+store.getName()+"-ContentPublisher", wcmZones, ActionType.SET)); - groupActions.add(new Action("GROUP_"+store.getName()+"-ContentContributor", wcmZones, ActionType.SET)); - groupActions.add(new Action("GROUP_"+store.getName()+"-ContentReviewer", wcmZones, ActionType.SET)); - } + List groupActions = new ArrayList(sites.size() * 5 + 1); for (SiteInfo site : sites) { groupActions.add(new Action("GROUP_site_" + site.getShortName(), shareZones, ActionType.SET)); diff --git a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrAVMLocksPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrAVMLocksPatch.java deleted file mode 100644 index 890c36b16e..0000000000 --- a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrAVMLocksPatch.java +++ /dev/null @@ -1,125 +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 . - */ -package org.alfresco.repo.admin.patch.impl; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.repo.admin.patch.AbstractPatch; -import org.alfresco.repo.avm.locking.AVMLockingServiceImpl; -import org.alfresco.repo.domain.patch.PatchDAO; -import org.alfresco.service.cmr.attributes.AttributeService; -import org.alfresco.wcm.util.WCMUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.ibatis.session.ResultContext; -import org.apache.ibatis.session.ResultHandler; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Migrate AVM lock attributes (from 'alf_*attribute*' to 'alf_prop_*') - * - * @author janv - * @since 3.4 - */ -public class MigrateAttrAVMLocksPatch extends AbstractPatch -{ - private Log logger = LogFactory.getLog(this.getClass()); - - private static final String MSG_SUCCESS = "patch.migrateAttrAVMLocks.result"; - - private AttributeService attributeService; - private PatchDAO patchDAO; - - public void setAttributeService(AttributeService attributeService) - { - this.attributeService = attributeService; - } - - public void setPatchDAO(PatchDAO patchDAO) - { - this.patchDAO = patchDAO; - } - - @Override - protected String applyInternal() throws Exception - { - long startTime = System.currentTimeMillis(); - - AVMLockResultHandler handler = new AVMLockResultHandler(); - patchDAO.migrateOldAttrAVMLocks(handler); - - if (handler.total > 0) - { - logger.info("Processed "+handler.total+" AVM Lock attrs in "+(System.currentTimeMillis()-startTime)/1000+" secs"); - } - - // build the result message - String msg = I18NUtil.getMessage(MSG_SUCCESS, handler.total); - // done - return msg; - } - - /** - * Row handler for migrating AVM Locks - */ - private class AVMLockResultHandler implements ResultHandler - { - private int total = 0; - - private AVMLockResultHandler() - { - } - @SuppressWarnings("unchecked") - public void handleResult(ResultContext context) - { - Map result = (Map)context.getResultObject(); - - String wpStoreId = (String)result.get("wpStoreId"); - String path = (String)result.get("relPath"); - String avmStore = (String)result.get("avmStore"); - String lockOwner = (String)result.get("owner1"); - - String relPath = AVMLockingServiceImpl.normalizePath(path); - - HashMap lockData = new HashMap(2); - lockData.put(AVMLockingServiceImpl.KEY_LOCK_OWNER, lockOwner); - lockData.put(WCMUtil.LOCK_KEY_STORE_NAME, avmStore); - - if (!attributeService.exists(AVMLockingServiceImpl.KEY_AVM_LOCKS, wpStoreId, relPath)) - { - attributeService.createAttribute(lockData, AVMLockingServiceImpl.KEY_AVM_LOCKS, wpStoreId, relPath); - if (logger.isTraceEnabled()) - { - logger.trace("Set AVM Lock attr [wpStoreId=" + wpStoreId + ", relPath=" + relPath + ", lockOwner=" + lockOwner + ", avmStore=" + avmStore + "]"); - } - total++; - } - else - { - logger.warn("'" + path + "' path has duplicates in normalized form. AVM lock unique attribute creation has been skipped"); - } - - if (logger.isDebugEnabled() && (total == 0 || (total % 1000 == 0) )) - { - logger.debug(" Handled " + total + " AVM Lock attributes"); - } - } - } -} diff --git a/source/java/org/alfresco/repo/admin/patch/impl/MultiTShareExistingTenantsPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/MultiTShareExistingTenantsPatch.java index 00a20ccf95..e325a927cc 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/MultiTShareExistingTenantsPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/MultiTShareExistingTenantsPatch.java @@ -23,7 +23,6 @@ import java.util.Properties; import org.springframework.extensions.surf.util.I18NUtil; import org.alfresco.repo.admin.patch.AbstractPatch; -import org.alfresco.repo.site.SiteAVMBootstrap; import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.workflow.WorkflowDeployer; diff --git a/source/java/org/alfresco/repo/avm/AVMCrawler.java b/source/java/org/alfresco/repo/avm/AVMCrawler.java deleted file mode 100644 index 9978f1f70b..0000000000 --- a/source/java/org/alfresco/repo/avm/AVMCrawler.java +++ /dev/null @@ -1,329 +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 . */ - -package org.alfresco.repo.avm; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.InputStreamReader; -import java.io.PrintStream; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Random; - -import net.sf.acegisecurity.Authentication; - -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.avm.AVMException; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMNotFoundException; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.avm.AVMStoreDescriptor; -import org.alfresco.service.cmr.repository.ContentIOException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.dao.ConcurrencyFailureException; - - -/** - * This is another tester designed to emulate more typical use patterns. - * @author britt - */ -class AVMCrawler implements Runnable -{ - private static Log logger = LogFactory.getLog(AVMCrawler.class); - - /** - * The AVMService to use. - */ - private AVMService fService; - - private Authentication authentication; - - /** - * The Operation count. - */ - private int fOpCount; - - /** - * Whether we are done. - */ - private boolean fDone; - - /** - * Whether an error has occurred. - */ - private boolean fError; - private String fErrorStackTrace = null; - - /** - * Random number generator. - */ - private Random fRandom; - - /** - * Make up a new one. - * @param service The AVMService. - */ - public AVMCrawler(AVMService service, Authentication authentication) - { - fService = service; - this.authentication = authentication; - fOpCount = 0; - fDone = false; - fError = false; - fRandom = new Random(); - } - - /** - * Tell this thread it is done. - */ - public void setDone() - { - fDone = true; - } - - /** - * Is this thread in an error state. - */ - public boolean getError() - { - return fError; - } - - /** - * Get error stack trace - */ - public String getErrorStackTrace() - { - return fErrorStackTrace; - } - - /** - * Implementation of run. - */ - public void run() - { - try - { - AuthenticationUtil.setFullAuthentication(authentication); - while (!fDone) - { - doCrawl(); - } - } - catch (Throwable t) - { - t.printStackTrace(); - - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - t.printStackTrace(pw); - - fError = true; - fErrorStackTrace = sw.toString(); - } - finally - { - AuthenticationUtil.clearCurrentSecurityContext(); - } - } - - /** - * Do one crawl. - */ - public void doCrawl() - { - try - { - List reps = fService.getStores(); - fOpCount++; - - if (reps.size() == 0) - { - logger.warn("No AVM stores"); - return; - } - - AVMStoreDescriptor repDesc = reps.get(fRandom.nextInt(reps.size())); - Map rootListing = fService.getDirectoryListing(-1, repDesc.getName() + ":/"); - fOpCount++; - // Get all the directories in the root. - List dirs = new ArrayList(); - for (AVMNodeDescriptor desc : rootListing.values()) - { - if (desc.isDirectory()) - { - dirs.add(desc); - } - } - - if (dirs.size() == 0) - { - logger.warn("No dirs in root: "+repDesc.getName() + ":/"); - } - else - { - AVMNodeDescriptor dir = dirs.get(fRandom.nextInt(dirs.size())); - int depth = 1; - while (dir != null) - { - Map listing = fService.getDirectoryListing(-1, dir.getPath()); - fOpCount++; - List files = new ArrayList(); - dirs = new ArrayList(); - for (AVMNodeDescriptor desc : listing.values()) - { - if (desc.isDirectory()) - { - dirs.add(desc); - } - else - { - files.add(desc); - } - } - // Read some files if there are any. - if (files.size() > 0) - { - for (int i = 0; i < 6; i++) - { - String path = files.get(fRandom.nextInt(files.size())).getPath(); - logger.info("Reading: " + path); - BufferedReader - reader = new BufferedReader - (new InputStreamReader - (fService.getFileInputStream(-1, path))); - fOpCount++; - String line = reader.readLine(); - if (logger.isDebugEnabled()) - { - logger.debug(line); - } - reader.close(); - } - // Modify some files. - for (int i = 0; i < 2; i++) - { - String path = files.get(fRandom.nextInt(files.size())).getPath(); - logger.info("Modifying: " + path); - PrintStream out = new PrintStream(fService.getFileOutputStream(path)); - out.println("I am " + path); - out.close(); - fOpCount++; - } - } - if (fRandom.nextInt(depth) < depth - 1) - { - // Create some files. - for (int i = 0; i < 1; i++) - { - String name = randomName(); - if (listing.containsKey(name)) - { - break; - } - logger.info("Creating File: " + name); - fService.createFile(dir.getPath(), name, - new ByteArrayInputStream(("I am " + name).getBytes())); - fOpCount++; - } - } - // 1 in 100 times create a directory. - if (fRandom.nextInt(100) == 0) - { - String name = randomName(); - if (listing.containsKey(name)) - { - break; - } - logger.info("Creating Directory: " + name); - fService.createDirectory(dir.getPath(), name); - fOpCount++; - } - if (listing.size() > 0) - { - // 1 in 100 times remove something - if (fRandom.nextInt(100) == 0) - { - List names = new ArrayList(listing.keySet()); - String name = names.get(fRandom.nextInt(names.size())); - logger.info("Removing: " + name); - fService.removeNode(dir.getPath(), - name); - fOpCount++; - } - } - if (dirs.size() > 0) - { - dir = dirs.get(fRandom.nextInt(dirs.size())); - } - else - { - dir = null; - } - depth++; - } - } - - if (fRandom.nextInt(16) == 0) - { - logger.info("Snapshotting: " + repDesc.getName()); - fService.createSnapshot(repDesc.getName(), null, null); - fOpCount++; - } - } - catch (Exception e) - { - if ((e instanceof AVMNotFoundException) || - (e instanceof AVMException) || - (e instanceof ContentIOException) || - (e instanceof ConcurrencyFailureException)) - { - logger.warn(e.getMessage()); - return; - } - - e.printStackTrace(System.err); - throw new AVMException("Failure", e); - } - } - - /** - * Get a random two character string. - * @return A random name. - */ - private String randomName() - { - char [] chars = new char[2]; - chars[0] = (char)('a' + fRandom.nextInt(12)); - chars[1] = (char)('a' + fRandom.nextInt(12)); - return new String(chars); - } - - /** - * Get the operation count. - */ - public int getOpCount() - { - return fOpCount; - } -} diff --git a/source/java/org/alfresco/repo/avm/AVMDeploymentAttemptCleaner.java b/source/java/org/alfresco/repo/avm/AVMDeploymentAttemptCleaner.java deleted file mode 100644 index 86ef55c6bc..0000000000 --- a/source/java/org/alfresco/repo/avm/AVMDeploymentAttemptCleaner.java +++ /dev/null @@ -1,166 +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 . - */ -package org.alfresco.repo.avm; - -import java.util.Calendar; -import java.util.Date; - -import org.alfresco.model.WCMAppModel; -import org.alfresco.repo.importer.ImporterBootstrap; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -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.service.transaction.TransactionService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Bean that is responsible for locating expired content and routing - * it for review to the most relevant user. - * - * @author gavinc - */ -public class AVMDeploymentAttemptCleaner -{ - // defaults in case these properties are not configured in Spring - protected long maxAge = 180L; - - protected NodeService nodeService; - protected TransactionService transactionService; - protected SearchService searchService; - protected ImporterBootstrap importerBootstrap; - - private static Log logger = LogFactory.getLog(AVMDeploymentAttemptCleaner.class); - - public AVMDeploymentAttemptCleaner() - { - } - - public void setMaxAge(long maxAge) - { - this.maxAge = new Long(maxAge); - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - public void setImporterBootstrap(ImporterBootstrap importerBootstrap) - { - this.importerBootstrap = importerBootstrap; - } - - /** - * Executes the expired content processor. - * The work is performed within a transaction running as the system user. - */ - public void execute() - { - // setup a wrapper object to run the processor within a transaction. - AuthenticationUtil.RunAsWork authorisedWork = new AuthenticationUtil.RunAsWork() - { - public String doWork() throws Exception - { - RetryingTransactionCallback expiredContentWork = new RetryingTransactionCallback() - { - public String execute() throws Exception - { - cleanAttempts(); - return null; - } - }; - return transactionService.getRetryingTransactionHelper().doInTransaction(expiredContentWork); - } - }; - - // perform the work as the system user - AuthenticationUtil.runAs(authorisedWork, AuthenticationUtil.getAdminUserName()); - } - - /** - * Entry point. - */ - private void cleanAttempts() - { - // calculate the date 'maxAge' days before today - long daysInMs = 1000L*60L*60L*24L*this.maxAge; - Date toDate = new Date(new Date().getTime() - daysInMs); - - // build the query to find deployment attempts older than this.maxAge - Calendar cal = Calendar.getInstance(); - cal.setTime(toDate); - StringBuilder query = new StringBuilder("@"); - query.append(NamespaceService.WCMAPP_MODEL_PREFIX); - query.append("\\:"); - query.append(WCMAppModel.PROP_DEPLOYATTEMPTTIME.getLocalName()); - query.append(":[0001\\-01\\-01T00:00:00 TO "); - query.append(cal.get(Calendar.YEAR)); - query.append("\\-"); - query.append((cal.get(Calendar.MONTH)+1)); - query.append("\\-"); - query.append(cal.get(Calendar.DAY_OF_MONTH)); - query.append("T00:00:00]"); - - if (logger.isDebugEnabled()) - logger.debug("Finding old deploymentattempt nodes using query: " + query.toString()); - - // do the query - ResultSet results = null; - try - { - // execute the query - results = searchService.query(this.importerBootstrap.getStoreRef(), - SearchService.LANGUAGE_LUCENE, query.toString()); - - if (logger.isDebugEnabled()) - logger.debug("Deleting " + results.length() + " old deployment attempts"); - - // iterate through the attempt nodes and delete them - for (NodeRef attempt : results.getNodeRefs()) - { - this.nodeService.deleteNode(attempt); - - if (logger.isDebugEnabled()) - logger.debug("Deleted deployment attempt: " + attempt); - } - } - finally - { - if (results != null) - { - results.close(); - } - } - } -} diff --git a/source/java/org/alfresco/repo/avm/AVMDeploymentAttemptCleanerJob.java b/source/java/org/alfresco/repo/avm/AVMDeploymentAttemptCleanerJob.java deleted file mode 100644 index 8281760a9f..0000000000 --- a/source/java/org/alfresco/repo/avm/AVMDeploymentAttemptCleanerJob.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.avm; - -import org.quartz.Job; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; - -/** - * Job to periodically execute the deployment attempt cleaner. - * - *

- * The following parameters are required: - *

    - *
  • deploymentAttemptCleaner: The deployment attempt cleaner instance
  • - *
- * - * @author gavinc - */ -public class AVMDeploymentAttemptCleanerJob implements Job -{ - /** - * Searches for old deployment attempts and removes them. - * - * @param context The job context - */ - public void execute(JobExecutionContext context) throws JobExecutionException - { - // get the expired content processor bean from the job context - AVMDeploymentAttemptCleaner cleaner = - (AVMDeploymentAttemptCleaner)context.getJobDetail().getJobDataMap().get("deploymentAttemptCleaner"); - if (cleaner == null) - { - throw new JobExecutionException("Missing job data: deploymentAttemptCleaner"); - } - - // execute the cleaner to do the actual work - cleaner.execute(); - } -} diff --git a/source/java/org/alfresco/repo/avm/AVMExpiredContentJob.java b/source/java/org/alfresco/repo/avm/AVMExpiredContentJob.java deleted file mode 100644 index 6d68137aba..0000000000 --- a/source/java/org/alfresco/repo/avm/AVMExpiredContentJob.java +++ /dev/null @@ -1,57 +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 . - */ -package org.alfresco.repo.avm; - -import org.quartz.Job; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; - -/** - * Job to periodically execute the expired content processor. - * - *

- * The following parameters are required: - *

    - *
  • expiredContent: The expired content processor instance
  • - *
- * - * @author gavinc - */ -public class AVMExpiredContentJob implements Job -{ - /** - * Searches for expired content in web project's staging area and - * prompt the last modifier of the content to review it. - * - * @param context The job context - */ - public void execute(JobExecutionContext context) throws JobExecutionException - { - // get the expired content processor bean from the job context - AVMExpiredContentProcessor expiredContentProcessor = - (AVMExpiredContentProcessor)context.getJobDetail().getJobDataMap().get("expiredContentProcessor"); - if (expiredContentProcessor == null) - { - throw new JobExecutionException("Missing job data: expiredContentProcessor"); - } - - // execute the processor to do the actual work - expiredContentProcessor.execute(); - } -} diff --git a/source/java/org/alfresco/repo/avm/AVMExpiredContentProcessor.java b/source/java/org/alfresco/repo/avm/AVMExpiredContentProcessor.java deleted file mode 100644 index 77edbb402c..0000000000 --- a/source/java/org/alfresco/repo/avm/AVMExpiredContentProcessor.java +++ /dev/null @@ -1,492 +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 . - */ -package org.alfresco.repo.avm; - -import java.io.Serializable; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.alfresco.config.JNDIConstants; -import org.alfresco.mbeans.VirtServerRegistry; -import org.alfresco.model.ContentModel; -import org.alfresco.model.WCMAppModel; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.repo.workflow.WorkflowModel; -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.locking.AVMLockingService; -import org.alfresco.service.cmr.avmsync.AVMSyncService; -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.repository.StoreRef; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.cmr.workflow.WorkflowDefinition; -import org.alfresco.service.cmr.workflow.WorkflowPath; -import org.alfresco.service.cmr.workflow.WorkflowService; -import org.alfresco.service.cmr.workflow.WorkflowTask; -import org.alfresco.service.cmr.workflow.WorkflowTaskState; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.Pair; -import org.alfresco.wcm.sandbox.SandboxConstants; -import org.alfresco.wcm.sandbox.SandboxFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Bean that is responsible for locating expired content and routing - * it for review to the most relevant user. - * - * @author gavinc - */ -public class AVMExpiredContentProcessor -{ - // defaults in case these properties are not configured in Spring - protected String workflowName = "jbpm$wcmwf:changerequest"; - - protected List workflowStores; - protected Map>> expiredContent; - protected AVMService avmService; - protected AVMSyncService avmSyncService; - protected AVMService avmLockingAwareService; - protected AVMLockingService avmLockingService; - protected NodeService nodeService; - protected WorkflowService workflowService; - protected PersonService personService; - protected PermissionService permissionService; - protected TransactionService transactionService; - protected VirtServerRegistry virtServerRegistry; - protected SearchService searchService; - private SandboxFactory sandboxFactory; - - private static Log logger = LogFactory.getLog(AVMExpiredContentProcessor.class); - - private static final String STORE_SEPARATOR = "--"; - private final static Pattern STORE_RELATIVE_PATH_PATTERN = Pattern.compile("[^:]+:(.+)"); - - public AVMExpiredContentProcessor() - { - } - - public void setAdminUserName(String adminUserName) - { - // NOTE: ignore, just for backwards compatible Spring config - } - - public void setWorkflowName(String workflowName) - { - this.workflowName = workflowName; - } - - public void setAvmService(AVMService avmService) - { - this.avmService = avmService; - } - - public void setAvmLockingService(AVMLockingService avmLockingService) - { - this.avmLockingService = avmLockingService; - } - - public void setAvmSyncService(AVMSyncService avmSyncService) - { - this.avmSyncService = avmSyncService; - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - public void setPersonService(PersonService personService) - { - this.personService = personService; - } - - public void setWorkflowService(WorkflowService workflowService) - { - this.workflowService = workflowService; - } - - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - public void setVirtServerRegistry(VirtServerRegistry virtServerRegistry) - { - this.virtServerRegistry = virtServerRegistry; - } - - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - public void setAvmLockingAwareService(AVMService avmLockingAwareService) - { - this.avmLockingAwareService = avmLockingAwareService; - } - - public void setSandboxFactory(SandboxFactory sandboxFactory) - { - this.sandboxFactory = sandboxFactory; - } - - /** - * Executes the expired content processor. - * The work is performed within a transaction running as the system user. - */ - public void execute() - { - // setup a wrapper object to run the processor within a transaction. - AuthenticationUtil.RunAsWork authorisedWork = new AuthenticationUtil.RunAsWork() - { - public String doWork() throws Exception - { - RetryingTransactionCallback expiredContentWork = new RetryingTransactionCallback() - { - public String execute() throws Exception - { - processExpiredContent(); - return null; - } - }; - return transactionService.getRetryingTransactionHelper().doInTransaction(expiredContentWork); - } - }; - - // perform the work as the system user - AuthenticationUtil.runAs(authorisedWork, AuthenticationUtil.getAdminUserName()); - - // now we know everything worked ok, let the virtualisation server - // know about all the new workflow sandboxes created (just the main stores) - for (String path : this.workflowStores) - { - this.virtServerRegistry.updateAllWebapps(-1, path, true); - } - } - - /** - * Entry point. - */ - private void processExpiredContent() - { - // create the maps to hold the expired content for each user in each web project - this.expiredContent = new HashMap>>(8); - this.workflowStores = new ArrayList(4); - - // iterate through all AVM stores and focus only on staging main stores - List stores = avmService.getStores(); - if (logger.isDebugEnabled()) - logger.debug("Checking " + stores.size() + " AVM stores..."); - - for (AVMStoreDescriptor storeDesc : stores) - { - String storeName = storeDesc.getName(); - PropertyValue val = avmService.getStoreProperty(storeName, SandboxConstants.PROP_SANDBOX_STAGING_MAIN); - - if (val != null) - { - if (logger.isDebugEnabled()) - logger.debug("Searching store '" + storeName + "' for expired content..."); - - // find ant nodes with an expiration *date* of today or before - Calendar cal = Calendar.getInstance(); - StringBuilder query = new StringBuilder("@wca\\:expirationDate:[0001\\-01\\-01T00:00:00 TO "); - query.append(cal.get(Calendar.YEAR)); - query.append("\\-"); - query.append((cal.get(Calendar.MONTH)+1)); - query.append("\\-"); - query.append(cal.get(Calendar.DAY_OF_MONTH)); - query.append("T00:00:00]"); - - // do the query - StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_AVM, storeName); - ResultSet results = this.searchService.query(storeRef, SearchService.LANGUAGE_LUCENE, - query.toString()); - try - { - if (logger.isDebugEnabled()) - logger.debug("Found " + results.length() + " potential expired item(s) in store '" + storeName + "'"); - - if (results.length() > 0) - { - for (NodeRef resultNode : results.getNodeRefs()) - { - // get the AVMNodeDescriptor object for each node found - Pair path = AVMNodeConverter.ToAVMVersionPath(resultNode); - AVMNodeDescriptor node = this.avmService.lookup(path.getFirst(), path.getSecond()); - - // process the node to see whether the date and time has passed - processNode(storeName, node); - } - } - } - finally - { - results.close(); - } - } - else - { - if (logger.isDebugEnabled()) - logger.debug("Skipping store '" + storeName + "' as it is not a main staging store"); - } - } - - // show all the expired content if debug is on - if (logger.isDebugEnabled()) - logger.debug("Expired content to action:\n" + this.expiredContent); - - // iterate through each store that has expired content, then iterate through - // each user that has expired content in that store. For each user start - // a workflow assigned to them to review the expired content. - for (String storeName: this.expiredContent.keySet()) - { - // get the name of the store and create the workflow title - // using it's name - NodeRef webProjectNodeRef = (NodeRef)avmService.getStoreProperty(storeName, - SandboxConstants.PROP_WEB_PROJECT_NODE_REF).getValue(DataTypeDefinition.NODE_REF); - String webProjectName = (String)this.nodeService.getProperty(webProjectNodeRef, - ContentModel.PROP_NAME); - String pattern = I18NUtil.getMessage("expiredcontent.workflow.title"); - String workflowTitle = MessageFormat.format(pattern, new Object[] {webProjectName}); - - Map> users = this.expiredContent.get(storeName); - for (String userName: users.keySet()) - { - List expiredContent = users.get(userName); - startWorkflow(userName, storeName, expiredContent, workflowTitle); - } - } - } - - /** - * Processes the given node. - *

- * This method is called if the node has been identified as being expired, - * the date and time is checked to make sure it has actually passed i.e. the - * date maybe todat but the time set to later in the day. If the item is - * indeed expired it's added to the expired list and the date reset. - *

- * - * @param storeName The name of the store the folder belongs to - * @param node The node to examine - */ - private void processNode(String storeName, AVMNodeDescriptor node) - { - // check supplied node is a file - if (node.isFile()) - { - // check for existence of expires aspect - String nodePath = node.getPath(); - PropertyValue expirationDateProp = this.avmService.getNodeProperty(-1, nodePath, - WCMAppModel.PROP_EXPIRATIONDATE); - - if (logger.isDebugEnabled()) - logger.debug("Examining expiration date for '" + nodePath + "': " + - expirationDateProp); - - if (expirationDateProp != null) - { - Date now = new Date(); - Date expirationDate = (Date)expirationDateProp.getValue(DataTypeDefinition.DATETIME); - - if (expirationDate != null && expirationDate.before(now)) - { - // before doing anything else see whether the item is locked by any user, - // if it is then just log a warning messge and wait until the next time around - String[] splitPath = nodePath.split(":"); - String lockOwner = this.avmLockingService.getLockOwner(storeName, splitPath[1]); - - if (logger.isDebugEnabled()) - logger.debug("lock details for '" + nodePath + "': " + lockOwner); - - if (lockOwner == null) - { - // get the map of expired content for the store - Map> storeExpiredContent = this.expiredContent.get(storeName); - if (storeExpiredContent == null) - { - storeExpiredContent = new HashMap>(4); - this.expiredContent.put(storeName, storeExpiredContent); - } - - // get the list of expired content for the last modifier of the node - String modifier = node.getLastModifier(); - List userExpiredContent = storeExpiredContent.get(modifier); - if (userExpiredContent == null) - { - userExpiredContent = new ArrayList(4); - storeExpiredContent.put(modifier, userExpiredContent); - } - - // add the content to the user's list for the current store - userExpiredContent.add(nodePath); - - if (logger.isDebugEnabled()) - logger.debug("Added " + nodePath + " to " + modifier + "'s list of expired content"); - - // reset the expiration date - this.avmService.setNodeProperty(nodePath, WCMAppModel.PROP_EXPIRATIONDATE, - new PropertyValue(DataTypeDefinition.DATETIME, null)); - - if (logger.isDebugEnabled()) - logger.debug("Reset expiration date for: " + nodePath); - } - else - { - if (logger.isWarnEnabled()) - { - logger.warn("ignoring '" + nodePath + "', although it has expired, it's currently locked"); - } - } - } - } - } - } - - /** - * Starts a workflow for the given user prompting them to review the list of given - * expired content in the given store. - * - * @param userName The user the expired content should be sent to - * @param storeName The store the expired content is in - * @param expiredContent List of paths to expired content - * @param workflowTitle The title to apply to the workflow - */ - private void startWorkflow(String userName, String storeName, List expiredContent, - String workflowTitle) - { - // find the 'Change Request' workflow - WorkflowDefinition wfDef = workflowService.getDefinitionByName(this.workflowName); - WorkflowPath path = this.workflowService.startWorkflow(wfDef.id, null); - if (path != null) - { - // extract the start task - List tasks = this.workflowService.getTasksForWorkflowPath(path.id); - if (tasks.size() == 1) - { - WorkflowTask startTask = tasks.get(0); - - if (startTask.state == WorkflowTaskState.IN_PROGRESS) - { - // determine the user to assign the workflow to - String userStore = storeName + STORE_SEPARATOR + userName; - if (this.avmService.getStore(userStore) == null) - { - // use the creator of the store (the web project creator) to assign the - // workflow to - String storeCreator = this.avmService.getStore(storeName).getCreator(); - - if (logger.isDebugEnabled()) - logger.debug("'" + userName + "' is no longer assigned to web project. Using '" + - storeCreator + "' as they created store '" + storeName + "'"); - - userName = storeCreator; - userStore = storeName + STORE_SEPARATOR + userName; - } - - // lookup the NodeRef for the user - NodeRef assignee = this.personService.getPerson(userName); - - // create a workflow store layered over the users store - String workflowStoreName = sandboxFactory.createUserWorkflowSandbox(storeName, userStore); - - // create a workflow package with all the expired items - NodeRef workflowPackage = setupWorkflowPackage(workflowStoreName, expiredContent); - - // create the workflow parameters map - Map params = new HashMap(5); - params.put(WorkflowModel.ASSOC_PACKAGE, workflowPackage); - params.put(WorkflowModel.ASSOC_ASSIGNEE, assignee); - params.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, workflowTitle); - - // transition the workflow to send it to the users inbox - this.workflowService.updateTask(startTask.id, params, null, null); - this.workflowService.endTask(startTask.id, null); - - // remember the root path of the workflow sandbox so we can inform - // the virtualisation server later - this.workflowStores.add(workflowStoreName + ":/" + - JNDIConstants.DIR_DEFAULT_WWW + "/" + - JNDIConstants.DIR_DEFAULT_APPBASE + "/ROOT"); - - if (logger.isDebugEnabled()) - logger.debug("Started '" + this.workflowName + "' workflow for user '" + - userName + "' in store '" + storeName + "'"); - } - } - } - } - - /** - * Sets up a workflow package from the given main workflow store and applies - * the list of paths as modified items within the main workflow store. - * - * @param workflowStoreName The main workflow store to setup - * @param expiredContent The expired content - * @return The NodeRef representing the workflow package - */ - private NodeRef setupWorkflowPackage(String workflowStoreName, List expiredContent) - { - // create package paths (layered to user sandbox area as target) - String packagesPath = workflowStoreName + ":/" + JNDIConstants.DIR_DEFAULT_WWW; - - for (final String srcPath : expiredContent) - { - final Matcher m = STORE_RELATIVE_PATH_PATTERN.matcher(srcPath); - String relPath = m.matches() && m.group(1).length() != 0 ? m.group(1) : null; - String pathInWorkflowStore = workflowStoreName + ":" + relPath; - - // call forceCopy to make sure the path appears modified in the workflow - // sandbox, if the item is already modified or deleted this call has no effect. - this.avmLockingAwareService.forceCopy(pathInWorkflowStore); - } - - // convert package to workflow package - AVMNodeDescriptor packageDesc = avmService.lookup(-1, packagesPath); - NodeRef packageNodeRef = workflowService.createPackage( - AVMNodeConverter.ToNodeRef(-1, packageDesc.getPath())); - this.nodeService.setProperty(packageNodeRef, WorkflowModel.PROP_IS_SYSTEM_PACKAGE, true); - - return packageNodeRef; - } -} diff --git a/source/java/org/alfresco/repo/avm/AVMInterpreter.java b/source/java/org/alfresco/repo/avm/AVMInterpreter.java deleted file mode 100644 index 0b274e091f..0000000000 --- a/source/java/org/alfresco/repo/avm/AVMInterpreter.java +++ /dev/null @@ -1,970 +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 . - */ - -package org.alfresco.repo.avm; - -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Pattern; - -import org.alfresco.repo.avm.util.BulkLoader; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMNotFoundException; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.avm.AVMStoreDescriptor; -import org.alfresco.service.cmr.avm.VersionDescriptor; -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.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.QName; -import org.alfresco.wcm.util.WCMUtil; -import org.springframework.context.support.FileSystemXmlApplicationContext; -import org.springframework.extensions.surf.util.ISO8601DateFormat; - -/** - * An interactive console for the AVM repository. - * - * @author britt - * @author Gavin Cornwell - * @author janv - */ -public class AVMInterpreter -{ - private static final Pattern collectionPattern = Pattern.compile("^\\[(.*)\\]$"); - private static final Pattern nodeRefPattern = Pattern.compile("^\\w+://\\w+\\w+$"); - private static final Pattern integerPattern = Pattern.compile("^\\d+$"); - private static final Pattern dateTimePattern = Pattern.compile("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$"); - - /** - * The service interface. - */ - private AVMService fService; - - /** - * The sync service. - */ - private AVMSyncService fSyncService; - - /** - * The locking service. - */ - private AVMLockingService fLockingService; - - /** - * The permission service. - */ - private PermissionService fPermissionService; - - /** - * The reader for interaction. - */ - private BufferedReader fIn; - - /** - * The Bulk Loader. - */ - private BulkLoader fLoader; - - /** - * Main entry point. - * Syntax: AVMInteractiveConsole storage (new|old). - */ - public static void main(String[] args) - { - FileSystemXmlApplicationContext context = - new FileSystemXmlApplicationContext("config/alfresco/application-context.xml"); - AVMInterpreter console = new AVMInterpreter(); - console.setAvmService((AVMService)context.getBean("AVMService")); - console.setAvmSyncService((AVMSyncService)context.getBean("AVMSyncService")); - console.setAvmLockingService((AVMLockingService)context.getBean("AVMLockingService")); - console.setPermissionService((PermissionService)context.getBean("PermissionService")); - BulkLoader loader = new BulkLoader(); - loader.setAvmService((AVMService)context.getBean("AVMService")); - console.setBulkLoader(loader); - console.rep(); - context.close(); - } - - /** - * Make up a new console. - */ - public AVMInterpreter() - { - fIn = new BufferedReader(new InputStreamReader(System.in)); - } - - /** - * Set the AVMService. - * @param service The AVMService instance. - */ - public void setAvmService(AVMService service) - { - fService = service; - } - - /** - * Set the AVM sync service. - * @param syncService - */ - public void setAvmSyncService(AVMSyncService syncService) - { - fSyncService = syncService; - } - - /** - * Set the AVM locking service. - * @param lockService - */ - public void setAvmLockingService(AVMLockingService lockService) - { - fLockingService = lockService; - } - - /** - * Set the PermissionService. - * @param service The PermissionService instance. - */ - public void setPermissionService(PermissionService service) - { - fPermissionService = service; - } - - /** - * Set the bulk loader. - * @param loader - */ - public void setBulkLoader(BulkLoader loader) - { - fLoader = loader; - } - - /** - * A Read-Eval-Print loop. - */ - public void rep() - { - while (true) - { - System.out.print("> "); - try - { - String line = fIn.readLine(); - if (line.equals("exit")) - { - return; - } - System.out.println(interpretCommand(line, fIn)); - } - catch (IOException ie) - { - ie.printStackTrace(System.err); - System.exit(2); - } - } - } - - /** - * Interpret a single command using the BufferedReader passed in for any data needed. - * @param line The unparsed command - * @param in A Reader to be used for commands that need input data. - * @return The textual output of the command. - */ - public String interpretCommand(String line, BufferedReader in) - { - String[] command = line.split(",\\s+"); - if (command.length == 0) - { - command = new String[1]; - command[0] = line; - } - try - { - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - PrintStream out = new PrintStream(bout); - if (command[0].equals("ls")) - { - if (command.length < 2) - { - return "Syntax Error."; - } - int version = (command.length == 2) ? -1 : Integer.parseInt(command[2]); - AVMNodeDescriptor desc = fService.lookup(version, command[1]); - if (desc == null) - { - return "Not Found."; - } - Map listing = - fService.getDirectoryListing(desc, true); - for (String name : listing.keySet()) - { - out.println(name + " " + listing.get(name)); - } - } - else if (command[0].equals("lsr")) - { - if (command.length < 2) - { - return "Syntax Error."; - } - int version = (command.length == 2) ? -1 : Integer.parseInt(command[2]); - AVMNodeDescriptor desc = fService.lookup(version, command[1]); - recursiveList(out, desc, 0); - } - else if (command[0].equals("lsrep")) - { - List repos = fService.getStores(); - for (AVMStoreDescriptor repo : repos) - { - out.println(repo); - } - } - else if (command[0].equals("lsver")) - { - if ((command.length < 2) || (command.length > 4)) - { - return "Syntax Error."; - } - - List listing = null; - String storeName = command[1]; - if (command.length == 2) - { - listing = fService.getStoreVersions(storeName); - } - else - { - Date fromDate = ISO8601DateFormat.parse(command[2]); - Date toDate = new Date(); - if (command.length == 4) - { - toDate = ISO8601DateFormat.parse(command[3]); - } - listing = fService.getStoreVersions(storeName, fromDate, toDate); - } - - for (VersionDescriptor desc : listing) - { - out.println(desc); - } - } - else if (command[0].equals("mkrep")) - { - if (command.length != 2) - { - return "Syntax Error."; - } - fService.createStore(command[1]); - } - else if (command[0].equals("load")) - { - if (command.length != 3) - { - return "Syntax Error."; - } - fLoader.recursiveLoad(command[1], command[2]); - } - else if (command[0].equals("mkdir")) - { - if (command.length != 3) - { - return "Syntax Error."; - } - fService.createDirectory(command[1], command[2]); - } - else if (command[0].equals("mkbr")) - { - if (command.length != 5) - { - return "Syntax Error."; - } - fService.createBranch(Integer.parseInt(command[4]), command[1], command[2], command[3]); - } - else if (command[0].equals("mkldir")) - { - if (command.length != 4) - { - return "Syntax Error."; - } - fService.createLayeredDirectory(command[1], command[2], command[3]); - } - else if (command[0].equals("setopacity")) - { - if (command.length != 3) - { - return "Syntax Error."; - } - boolean isOpaque = new Boolean(command[2]); - fService.setOpacity(command[1], isOpaque); - } - else if (command[0].equals("rename")) - { - if (command.length != 5) - { - return "Syntax Error."; - } - fService.rename(command[1], command[2], command[3], command[4]); - } - else if (command[0].equals("cp")) - { - if (command.length != 5) - { - return "Syntax Error."; - } - InputStream fin = fService.getFileInputStream(Integer.parseInt(command[2]), command[1]); - OutputStream fout = fService.createFile(command[3], command[4]); - byte [] buff = new byte[8192]; - int read; - while ((read = fin.read(buff)) != -1) - { - fout.write(buff, 0, read); - } - fin.close(); - fout.close(); - } - else if (command[0].equals("retarget")) - { - if (command.length != 3) - { - return "Syntax Error."; - } - fService.retargetLayeredDirectory(command[1], command[2]); - } - else if (command[0].equals("mkprimary")) - { - if (command.length != 2) - { - return "Syntax Error."; - } - fService.makePrimary(command[1]); - } - else if (command[0].equals("mklfile")) - { - if (command.length != 4) - { - return "Syntax Error."; - } - fService.createLayeredFile(command[1], command[2], command[3]); - } - else if (command[0].equals("snap")) - { - if ((command.length < 2) || (command.length > 4)) - { - return "Syntax Error."; - } - - String tag = (command.length > 2) ? command[2] : null; - String description = (command.length > 3) ? command[3] : null; - - fService.createSnapshot(command[1], tag, description); - } - else if (command[0].equals("cat")) - { - if (command.length < 2) - { - return "Syntax Error."; - } - int version = (command.length == 2) ? -1 : Integer.parseInt(command[2]); - BufferedReader reader = - new BufferedReader( - new InputStreamReader(fService.getFileInputStream(version, command[1]))); - String l; - while ((l = reader.readLine()) != null) - { - out.println(l); - } - reader.close(); - } - else if (command[0].equals("rm")) - { - if (command.length != 3) - { - return "Syntax Error."; - } - fService.removeNode(command[1], command[2]); - } - else if (command[0].equals("rmrep")) - { - if (command.length != 2) - { - return "Syntax Error."; - } - fService.purgeStore(command[1]); - } - else if (command[0].equals("rmver")) - { - if (command.length != 3) - { - return "Syntax Error."; - } - - String storeName = command[1]; - int ver =Integer.parseInt(command[2]); - String wpStoreId = WCMUtil.getWebProject(fService, storeName); - if ((wpStoreId != null) && (ver <= 2)) - { - return "WCM store - cannot delete versions 0-2"; - } - fService.purgeVersion(ver, storeName); - } - else if (command[0].equals("rmvers")) - { - if (command.length != 4) - { - return "Syntax Error."; - } - String storeName = command[1]; - String wpStoreId = WCMUtil.getWebProject(fService, storeName); - - Date fromDate = ISO8601DateFormat.parse(command[2]); - Date toDate = ISO8601DateFormat.parse(command[3]); - - List listing = fService.getStoreVersions(storeName, fromDate, toDate); - for (VersionDescriptor desc : listing) - { - int ver = desc.getVersionID(); - if ((wpStoreId != null) && (ver <= 2)) - { - return "WCM store - cannot delete versions 0-2"; - } - fService.purgeVersion(ver, storeName); - } - } - else if (command[0].equals("write")) - { - if (command.length != 2) - { - return "Syntax Error."; - } - PrintStream ps = - new PrintStream(fService.getFileOutputStream(command[1])); - String l; - while (!(l = in.readLine()).equals("")) - { - ps.println(l); - } - ps.close(); - } - else if (command[0].equals("create")) - { - if (command.length != 3) - { - return "Syntax Error."; - } - PrintStream ps = - new PrintStream(fService.createFile(command[1], command[2])); - String l; - while (!(l = in.readLine()).equals("")) - { - ps.println(l); - } - ps.close(); - } - else if (command[0].equals("stat")) - { - if (command.length < 2) - { - return "Syntax Error."; - } - int version = (command.length == 2) ? -1 : Integer.parseInt(command[2]); - AVMNodeDescriptor desc = fService.lookup(version, command[1]); - out.println(desc); - out.println("Version: " + desc.getVersionID()); - out.println("Owner: " + desc.getOwner()); - out.println("Mod Time: " + new Date(desc.getModDate())); - } - else if (command[0].equals("getnodeproperties")) - { - if (command.length < 2) - { - return "Syntax Error."; - } - int version = (command.length == 2) ? -1 : Integer.parseInt(command[2]); - final Map properties = fService.getNodeProperties(version, command[1]); - for (final Map.Entry p : properties.entrySet()) - { - out.println(p.getKey() + ": " + p.getValue()); - } - } - else if (command[0].equals("setnodepermission")) - { - if (command.length != 4) - { - return "Syntax Error."; - } - - fPermissionService.setPermission( - AVMNodeConverter.ToNodeRef(-1, command[1]), command[2], command[3], true); - } - else if (command[0].equals("clearnodepermission")) - { - if (command.length != 3) - { - return "Syntax Error."; - } - - fPermissionService.clearPermission( - AVMNodeConverter.ToNodeRef(-1, command[1]), command[2]); - } - else if (command[0].equals("descnode")) - { - if (command.length < 2) - { - return "Syntax Error."; - } - - String path = command[1]; - int version = (command.length == 2) ? -1 : Integer.parseInt(command[2]); - AVMNodeDescriptor nodeDesc = fService.lookup(version, path); - if (nodeDesc == null) - { - return "Path Not Found."; - } - - out.println(nodeDesc.toString()); - out.println("isDirectory: " + nodeDesc.isDirectory()); - out.println("isFile: " + nodeDesc.isFile()); - out.println("isPrimary: " + nodeDesc.isPrimary()); - out.println("isOpaque: " + nodeDesc.getOpacity()); - out.println("creator: " + nodeDesc.getCreator()); - out.println("owner: " + nodeDesc.getOwner()); - out.println("lastModifier: " + nodeDesc.getLastModifier()); - out.println("created: " + new Date(nodeDesc.getCreateDate())); - out.println("modified: " + new Date(nodeDesc.getModDate())); - out.println("lastAccess: " + new Date(nodeDesc.getAccessDate())); - - // get lock information - String lockPath = path.substring(path.indexOf("/")); - String store = path.substring(0, path.indexOf(":")); - String mainStore = store; - if (store.indexOf("--") != -1) - { - mainStore = store.substring(0, store.indexOf("--")); - } - - try - { - String lockOwner = fLockingService.getLockOwner(mainStore, lockPath); - if (lockOwner != null) - { - out.println("lock: " + lockOwner); - } - else - { - out.println("No locks found"); - } - } - catch (AVMNotFoundException avmerr) - { - out.println("No locks found"); - } - } - else if (command[0].equals("deletenodeproperty")) - { - if (command.length != 3) - { - return "Syntax Error."; - } - - fService.deleteNodeProperty(command[1], QName.createQName(command[2])); - out.println("deleted property " + command[2] + " of " + command[1]); - } - else if (command[0].equals("history")) - { - if (command.length != 4) - { - return "Syntax Error."; - } - AVMNodeDescriptor desc = fService.lookup(Integer.parseInt(command[2]), command[1]); - List history = fService.getHistory(desc, Integer.parseInt(command[3])); - for (AVMNodeDescriptor node : history) - { - out.println(node); - out.println("Version: " + node.getVersionID()); - out.println("Owner: " + node.getOwner()); - out.println("Mod Time: " + new Date(node.getModDate())); - } - } - /* - else if (command[0].equals("catver")) - { - if (command.length != 4) - { - return "Syntax Error."; - } - AVMNodeDescriptor desc = fService.lookup(Integer.parseInt(command[2]), command[1]); - List history = fService.getHistory(desc, Integer.parseInt(command[3])); - if (history.size() == 0) - { - return "No History."; - } - BufferedReader reader = - new BufferedReader( - new InputStreamReader( - fService.getFileInputStream(history.get(history.size() - 1)))); - String l; - while ((l = reader.readLine()) != null) - { - out.println(l); - } - reader.close(); - } - */ - else if (command[0].equals("ca")) - { - if (command.length != 5) - { - return "Syntax Error."; - } - AVMNodeDescriptor left = fService.lookup(Integer.parseInt(command[2]), command[1]); - AVMNodeDescriptor right = fService.lookup(Integer.parseInt(command[4]), command[3]); - AVMNodeDescriptor ca = fService.getCommonAncestor(left, right); - out.println(ca); - } - else if (command[0].equals("statstore")) - { - if (command.length != 2) - { - return "Syntax Error."; - } - AVMStoreDescriptor desc = fService.getStore(command[1]); - if (desc == null) - { - return "Not Found."; - } - out.println(desc); - Map props = - fService.getStoreProperties(command[1]); - for (QName name : props.keySet()) - { - out.println(name + ": " + props.get(name)); - } - } - else if (command[0].equals("compare")) - { - if (command.length != 5) - { - return "Syntax Error."; - } - List diffs = fSyncService.compare(Integer.parseInt(command[2]), - command[1], - Integer.parseInt(command[4]), - command[3], - null); - for (AVMDifference diff : diffs) - { - out.println(diff); - } - } - else if (command[0].equals("update")) - { - if (command.length != 4) - { - return "Syntax Error."; - } - AVMDifference diff = new AVMDifference(Integer.parseInt(command[2]), command[1], - -1, command[3], AVMDifference.NEWER); - List diffs = new ArrayList(); - diffs.add(diff); - fSyncService.update(diffs, null, false, false, false, false, null, null); - } - else if (command[0].equals("resetLayer")) - { - if (command.length != 2) - { - return "Syntax Error."; - } - fSyncService.resetLayer(command[1]); - } - else if (command[0].equals("flatten")) - { - if (command.length != 3) - { - return "Syntax Error."; - } - fSyncService.flatten(command[1], command[2]); - } - else if (command[0].equals("getnodeaspects")) - { - if (command.length != 3) - { - return "Syntax Error."; - } - - final Set aspects = fService.getAspects(Integer.parseInt(command[2]), command[1]); - for (final QName qn : aspects) - { - out.println(qn.toString()); - } - } - else if (command[0].equals("addnodeaspect")) - { - if (command.length != 3) - { - return "Syntax Error."; - } - - fService.addAspect(command[1], QName.createQName(command[2])); - } - else if (command[0].equals("deletenodeaspect")) - { - if (command.length != 3) - { - return "Syntax Error."; - } - - fService.removeAspect(command[1], QName.createQName(command[2])); - } - else if (command[0].equals("setnodeproperty")) - { - if (command.length < 4) - { - return "Syntax Error."; - } - - QName valueQName = QName.createQName(command[2]); - - String propertyValue = ""; - - // If multiple values are specified then concatenate the values - if (command.length > 4) - { - StringBuffer sb = new StringBuffer(); - for (int i=3; i 4) - { - StringBuffer sb = new StringBuffer(); - for (int i=3; i listing = fService.getDirectoryListing(dir, true); - for (String name : listing.keySet()) - { - AVMNodeDescriptor child = listing.get(name); - for (int i = 0; i < indent; i++) - { - out.print(' '); - } - out.println(name + " " + child); - if (child.isDirectory()) - { - recursiveList(out, child, indent + 2); - } - } - } - - private static Serializable convertValueFromSring(String sValue) - { - Serializable retValue = ""; - - CharSequence seq = sValue.subSequence(0, sValue.length()); - - if (collectionPattern.matcher(seq).matches()) - { - String[] elements = getCSVArray(sValue.substring(1, sValue.length()-1)); - - // Should this be an ArrayList or a HashSet? - Collection propValues = new HashSet(elements.length); - for (int i=0; i. - */ -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.avm.util.AVMUtil; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.service.cmr.avm.AVMExistsException; -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.avm.locking.AVMLockingException; -import org.alfresco.service.cmr.avm.locking.AVMLockingService; -import org.alfresco.service.cmr.avm.locking.AVMLockingService.LockState; -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.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; -import org.alfresco.wcm.util.WCMUtil; -import org.alfresco.wcm.webproject.WebProjectService; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * An AVMLockingService aware implementation of AVMService. - * @author britt - */ -public class AVMLockingAwareService implements AVMService, ApplicationContextAware -{ - public static final String STORE_SEPARATOR = "--"; - - public static final String STORE_WORKFLOW = "workflow"; - - public static final String STORE_PREVIEW = "preview"; - - private AVMService fService; - - private AVMLockingService fLockingService; - - private PermissionService permissionService; - - private ApplicationContext fContext; - - private WebProjectService wpService; - - public AVMLockingAwareService() - { - } - - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException - { - fContext = applicationContext; - } - - public void init() - { - fService = (AVMService)fContext.getBean("avmService"); - fLockingService = (AVMLockingService)fContext.getBean("avmLockingService"); - permissionService = (PermissionService) fContext.getBean("PermissionService"); - wpService = (WebProjectService) fContext.getBean("WebProjectService"); - } - - public void addAspect(String path, QName aspectName) - { - grabLock(path); - fService.addAspect(path, aspectName); - } - - public void copy(int srcVersion, String srcPath, String dstPath, String name) - { - fService.copy(srcVersion, srcPath, dstPath, name); - } - - public void createBranch(int version, String srcPath, String dstPath, - String name) - { - fService.createBranch(version, srcPath, dstPath, name); - } - - public void createDirectory(String path, String name) - { - fService.createDirectory(path, name); - } - - public OutputStream createFile(String path, String name) - { - grabLock(AVMUtil.extendAVMPath(path, name)); - return fService.createFile(path, name); - } - - public void createFile(String path, String name, InputStream in) - { - grabLock(AVMUtil.extendAVMPath(path, name)); - fService.createFile(path, name, in); - } - - public void createLayeredDirectory(String targetPath, String parent, - String name) - { - fService.createLayeredDirectory(targetPath, parent, name); - } - - public void createLayeredFile(String targetPath, String parent, String name) - { - grabLock(AVMUtil.extendAVMPath(parent, name)); - fService.createLayeredFile(targetPath, parent, name); - } - - public Map createSnapshot(String store, String tag, String description) - { - return fService.createSnapshot(store, tag, description); - } - - public void createStore(String name) - { - fService.createStore(name); - } - - public void createStore(String name, Map props) - { - fService.createStore(name, props); - } - - public void deleteNodeProperties(String path) - { - grabLock(path); - fService.deleteNodeProperties(path); - } - - public void deleteNodeProperty(String path, QName name) - { - grabLock(path); - fService.deleteNodeProperty(path, name); - } - - public void deleteStoreProperty(String store, QName name) - { - fService.deleteStoreProperty(store, name); - } - - public AVMNodeDescriptor forceCopy(String path) - { - grabLock(path); - return fService.forceCopy(path); - } - - public Pair getAPath(AVMNodeDescriptor desc) - { - return fService.getAPath(desc); - } - - public List getPathsInStoreVersion(AVMNodeDescriptor desc, String store, int version) - { - return fService.getPathsInStoreVersion(desc, store, version); - } - - public Set getAspects(int version, String path) - { - return fService.getAspects(version, path); - } - - public Set getAspects(AVMNodeDescriptor desc) - { - return fService.getAspects(desc); - } - - public AVMNodeDescriptor getCommonAncestor(AVMNodeDescriptor left, - AVMNodeDescriptor right) - { - return fService.getCommonAncestor(left, right); - } - - public ContentData getContentDataForRead(int version, String path) - { - return fService.getContentDataForRead(version, path); - } - - public ContentData getContentDataForRead(AVMNodeDescriptor desc) - { - return fService.getContentDataForRead(desc); - } - - public ContentData getContentDataForWrite(String path) - { - grabLock(path); - return fService.getContentDataForWrite(path); - } - - public ContentReader getContentReader(int version, String path) - { - return fService.getContentReader(version, path); - } - - public ContentWriter getContentWriter(String path, boolean update) - { - grabLock(path); - return fService.getContentWriter(path, update); - } - - public List getDeleted(int version, String path) - { - return fService.getDeleted(version, path); - } - - public SortedMap getDirectoryListing(int version, String path) - { - return fService.getDirectoryListing(version, path); - } - - public SortedMap getDirectoryListing(int version, String path, boolean includeDeleted) - { - return fService.getDirectoryListing(version, path, includeDeleted); - } - - public SortedMap getDirectoryListing(AVMNodeDescriptor dir) - { - return fService.getDirectoryListing(dir); - } - - public SortedMap getDirectoryListing(AVMNodeDescriptor dir, String childNamePattern) - { - return fService.getDirectoryListing(dir, childNamePattern); - } - - public SortedMap getDirectoryListing(AVMNodeDescriptor dir, boolean includeDeleted) - { - return fService.getDirectoryListing(dir, includeDeleted); - } - - public AVMNodeDescriptor[] getDirectoryListingArray(int version, String path, boolean includeDeleted) - { - return fService.getDirectoryListingArray(version, path, includeDeleted); - } - - public AVMNodeDescriptor[] getDirectoryListingArray(AVMNodeDescriptor dir, boolean includeDeleted) - { - return fService.getDirectoryListingArray(dir, includeDeleted); - } - - public SortedMap getDirectoryListingDirect(int version, String path) - { - return fService.getDirectoryListingDirect(version, path); - } - - public SortedMap getDirectoryListingDirect(int version, String path, boolean includeDeleted) - { - return fService.getDirectoryListingDirect(version, path, includeDeleted); - } - - public SortedMap getDirectoryListingDirect( - AVMNodeDescriptor dir, boolean includeDeleted) - { - return fService.getDirectoryListingDirect(dir, includeDeleted); - } - - public InputStream getFileInputStream(int version, String path) - { - return fService.getFileInputStream(version, path); - } - - public InputStream getFileInputStream(AVMNodeDescriptor desc) - { - return fService.getFileInputStream(desc); - } - - public OutputStream getFileOutputStream(String path) - { - grabLock(path); - return fService.getFileOutputStream(path); - } - - public List> getHeadPaths(AVMNodeDescriptor desc) - { - return fService.getHeadPaths(desc); - } - - public List getHistory(AVMNodeDescriptor desc, int count) - { - return fService.getHistory(desc, count); - } - - public String getIndirectionPath(int version, String path) - { - return fService.getIndirectionPath(version, path); - } - - public int getLatestSnapshotID(String storeName) - { - return fService.getLatestSnapshotID(storeName); - } - - public LayeringDescriptor getLayeringInfo(int version, String path) - { - return fService.getLayeringInfo(version, path); - } - - public int getNextVersionID(String storeName) - { - return fService.getNextVersionID(storeName); - } - - public Map getNodeProperties(int version, String path) - { - return fService.getNodeProperties(version, path); - } - - public Map getNodeProperties(AVMNodeDescriptor desc) - { - return fService.getNodeProperties(desc); - } - - public PropertyValue getNodeProperty(int version, String path, QName name) - { - return fService.getNodeProperty(version, path, name); - } - - public List> getPaths(AVMNodeDescriptor desc) - { - return fService.getPaths(desc); - } - - public List> getPathsInStoreHead( - AVMNodeDescriptor desc, String store) - { - return fService.getPathsInStoreHead(desc, store); - } - - public AVMStoreDescriptor getStore(String name) - { - return fService.getStore(name); - } - - public Map getStoreProperties(String store) - { - return fService.getStoreProperties(store); - } - - public PropertyValue getStoreProperty(String store, QName name) - { - return fService.getStoreProperty(store, name); - } - - public AVMNodeDescriptor getStoreRoot(int version, String name) - { - return fService.getStoreRoot(version, name); - } - - public List getStoreVersions(String name) - { - return fService.getStoreVersions(name); - } - - public List getStoreVersions(String name, Date from, Date to) - { - return fService.getStoreVersions(name, from, to); - } - - public List getStores() - { - return fService.getStores(); - } - - public AVMStoreDescriptor getSystemStore() - { - return fService.getSystemStore(); - } - - public boolean hasAspect(int version, String path, QName aspectName) - { - return fService.hasAspect(version, path, aspectName); - } - - public void link(String parentPath, String name, AVMNodeDescriptor toLink) - { - // TODO Does this need a lock? I don't think so, but revisit. - fService.link(parentPath, name, toLink); - } - - public void updateLink(String parentPath, String name, AVMNodeDescriptor toLink) - { - // TODO Does this need a lock? I don't think so, but revisit. - fService.updateLink(parentPath, name, toLink); - } - - public AVMNodeDescriptor lookup(int version, String path) - { - return fService.lookup(version, path); - } - - public AVMNodeDescriptor lookup(int version, String path, - boolean includeDeleted) - { - return fService.lookup(version, path, includeDeleted); - } - - public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name) - { - return fService.lookup(dir, name); - } - - public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name, - boolean includeDeleted) - { - return fService.lookup(dir, name, includeDeleted); - } - - public void makePrimary(String path) - { - fService.makePrimary(path); - } - - public void makeTransparent(String dirPath, String name) - { - fService.makeTransparent(dirPath, name); - } - - public void purgeStore(String name) - { - fService.purgeStore(name); - - String webProject = WCMUtil.getWebProject(fService, name); - if (webProject != null) - { - fLockingService.removeLocks(name); - } - } - - public void purgeVersion(int version, String name) - { - fService.purgeVersion(version, name); - } - - public Map queryStorePropertyKey(String store, QName keyPattern) - { - return fService.queryStorePropertyKey(store, keyPattern); - } - - public Map> queryStoresPropertyKeys(QName keyPattern) - { - return fService.queryStoresPropertyKeys(keyPattern); - } - - public void removeAspect(String path, QName aspectName) - { - grabLock(path); - fService.removeAspect(path, aspectName); - } - - public void removeNode(String parent, String name) - { - String path = AVMUtil.extendAVMPath(parent, name); - grabLock(path); - fService.removeNode(parent, name); - String[] storePath = AVMUtil.splitPath(parent); - String avmStore = storePath[0]; - fService.createSnapshot(avmStore, null, "Removed "+path); - String webProject = WCMUtil.getWebProject(fService, avmStore); - if (webProject != null) - { - Map lockDataToMatch = Collections.singletonMap(WCMUtil.LOCK_KEY_STORE_NAME, avmStore); - String relPath = AVMUtil.extendAVMPath(storePath[1], name); // store-relative path, eg. /www/avm_webapps/ROOT/my.txt - fLockingService.removeLocks(webProject, relPath, lockDataToMatch); - } - } - - public void removeNode(String path) - { - grabLock(path); - fService.removeNode(path); - String[] storePath = AVMUtil.splitPath(path); - String avmStore = storePath[0]; - String relPath = storePath[1]; // store-relative path, eg. /www/avm_webapps/ROOT/my.txt - fService.createSnapshot(avmStore, null, "Removed "+path); - String webProject = WCMUtil.getWebProject(fService, avmStore); - if (webProject != null) - { - Map lockDataToMatch = Collections.singletonMap(WCMUtil.LOCK_KEY_STORE_NAME, avmStore); - fLockingService.removeLocks(webProject, relPath, lockDataToMatch); - } - } - - public void rename(String srcParent, String srcName, String dstParent, String dstName) - { - String srcPath = AVMUtil.extendAVMPath(srcParent, srcName); - String dstPath = AVMUtil.extendAVMPath(dstParent, dstName); - - AVMNodeDescriptor desc = fService.lookup(-1, srcPath, false); - if (! (desc != null && desc.isDirectory())) - { - grabLock(srcPath); - } - - fService.rename(srcParent, srcName, dstParent, dstName); - - if (! (desc != null && desc.isDirectory())) - { - String[] srcStorePath = AVMUtil.splitPath(srcPath); - String[] dstStorePath = AVMUtil.splitPath(dstPath); - - String srcWebProject = WCMUtil.getWebProject(fService, srcStorePath[0]); - String dstWebProject = WCMUtil.getWebProject(fService, dstStorePath[0]); - - if ((dstWebProject != null) && (dstWebProject.equals(srcWebProject))) - { - // Make sure we hold the lock already - grabLock(dstPath); - } - else - { - // Remove the old lock and take the new - fLockingService.removeLock(srcWebProject, srcStorePath[1]); - grabLock(dstPath); - } - } - } - - public void renameStore(String sourceName, String destName) - { - fService.renameStore(sourceName, destName); - } - - public void retargetLayeredDirectory(String path, String target) - { - // TODO This assumes that directories are not locked. - fService.retargetLayeredDirectory(path, target); - } - - public void revert(String path, AVMNodeDescriptor toRevertTo) - { - grabLock(path); - fService.revert(path, toRevertTo); - } - - public void setContentData(String path, ContentData data) - { - grabLock(path); - fService.setContentData(path, data); - } - - public void setEncoding(String path, String encoding) - { - grabLock(path); - fService.setEncoding(path, encoding); - } - - public void setGuid(String path, String guid) - { - grabLock(path); - fService.setGuid(path, guid); - } - - public void setMetaDataFrom(String path, AVMNodeDescriptor from) - { - grabLock(path); - fService.setMetaDataFrom(path, from); - } - - public void setMimeType(String path, String mimeType) - { - grabLock(path); - fService.setMimeType(path, mimeType); - } - - public void setNodeProperties(String path, - Map properties) - { - grabLock(path); - fService.setNodeProperties(path, properties); - } - - public void setNodeProperty(String path, QName name, PropertyValue value) - { - grabLock(path); - fService.setNodeProperty(path, name, value); - } - - public void setOpacity(String path, boolean opacity) - { - // TODO Assumes no directory locking. - fService.setOpacity(path, opacity); - } - - public void setStoreProperties(String store, Map props) - { - fService.setStoreProperties(store, props); - } - - public void setStoreProperty(String store, QName name, PropertyValue value) - { - fService.setStoreProperty(store, name, value); - } - - public void uncover(String dirPath, String name) - { - // TODO What about when this is a directory? - grabLock(AVMUtil.extendAVMPath(dirPath, name)); - fService.uncover(dirPath, name); - } - - public void createDirectory(String path, String name, List aspects, Map properties) - { - fService.createDirectory(path, name, aspects, properties); - } - - public void createFile(String path, String name, InputStream in, List aspects, Map properties) - { - grabLock(AVMUtil.extendAVMPath(path, name)); - fService.createFile(path, name, in, aspects, properties); - } - - private void grabLock(String path) - { - AVMNodeDescriptor desc = fService.lookup(-1, path, false); - if (desc != null && desc.isDirectory()) - { - return; - } - String[] storePath = AVMUtil.splitPath(path); - String avmStore = storePath[0]; - String webProject = WCMUtil.getWebProject(fService, storePath[0]); - if (webProject != null && webProject.equals(avmStore)) - { - // Don't do locking in staging. - return; - } - if (avmStore.indexOf(STORE_SEPARATOR + STORE_WORKFLOW) != -1) - { - //Allow lock in workflow store if user has "Write" permission - NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, path); - if (permissionService.hasPermission(nodeRef, PermissionService.WRITE) == AccessStatus.DENIED) - { - String errorMessage = I18NUtil.getMessage("avmlockservice.accessdenied", AuthenticationUtil.getFullyAuthenticatedUser()); - throw new AccessDeniedException(errorMessage); - } - } - else if (webProject != null) - { - String userName = AuthenticationUtil.getFullyAuthenticatedUser(); - LockState lockState = fLockingService.getLockState(webProject, storePath[1], userName); - String wpStoreId = WCMUtil.getWebProjectStoreId(webProject); - - // ALF-11440 PM 18-Dec-2011: - // 1. Managers may edit any unlocked file - it becomes locked. - // 2. Managers may edit any locked file in any sandbox in which it is locked - // but not in sandboxes where it is unlocked. - // ALF-8787 and ALF-12766 are consistent with 2. - // A Manager should only be able to create a file in a sandbox - // if it is NOT locked somewhere else. - switch (lockState) - { - case LOCK_NOT_OWNER: - String lockOwner = fLockingService.getLockOwner(webProject, storePath[1]); - if ((wpService.isContentManager(wpStoreId, userName)) && - (avmStore.equals(wpStoreId + STORE_SEPARATOR + lockOwner) || - avmStore.equals(wpStoreId + STORE_SEPARATOR + lockOwner - + STORE_SEPARATOR + STORE_PREVIEW))) - { - // Handle as if LOCK_OWNER - break; - } - throw new AVMLockingException("avmlockservice.locked", path, lockOwner); - case NO_LOCK: - Map lockAttributes = Collections.singletonMap(WCMUtil.LOCK_KEY_STORE_NAME, avmStore); - fLockingService.lock(webProject, storePath[1], userName, lockAttributes); - break; - case LOCK_OWNER: - // Nothing to do - break; - } - } - } - - public List getStoreVersionsTo(String name, int version) - { - return fService.getStoreVersionsTo(name, version); - } - - public List getStoreVersionsFrom(String name, int version) - { - return fService.getStoreVersionsFrom(name, version); - } - - public List getStoreVersionsBetween(String name, int from, int to) - { - return fService.getStoreVersionsBetween(name, from, to); - } - -} diff --git a/source/java/org/alfresco/repo/avm/AVMNodeConverter.java b/source/java/org/alfresco/repo/avm/AVMNodeConverter.java deleted file mode 100644 index c05d7e9489..0000000000 --- a/source/java/org/alfresco/repo/avm/AVMNodeConverter.java +++ /dev/null @@ -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 . */ - -package org.alfresco.repo.avm; - -import org.alfresco.repo.avm.util.AVMUtil; -import org.alfresco.service.cmr.avm.AVMException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.util.Pair; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Utility for going back and forth between the AVM world and - * the StoreRef, NodeRef world. - * @author britt - */ -public class AVMNodeConverter -{ - private static Log fgLogger = LogFactory.getLog(AVMNodeConverter.class); - - /** - * Get a NodeRef corresponding to the given path and version. - * @param version The version id. - * @param avmPath The AVM path. - * @return A NodeRef with AVM info stuffed inside. - */ - public static NodeRef ToNodeRef(int version, String avmPath) - { - String [] pathParts = AVMUtil.splitPath(avmPath); - while (pathParts[1].endsWith(AVMUtil.AVM_PATH_SEPARATOR) && pathParts[1].length() > 1) - { - pathParts[1] = pathParts[1].substring(0, pathParts[1].length() - 1); - } - StoreRef storeRef = ToStoreRef(pathParts[0]); - String translated = version + pathParts[1]; - translated = translated.replaceAll("/+", "|"); - return new NodeRef(storeRef, translated); - } - - /** - * Get a StoreRef that corresponds to a given AVMStore name. - * @param avmStore The name of the AVMStore. - * @return A working StoreRef. - */ - public static StoreRef ToStoreRef(String avmStore) - { - return new StoreRef(StoreRef.PROTOCOL_AVM, avmStore); - } - - /** - * Convert a NodeRef into a version, AVMPath pair. - * @param nodeRef The NodeRef to convert. - * @return An Integer, String array. - */ - public static Pair ToAVMVersionPath(NodeRef nodeRef) - { - StoreRef store = nodeRef.getStoreRef(); - String translated = nodeRef.getId(); - - if (translated.indexOf('|') != -1) - { - // we assume that this is the new style avm path - translated = translated.replace('|', AVMUtil.AVM_PATH_SEPARATOR_CHAR); - } - else - { - // this is the old style avm path - translated = translated.replace(';', AVMUtil.AVM_PATH_SEPARATOR_CHAR); - } - int off = translated.indexOf(AVMUtil.AVM_PATH_SEPARATOR_CHAR); - if (off == -1) - { - fgLogger.error(translated); - throw new AVMException("Bad Node Reference: " + nodeRef.getId()); - } - int version = Integer.parseInt(translated.substring(0, off)); - String path = translated.substring(off); - return new Pair(version, AVMUtil.buildAVMPath(store.getIdentifier(), path)); - } - - /** - * Extend an already valid AVM path by one more component. - * @param path The starting AVM path. - * @param name The name to add to it. - * @return The extended path. - */ - public static String ExtendAVMPath(String path, String name) - { - return AVMUtil.extendAVMPath(path, name); - } - - /** - * Split a path into its parent path and its base name. - * @param path The initial AVM path. - * @return An array of 2 Strings containing the parent path and the base - * name. - */ - public static String[] SplitBase(String path) - { - return AVMUtil.splitBase(path); - } - - /** - * Normalize an AVM path. - * @param path The incoming path. - * @return The normalized path. - * - * @deprecated see org.alfresco.repo.avm.util.AVMUtil.normalizePath - */ - public static String NormalizePath(String path) - { - return AVMUtil.normalizePath(path); - } -} diff --git a/source/java/org/alfresco/repo/avm/AVMNodeService.java b/source/java/org/alfresco/repo/avm/AVMNodeService.java deleted file mode 100644 index 1bc231e19b..0000000000 --- a/source/java/org/alfresco/repo/avm/AVMNodeService.java +++ /dev/null @@ -1,2090 +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 . */ - -package org.alfresco.repo.avm; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedMap; - -import org.alfresco.model.ContentModel; -import org.alfresco.model.WCMModel; -import org.alfresco.repo.avm.util.AVMUtil; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.node.AbstractNodeServiceImpl; -import org.alfresco.service.cmr.avm.AVMException; -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.avm.AVMService; -import org.alfresco.service.cmr.avm.AVMStoreDescriptor; -import org.alfresco.service.cmr.avm.AVMWrongTypeException; -import org.alfresco.service.cmr.dictionary.AspectDefinition; -import org.alfresco.service.cmr.dictionary.ClassDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryException; -import org.alfresco.service.cmr.dictionary.InvalidAspectException; -import org.alfresco.service.cmr.dictionary.InvalidTypeException; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.dictionary.TypeDefinition; -import org.alfresco.service.cmr.repository.AssociationExistsException; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.CyclicChildRelationshipException; -import org.alfresco.service.cmr.repository.InvalidChildAssociationRefException; -import org.alfresco.service.cmr.repository.InvalidNodeRefException; -import org.alfresco.service.cmr.repository.InvalidStoreRefException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.Path; -import org.alfresco.service.cmr.repository.StoreExistsException; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.repository.datatype.TypeConversionException; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.QNamePattern; -import org.alfresco.util.Pair; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * NodeService implementing facade over AVMService. - * @author britt - */ -public class AVMNodeService extends AbstractNodeServiceImpl implements NodeService -{ - private static Log logger = LogFactory.getLog(AVMNodeService.class); - - /** - * Flag for whether policy callbacks are made. - */ - private boolean fInvokePolicies = false; - - /** - * Reference to AVMService. - */ - private AVMService fAVMService; - - /** - * Set the AVMService. For Spring. - * @param service The AVMService instance. - */ - public void setAvmService(AVMService service) - { - fAVMService = service; - } - - /** - * Default constructor. - */ - public AVMNodeService() - { - } - - public void setInvokePolicies(boolean invoke) - { - fInvokePolicies = invoke; - } - - /** - * Helper method to convert the Serializable value into a full, - * persistable {@link PropertyValue}. - *

- * Where the property definition is null, the value will take on the - * {@link DataTypeDefinition#ANY generic ANY} value. - *

- * Where the property definition specifies a multi-valued property but the - * value provided is not a collection, the value will be wrapped in a collection. - * - * @param propertyDef the property dictionary definition, may be null - * @param value the value, which will be converted according to the definition - - * may be null - * @return Returns the persistable property value - */ - protected PropertyValue makePropertyValue(PropertyDefinition propertyDef, Serializable value) - { - // get property attributes - QName propertyTypeQName = null; - if (propertyDef == null) // property not recognised - { - // allow it for now - persisting excess properties can be useful sometimes - propertyTypeQName = DataTypeDefinition.ANY; - } - else - { - propertyTypeQName = propertyDef.getDataType().getName(); - // check that multi-valued properties are allowed - boolean isMultiValued = propertyDef.isMultiValued(); - if (isMultiValued && !(value instanceof Collection)) - { - if (value != null) - { - // put the value into a collection - // the implementation gives back a Serializable list - value = (Serializable) Collections.singletonList(value); - } - } - else if (!isMultiValued && (value instanceof Collection)) - { - // we only allow this case if the property type is ANY - if (!propertyTypeQName.equals(DataTypeDefinition.ANY)) - { - throw new DictionaryException( - "A single-valued property of this type may not be a collection: \n" + - " Property: " + propertyDef + "\n" + - " Type: " + propertyTypeQName + "\n" + - " Value: " + value); - } - } - } - try - { - PropertyValue propertyValue = new PropertyValue(propertyTypeQName, value); - // done - return propertyValue; - } - catch (TypeConversionException e) - { - throw new TypeConversionException( - "The property value is not compatible with the type defined for the property: \n" + - " property: " + (propertyDef == null ? "unknown" : propertyDef) + "\n" + - " value: " + value + "\n" + - " value type: " + value.getClass(), - e); - } - } - - /** - * Extracts the externally-visible property from the {@link PropertyValue propertyValue}. - * - * @param propertyDef the model property definition - may be null - * @param propertyValue the persisted property - * @return Returns the value of the property in the format dictated by the property - * definition, or null if the property value is null - */ - protected Serializable makeSerializableValue(PropertyDefinition propertyDef, PropertyValue propertyValue) - { - if (propertyValue == null) - { - return null; - } - // get property attributes - QName propertyTypeQName = null; - if (propertyDef == null) - { - // allow this for now - propertyTypeQName = DataTypeDefinition.ANY; - } - else - { - propertyTypeQName = propertyDef.getDataType().getName(); - } - try - { - Serializable value = propertyValue.getValue(propertyTypeQName); - // done - return value; - } - catch (TypeConversionException e) - { - throw new TypeConversionException( - "The property value is not compatible with the type defined for the property: \n" + - " property: " + (propertyDef == null ? "unknown" : propertyDef) + "\n" + - " property value: " + propertyValue, - e); - } - } - - /** - * Gets a list of all available node store references - * - * @return Returns a list of store references - */ - public List getStores() - { - /* Sparta: disable/remove WCM/AVM - // For AVM stores we fake up StoreRefs. - List stores = fAVMService.getStores(); - List result = new ArrayList(); - for (AVMStoreDescriptor desc : stores) - { - String name = desc.getName(); - result.add(new StoreRef(StoreRef.PROTOCOL_AVM, name)); - } - return result; - */ - return Collections.emptyList(); - } - - /** - * Create a new AVM store. - * @param protocol the implementation protocol - * @param identifier the protocol-specific identifier - * @return Returns a reference to the store - * @throws StoreExistsException - */ - public StoreRef createStore(String protocol, String identifier) throws StoreExistsException - { - StoreRef result = new StoreRef(StoreRef.PROTOCOL_AVM, identifier); - // invokeBeforeCreateStore(ContentModel.TYPE_STOREROOT, result); - try - { - fAVMService.createStore(identifier); - NodeRef rootRef = getRootNode(result); - addAspect(rootRef, ContentModel.ASPECT_ROOT, - Collections.emptyMap()); - // invokeOnCreateStore(rootRef); - return result; - } - catch (AVMExistsException e) - { - throw new StoreExistsException(result, e); - } - } - - /** - * @throws UnsupportedOperationException Always - */ - public void deleteStore(StoreRef storeRef) throws InvalidStoreRefException - { - throw new UnsupportedOperationException(); - } - - /** - * Does the indicated store exist? - * @param storeRef a reference to the store to look for - * @return Returns true if the store exists, otherwise false - */ - public boolean exists(StoreRef storeRef) - { - return fAVMService.getStore(storeRef.getIdentifier()) != null; - } - - /** - * @param nodeRef a reference to the node to look for - * @return Returns true if the node exists, otherwise false - */ - public boolean exists(NodeRef nodeRef) - { - Pair avmInfo = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = avmInfo.getFirst(); - String avmPath = avmInfo.getSecond(); - return fAVMService.lookup(version, avmPath) != null; - } - - /** - * Gets the ID of the last transaction that caused the node to change. This includes - * deletions, so it is possible that the node being referenced no longer exists. - * If the node never existed, then null is returned. - * - * @param nodeRef a reference to a current or previously existing node - * @return Returns the status of the node, or null if the node never existed - */ - public NodeRef.Status getNodeStatus(NodeRef nodeRef) - { - // TODO Need to find out if this is important and if so - // need to capture Transaction IDs. - return new NodeRef.Status(null, nodeRef, "Unknown", null, !exists(nodeRef)); - } - - /** - * @throws UnsupportedOperationException always - */ - @Override - public NodeRef getNodeRef(Long nodeId) - { - throw new UnsupportedOperationException(); - } - - /** - * @param storeRef a reference to an existing store - * @return Returns a reference to the root node of the store - * @throws InvalidStoreRefException if the store could not be found - */ - public NodeRef getRootNode(StoreRef storeRef) throws InvalidStoreRefException - { - String storeName = storeRef.getIdentifier(); - if (fAVMService.getStore(storeName) != null) - { - return AVMNodeConverter.ToNodeRef(-1, storeName + ":/"); - } - else - { - throw new InvalidStoreRefException(storeName +":/" + " not found.", storeRef); - } - } - - public Set getAllRootNodes(StoreRef storeRef) - { - return Collections.singleton(getRootNode(storeRef)); - } - - /** - * @see #createNode(NodeRef, QName, QName, QName, Map) - */ - public ChildAssociationRef createNode( - NodeRef parentRef, - QName assocTypeQName, - QName assocQName, - QName nodeTypeQName) - throws InvalidNodeRefException, InvalidTypeException - { - return createNode(parentRef, - assocTypeQName, - assocQName, - nodeTypeQName, - new HashMap()); - } - - /** - * Creates a new, non-abstract, real node as a primary child of the given parent node. - * - * @param parentRef the parent node - * @param assocTypeQName the type of the association to create. This is used - * for verification against the data dictionary. - * @param assocQName the qualified name of the association - * @param nodeTypeQName a reference to the node type - * @param properties optional map of properties to keyed by their qualified names - * @return Returns a reference to the newly created child association - * @throws InvalidNodeRefException if the parent reference is invalid - * @throws InvalidTypeException if the node type reference is not recognised - * - * @see org.alfresco.service.cmr.dictionary.DictionaryService - */ - @SuppressWarnings("deprecation") - public ChildAssociationRef createNode( - NodeRef parentRef, - QName assocTypeQName, - QName assocQName, - QName nodeTypeQName, - Map properties) - throws InvalidNodeRefException, InvalidTypeException - { - // AVM stores only allow simple child associations. - if (!assocTypeQName.equals(ContentModel.ASSOC_CONTAINS)) - { - throw new InvalidTypeException(assocTypeQName); - } - String nodeName = assocQName.getLocalName(); - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef); - int version = avmVersionPath.getFirst(); - if (version >= 0) - { - throw new InvalidNodeRefException("Read only store.", parentRef); - } - String avmPath = avmVersionPath.getSecond(); - // Invoke policy behavior. - // invokeBeforeUpdateNode(parentRef); - // invokeBeforeCreateNode(parentRef, assocTypeQName, assocQName, nodeTypeQName); - // Look up the type definition in the dictionary. - TypeDefinition nodeTypeDef = dictionaryService.getType(nodeTypeQName); - // Do the creates for supported types, or error out. - try - { - if (nodeTypeQName.equals(WCMModel.TYPE_AVM_PLAIN_FOLDER) || - nodeTypeQName.equals(ContentModel.TYPE_FOLDER)) - { - fAVMService.createDirectory(avmPath, nodeName); - } - else if (nodeTypeQName.equals(WCMModel.TYPE_AVM_PLAIN_CONTENT) || - nodeTypeQName.equals(ContentModel.TYPE_CONTENT)) - { - OutputStream os = fAVMService.createFile(avmPath, nodeName); - try - { - if (os != null) { os.close(); } - } - catch (IOException ioe) - { - logger.warn("Failed to close output stream when creating file '"+AVMUtil.extendAVMPath(avmPath, nodeName)+"'"+ioe.getMessage()); - } - } - else if (nodeTypeQName.equals(WCMModel.TYPE_AVM_LAYERED_CONTENT)) - { - NodeRef indirection = (NodeRef)properties.get(WCMModel.PROP_AVM_FILE_INDIRECTION); - if (indirection == null) - { - throw new InvalidTypeException("No Indirection Property", nodeTypeQName); - } - Pair indVersionPath = AVMNodeConverter.ToAVMVersionPath(indirection); - fAVMService.createLayeredFile(indVersionPath.getSecond(), avmPath, nodeName); - } - else if (nodeTypeQName.equals(WCMModel.TYPE_AVM_LAYERED_FOLDER)) - { - NodeRef indirection = (NodeRef)properties.get(WCMModel.PROP_AVM_DIR_INDIRECTION); - if (indirection == null) - { - throw new InvalidTypeException("No Indirection Property.", nodeTypeQName); - } - Pair indVersionPath = AVMNodeConverter.ToAVMVersionPath(indirection); - fAVMService.createLayeredDirectory(indVersionPath.getSecond(), avmPath, nodeName); - } - else - { - throw new InvalidTypeException("Invalid node type for AVM.", nodeTypeQName); - } - properties.putAll(getDefaultProperties(nodeTypeDef)); - addDefaultAspects(nodeTypeDef, avmPath, properties); - } - catch (AVMNotFoundException e) - { - throw new InvalidNodeRefException(avmPath + " not found.", parentRef); - } - catch (AVMExistsException e) - { - throw new InvalidNodeRefException("Child " + nodeName + " exists", parentRef); - } - String newAVMPath = AVMNodeConverter.ExtendAVMPath(avmPath, nodeName); - NodeRef childRef = AVMNodeConverter.ToNodeRef(-1, newAVMPath); - properties.putAll(getDefaultProperties(nodeTypeDef)); - addDefaultAspects(nodeTypeDef, newAVMPath, properties); - Map props = new HashMap(); - for (Map.Entry entry : properties.entrySet()) - { - QName propertyQName = entry.getKey(); - if (isBuiltInProperty(propertyQName)) - { - continue; - } - Serializable value = entry.getValue(); - PropertyDefinition propertyDef = dictionaryService.getProperty(propertyQName); - PropertyValue propertyValue = makePropertyValue(propertyDef, value); - props.put(propertyQName, propertyValue); - } - fAVMService.setNodeProperties(newAVMPath, props); - ChildAssociationRef ref = - new ChildAssociationRef(assocTypeQName, - parentRef, - assocQName, - childRef, - true, - -1); -// invokeOnCreateNode(ref); -// invokeOnUpdateNode(parentRef); -// if (properties.size() != 0) -// { -// invokeOnUpdateProperties(childRef, new HashMap(), properties); -// } - return ref; - } - - /** - * Moves the primary location of the given node. - *

- * This involves changing the node's primary parent and possibly the name of the - * association referencing it. - *

- * If the new parent is in a different store from the original, then the entire - * node hierarchy is moved to the new store. Inter-store associations are not - * affected. - * - * @param nodeToMoveRef the node to move - * @param newParentRef the new parent of the moved node - * @param assocTypeQName the type of the association to create. This is used - * for verification against the data dictionary. - * @param assocQName the qualified name of the new child association - * @return Returns a reference to the newly created child association - * @throws InvalidNodeRefException if either the parent node or move node reference is invalid - * @throws CyclicChildRelationshipException if the child partakes in a cyclic relationship after the add - * - * @see #getPrimaryParent(NodeRef) - */ - public ChildAssociationRef moveNode( - NodeRef nodeToMoveRef, - NodeRef newParentRef, - QName assocTypeQName, - QName assocQName) - throws InvalidNodeRefException - { - // AVM stores only allow simple child associations. - if (!assocTypeQName.equals(ContentModel.ASSOC_CONTAINS)) - { - throw new InvalidTypeException(assocTypeQName); - } - // Extract the parts from the source. - Pair src = AVMNodeConverter.ToAVMVersionPath(nodeToMoveRef); - int srcVersion = src.getFirst(); - if (srcVersion >= 0) - { - throw new InvalidNodeRefException("Read Only Store.", nodeToMoveRef); - } - String srcPath = src.getSecond(); - String [] splitSrc = null; - try - { - splitSrc = AVMNodeConverter.SplitBase(srcPath); - } - catch (AVMException e) - { - throw new InvalidNodeRefException("Invalid src path.", nodeToMoveRef); - } - String srcParent = splitSrc[0]; - if (srcParent == null) - { - throw new InvalidNodeRefException("Cannot rename root node.", nodeToMoveRef); - } - String srcName = splitSrc[1]; - // Extract and setup the parts of the destination. - Pair dst = AVMNodeConverter.ToAVMVersionPath(newParentRef); - if (dst.getFirst() >= 0) - { - throw new InvalidNodeRefException("Read Only Store.", newParentRef); - } - String dstParent = dst.getSecond(); - String dstName = assocQName.getLocalName(); - // TODO Invoke policy behavior. Not quite sure how to translate this. - NodeRef oldParentRef = AVMNodeConverter.ToNodeRef(-1, srcParent); - ChildAssociationRef oldAssocRef = - new ChildAssociationRef(assocTypeQName, - oldParentRef, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, srcName), - nodeToMoveRef, - true, - -1); -// invokeBeforeDeleteChildAssociation(oldAssocRef); - String dstPath = AVMNodeConverter.ExtendAVMPath(dstParent, dstName); - NodeRef newChildRef = AVMNodeConverter.ToNodeRef(-1, dstPath); -// invokeBeforeUpdateNode(oldParentRef); -// invokeBeforeUpdateNode(newParentRef); - // Actually perform the rename and return a pseudo - // ChildAssociationRef. - try - { - fAVMService.rename(srcParent, srcName, dstParent, dstName); - ChildAssociationRef newAssocRef = - new ChildAssociationRef(assocTypeQName, - newParentRef, - assocQName, - newChildRef, - true, - -1); - invokeOnMoveNode(oldAssocRef, newAssocRef); -// invokeOnCreateChildAssociation(newAssocRef); -// invokeOnDeleteChildAssociation(oldAssocRef); -// invokeOnUpdateNode(oldParentRef); -// invokeOnUpdateNode(newParentRef); - return newAssocRef; - } - catch (AVMNotFoundException e) - { - throw new InvalidNodeRefException("Non existent node.", nodeToMoveRef); - } - catch (AVMExistsException e) - { - throw new InvalidNodeRefException("Target already exists.", newParentRef); - } - catch (AVMException e) - { - throw new InvalidNodeRefException("Illegal move.", nodeToMoveRef); - } - } - - /** - * Set the ordering index of the child association. This affects the ordering of - * of the return values of methods that return a set of children or child - * associations. - * - * @param childAssocRef the child association that must be moved in the order - * @param index an arbitrary index that will affect the return order - * - * @see #getChildAssocs(NodeRef) - * @see #getChildAssocs(NodeRef, QNamePattern, QNamePattern) - * @see ChildAssociationRef#getNthSibling() - */ - public void setChildAssociationIndex( - ChildAssociationRef childAssocRef, - int index) - throws InvalidChildAssociationRefException - { - // TODO We'll keep this a no-op unless there's a - // compelling reason to implement this capability - // for the AVM repository. - } - - /** - * @param nodeRef - * @return Returns the type name - * @throws InvalidNodeRefException if the node could not be found - * - * @see org.alfresco.service.cmr.dictionary.DictionaryService - */ - public QName getType(NodeRef nodeRef) throws InvalidNodeRefException - { - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - AVMNodeDescriptor desc = fAVMService.lookup(avmVersionPath.getFirst(), - avmVersionPath.getSecond()); - if (desc == null) - { - throw new InvalidNodeRefException(avmVersionPath.getSecond() + " not found.", nodeRef); - } - if (desc.isPlainDirectory()) - { - return WCMModel.TYPE_AVM_PLAIN_FOLDER; - } - else if (desc.isPlainFile()) - { - return WCMModel.TYPE_AVM_PLAIN_CONTENT; - } - else if (desc.isLayeredDirectory()) - { - return WCMModel.TYPE_AVM_LAYERED_FOLDER; - } - else - { - return WCMModel.TYPE_AVM_LAYERED_CONTENT; - } - } - - /** - * Re-sets the type of the node. Can be called in order specialise a node to a sub-type. - * - * This should be used with caution since calling it changes the type of the node and thus - * implies a different set of aspects, properties and associations. It is the calling codes - * responsibility to ensure that the node is in a approriate state after changing the type. - * - * @param nodeRef the node reference - * @param typeQName the type QName - * - * @since 1.1 - */ - public void setType(NodeRef nodeRef, QName typeQName) throws InvalidNodeRefException - { - throw new UnsupportedOperationException("AVM Types are immutable."); - } - - /** - * Applies an aspect to the given node. After this method has been called, - * the node with have all the aspect-related properties present - * - * @param nodeRef - * @param aspectTypeQName the aspect to apply to the node - * @param aspectProperties a minimum of the mandatory properties required for - * the aspect - * @throws InvalidNodeRefException - * @throws InvalidAspectException if the class reference is not to a valid aspect - * - * @see org.alfresco.service.cmr.dictionary.DictionaryService#getAspect(QName) - * @see org.alfresco.service.cmr.dictionary.ClassDefinition#getProperties() - */ - public void addAspect( - NodeRef nodeRef, - QName aspectTypeQName, - Map aspectProperties) - throws InvalidNodeRefException, InvalidAspectException - { - // Check that the aspect exists. - AspectDefinition aspectDef = this.dictionaryService.getAspect(aspectTypeQName); - if (aspectDef == null) - { - throw new InvalidAspectException("The aspect is invalid: " + aspectTypeQName, - aspectTypeQName); - } - // Invoke policy behaviors. -// invokeBeforeUpdateNode(nodeRef); -// invokeBeforeAddAspect(nodeRef, aspectTypeQName); - // Crack the nodeRef. - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = avmVersionPath.getFirst(); - if (version >= 0) - { - throw new InvalidNodeRefException("Read Only node.", nodeRef); - } - String avmPath = avmVersionPath.getSecond(); - // Accumulate properties. - Map properties = new HashMap(); - // Add the supplied properties. - if (aspectProperties != null) - { - properties.putAll(aspectProperties); - } - // Now set any unspecified default properties for the aspect. - Map defaultProperties = getDefaultProperties(aspectDef); - properties.putAll(defaultProperties); - // Now add any cascading aspects. - addDefaultAspects(aspectDef, avmPath, properties); - // Set the property values on the AVM Node. - if (properties.size() != 0) - { - Map props = new HashMap(); - for (Map.Entry entry : properties.entrySet()) - { - QName propertyQName = entry.getKey(); - if (isBuiltInProperty(propertyQName)) - { - continue; - } - Serializable value = entry.getValue(); - PropertyDefinition propertyDef = dictionaryService.getProperty(propertyQName); - PropertyValue propertyValue = makePropertyValue(propertyDef, value); - props.put(propertyQName, propertyValue); - } - if (props.size() != 0) - { - fAVMService.setNodeProperties(avmPath, props); - } - } - if (isBuiltinAspect(aspectTypeQName)) - { - // No more work to do in this case. - return; - } - try - { - fAVMService.addAspect(avmPath, aspectTypeQName); - // Invoke policy behaviors. -// invokeOnUpdateNode(nodeRef); -// invokeOnAddAspect(nodeRef, aspectTypeQName); - } - catch (AVMNotFoundException e) - { - throw new InvalidNodeRefException(nodeRef); - } - } - - /** - * Add any aspects that are mandatory for the ClassDefinition. - * @param classDef The ClassDefinition. - * @param path The path to the AVMNode. - * @param properties The in/out map of accumulated properties. - */ - private void addDefaultAspects(ClassDefinition classDef, String path, - Map properties) - { - NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, path); - // Get mandatory aspects. - List defaultAspectDefs = classDef.getDefaultAspects(); - // add all the aspects (and there dependent aspects recursively). - for (AspectDefinition def : defaultAspectDefs) - { -// invokeBeforeAddAspect(nodeRef, def.getName()); - addAspect(nodeRef, def.getName(), Collections.emptyMap()); - properties.putAll(getDefaultProperties(def)); -// invokeOnAddAspect(nodeRef, def.getName()); - // recurse - addDefaultAspects(def, path, properties); - } - } - - /** - * Remove an aspect and all related properties from a node - * - * @param nodeRef - * @param aspectTypeQName the type of aspect to remove - * @throws InvalidNodeRefException if the node could not be found - * @throws InvalidAspectException if the the aspect is unknown or if the - * aspect is mandatory for the class of the node - */ - public void removeAspect(NodeRef nodeRef, QName aspectTypeQName) - throws InvalidNodeRefException, InvalidAspectException - { - // Invoke policy behaviors. -// invokeBeforeUpdateNode(nodeRef); -// invokeBeforeRemoveAspect(nodeRef, aspectTypeQName); - AspectDefinition def = dictionaryService.getAspect(aspectTypeQName); - if (def == null) - { - throw new InvalidAspectException(aspectTypeQName); - } - if (isBuiltinAspect(aspectTypeQName)) - { - // TODO shouldn't we be throwing some kind of exception here. - return; - } - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = avmVersionPath.getFirst(); - if (version >= 0) - { - throw new InvalidNodeRefException("Read Only Node.", nodeRef); - } - String path = avmVersionPath.getSecond(); - try - { - if (fAVMService.hasAspect(-1, path, aspectTypeQName)) - { - fAVMService.removeAspect(path, aspectTypeQName); - Map propDefs = def.getProperties(); - for (QName propertyName : propDefs.keySet()) - { - fAVMService.deleteNodeProperty(path, propertyName); - } - } - // Invoke policy behaviors. -// invokeOnUpdateNode(nodeRef); -// invokeOnRemoveAspect(nodeRef, aspectTypeQName); - } - catch (AVMNotFoundException e) - { - throw new InvalidNodeRefException(nodeRef); - } - } - - /** - * Determines if a given aspect is present on a node. Aspects may only be - * removed if they are NOT mandatory. - * - * @param nodeRef - * @param aspectTypeQName - * @return Returns true if the aspect has been applied to the given node, - * otherwise false - * @throws InvalidNodeRefException if the node could not be found - * @throws InvalidAspectException if the aspect reference is invalid - */ - public boolean hasAspect(NodeRef nodeRef, QName aspectTypeQName) - throws InvalidNodeRefException, InvalidAspectException - { - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = avmVersionPath.getFirst(); - String path = avmVersionPath.getSecond(); - if (isBuiltinAspect(aspectTypeQName)) - { - return true; - } - return fAVMService.hasAspect(version, path, aspectTypeQName); - } - - private static QName [] fgBuiltinAspects = new QName[] { ContentModel.ASPECT_AUDITABLE, - ContentModel.ASPECT_REFERENCEABLE }; - - private boolean isBuiltinAspect(QName aspectQName) - { - for (QName builtin : fgBuiltinAspects) - { - if (builtin.equals(aspectQName)) - { - return true; - } - } - return false; - } - - /** - * @param nodeRef - * @return Returns a set of all aspects applied to the node, including mandatory - * aspects - * @throws InvalidNodeRefException if the node could not be found - */ - public Set getAspects(NodeRef nodeRef) throws InvalidNodeRefException - { - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = avmVersionPath.getFirst(); - String path = avmVersionPath.getSecond(); - Set result = new HashSet(); - // Add the builtin ones. - for (QName name : fgBuiltinAspects) - { - result.add(name); - } - try - { - for (QName name : fAVMService.getAspects(version, path)) - { - result.add(name); - } - return result; - } - catch (AVMNotFoundException e) - { - throw new InvalidNodeRefException(nodeRef); - } - } - - /** - * Deletes the given node. - *

- * All associations (both children and regular node associations) - * will be deleted, and where the given node is the primary parent, - * the children will also be cascade deleted. - * - * @param nodeRef reference to a node within a store - * @throws InvalidNodeRefException if the reference given is invalid - */ - public void deleteNode(NodeRef nodeRef) throws InvalidNodeRefException - { - // Invoke policy behaviors. -// invokeBeforeDeleteNode(nodeRef); - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - if (avmVersionPath.getFirst() != -1) - { - throw new InvalidNodeRefException("Read only store.", nodeRef); - } - String [] avmPathBase = AVMNodeConverter.SplitBase(avmVersionPath.getSecond()); - if (avmPathBase[0] == null) - { - throw new InvalidNodeRefException("Cannot delete root node.", nodeRef); - } - try - { -// QName nodeTypeQName = getType(nodeRef); -// Set aspects = getAspects(nodeRef); - fAVMService.removeNode(avmPathBase[0], avmPathBase[1]); -// ChildAssociationRef childAssocRef = -// new ChildAssociationRef(ContentModel.ASSOC_CHILDREN, -// AVMNodeConverter.ToNodeRef(-1, avmPathBase[0]), -// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, -// avmPathBase[1]), -// nodeRef); -// invokeOnDeleteNode(childAssocRef, nodeTypeQName, aspects, false); - } - catch (AVMNotFoundException e) - { - throw new InvalidNodeRefException(avmVersionPath.getSecond() +" not found.", nodeRef); - } - } - - /** - * Makes a parent-child association between the given nodes. Both nodes must belong to the same store. - *

- * - * @param parentRef - * @param childRef - * @param assocTypeQName the qualified name of the association type as defined in the datadictionary - * @param qname the qualified name of the association - * @return Returns a reference to the newly created child association - * @throws InvalidNodeRefException if the parent or child nodes could not be found - * @throws CyclicChildRelationshipException if the child partakes in a cyclic relationship after the add - */ - public ChildAssociationRef addChild( - NodeRef parentRef, - NodeRef childRef, - QName assocTypeQName, - QName qname) throws InvalidNodeRefException - { - return addChild(Collections.singletonList(parentRef), childRef, assocTypeQName, qname).get(0); - } - - /** - * Associates a given child node with a given collection of parents. All nodes must belong to the same store. - *

- * - * - * @param parentRefs - * @param childRef - * @param assocTypeQName the qualified name of the association type as defined in the datadictionary - * @param qname the qualified name of the association - * @return Returns a reference to the newly created child association - * @throws InvalidNodeRefException if the parent or child nodes could not be found - * @throws CyclicChildRelationshipException if the child partakes in a cyclic relationship after the add - */ - public List addChild( - Collection parentRefs, - NodeRef childRef, - QName assocTypeQName, - QName qname) throws InvalidNodeRefException - { - Pair childVersionPath = AVMNodeConverter.ToAVMVersionPath(childRef); - AVMNodeDescriptor child = fAVMService.lookup(childVersionPath.getFirst(), - childVersionPath.getSecond()); - if (child == null) - { - throw new InvalidNodeRefException(childVersionPath.getSecond() + " not found.", childRef); - } - - List childAssociationRefs = new ArrayList(parentRefs.size()); - for (NodeRef parentRef : parentRefs) - { - Pair parentVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef); - if (parentVersionPath.getFirst() >= 0) - { - throw new InvalidNodeRefException("Read Only.", parentRef); - } - try - { - fAVMService.link(parentVersionPath.getSecond(), qname.getLocalName(), child); - ChildAssociationRef newChild = new ChildAssociationRef(assocTypeQName, parentRef, qname, - AVMNodeConverter.ToNodeRef(-1, AVMNodeConverter.ExtendAVMPath(parentVersionPath.getSecond(), - qname.getLocalName()))); - childAssociationRefs.add(newChild); - } - catch (AVMException e) - { - throw new InvalidNodeRefException("Could not link.", childRef); - } - } - return childAssociationRefs; - } - - /** - * Severs all parent-child relationships between two nodes. - *

- * The child node will be cascade deleted if one of the associations was the - * primary association, i.e. the one with which the child node was created. - * - * @param parentRef the parent end of the association - * @param childRef the child end of the association - * @throws InvalidNodeRefException if the parent or child nodes could not be found - */ - public void removeChild(NodeRef parentRef, NodeRef childRef) throws InvalidNodeRefException - { - Pair parentVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef); - if (parentVersionPath.getFirst() >= 0) - { - throw new InvalidNodeRefException("Read only store.", parentRef); - } - Pair childVersionPath = AVMNodeConverter.ToAVMVersionPath(childRef); - if (childVersionPath.getFirst() >= 0) - { - throw new InvalidNodeRefException("Read only store.", childRef); - } - String parentPath = parentVersionPath.getSecond(); - String childPath = childVersionPath.getSecond(); - String [] childPathBase = AVMNodeConverter.SplitBase(childPath); - if (childPathBase[0] == null || !childPathBase[0].equals(parentPath)) - { - throw new InvalidNodeRefException(childPath + " not a child of " + parentPath, childRef); - } - try - { -// ChildAssociationRef assocRef = -// new ChildAssociationRef(ContentModel.ASSOC_CHILDREN, -// AVMNodeConverter.ToNodeRef(-1, parentPath), -// QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, -// childPathBase[1]), -// AVMNodeConverter.ToNodeRef(-1, childPath)); -// invokeBeforeDeleteChildAssociation(assocRef); - fAVMService.removeNode(childPathBase[0], childPathBase[1]); -// invokeOnDeleteChildAssociation(assocRef); -// invokeOnUpdateNode(AVMNodeConverter.ToNodeRef(-1, parentPath)); - } - catch (AVMNotFoundException e) - { - throw new InvalidNodeRefException(childPathBase[1] + " not found in " + childPathBase[0], - childRef); - } - } - - /** - * TODO: Check implementation - */ - public boolean removeChildAssociation(ChildAssociationRef childAssocRef) - { - NodeRef parentRef = childAssocRef.getParentRef(); - NodeRef childRef = childAssocRef.getChildRef(); - Pair parentVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef); - if (parentVersionPath.getFirst() >= 0) - { - throw new InvalidNodeRefException("Read only store.", parentRef); - } - Pair childVersionPath = AVMNodeConverter.ToAVMVersionPath(childRef); - if (childVersionPath.getFirst() >= 0) - { - throw new InvalidNodeRefException("Read only store.", childRef); - } - String parentPath = parentVersionPath.getSecond(); - String childPath = childVersionPath.getSecond(); - String [] childPathBase = AVMNodeConverter.SplitBase(childPath); - if (childPathBase[0] == null || !childPathBase[0].equals(parentPath)) - { - return false; - } - try - { - fAVMService.removeNode(childPathBase[0], childPathBase[1]); - return true; - } - catch (AVMNotFoundException e) - { - throw new InvalidNodeRefException("Not found.", childRef); - } - } - - /** - * TODO: Implement - */ - public boolean removeSecondaryChildAssociation(ChildAssociationRef childAssocRef) - { - throw new UnsupportedOperationException(); - } - - /** - * @param nodeRef - * @return Returns all properties keyed by their qualified name - * @throws InvalidNodeRefException if the node could not be found - */ - public Map getProperties(NodeRef nodeRef) throws InvalidNodeRefException - { - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - Map props = null; - AVMNodeDescriptor desc = fAVMService.lookup(avmVersionPath.getFirst(), - avmVersionPath.getSecond()); - try - { - props = fAVMService.getNodeProperties(avmVersionPath.getFirst(), - avmVersionPath.getSecond()); - } - catch (AVMNotFoundException e) - { - throw new InvalidNodeRefException(avmVersionPath.getSecond() + " not found.", nodeRef); - } - Map result = new HashMap(); - for (QName qName : props.keySet()) - { - PropertyValue value = props.get(qName); - PropertyDefinition def = dictionaryService.getProperty(qName); - result.put(qName, makeSerializableValue(def, value)); - } - // Now spoof properties that are built in. - result.put(ContentModel.PROP_CREATED, new Date(desc.getCreateDate())); - result.put(ContentModel.PROP_CREATOR, desc.getCreator()); - result.put(ContentModel.PROP_MODIFIED, new Date(desc.getModDate())); - result.put(ContentModel.PROP_MODIFIER, desc.getLastModifier()); - result.put(ContentModel.PROP_OWNER, desc.getOwner()); - result.put(ContentModel.PROP_NAME, desc.getName()); - result.put(ContentModel.PROP_NODE_UUID, "UNKNOWN"); - result.put(ContentModel.PROP_NODE_DBID, new Long(desc.getId())); - result.put(ContentModel.PROP_STORE_PROTOCOL, "avm"); - result.put(ContentModel.PROP_STORE_IDENTIFIER, nodeRef.getStoreRef().getIdentifier()); - if (desc.isLayeredDirectory()) - { - result.put(WCMModel.PROP_AVM_DIR_INDIRECTION, - AVMNodeConverter.ToNodeRef(-1, desc.getIndirection())); - } - if (desc.isLayeredFile()) - { - result.put(WCMModel.PROP_AVM_FILE_INDIRECTION, - AVMNodeConverter.ToNodeRef(-1, desc.getIndirection())); - } - if (desc.isFile()) - { - try - { - ContentData contentData = fAVMService.getContentDataForRead(avmVersionPath.getFirst(), - avmVersionPath.getSecond()); - result.put(ContentModel.PROP_CONTENT, contentData); - } - catch (AVMException e) - { - // TODO For now ignore. - } - } - return result; - } - - /** - * @param nodeRef - * @param qname the qualified name of the property - * @return Returns the value of the property, or null if not yet set - * @throws InvalidNodeRefException if the node could not be found - */ - public Serializable getProperty(NodeRef nodeRef, QName qname) throws InvalidNodeRefException - { - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - if (isBuiltInProperty(qname)) - { - return getBuiltInProperty(avmVersionPath, qname, nodeRef); - } - try - { - PropertyValue value = fAVMService.getNodeProperty(avmVersionPath.getFirst(), - avmVersionPath.getSecond(), - qname); - if (value == null) - { - return null; - } - PropertyDefinition def = this.dictionaryService.getProperty(qname); - return makeSerializableValue(def, value); - } - catch (AVMNotFoundException e) - { - throw new InvalidNodeRefException(avmVersionPath.getSecond() + " not found.", nodeRef); - } - } - - /** - * {@inheritDoc} - */ - public void removeProperty(NodeRef nodeRef, QName qname) throws InvalidNodeRefException - { - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - if (isBuiltInProperty(qname)) - { - // Ignore - return; - } - try - { - fAVMService.deleteNodeProperty(avmVersionPath.getSecond(), qname); - } - catch (AVMNotFoundException e) - { - throw new InvalidNodeRefException(avmVersionPath.getSecond() + " not found.", nodeRef); - } - } - - /** - * A Helper to spoof built in properties. - * @param avmVersionPath The broken out version and path from a NodeRef. - * @param qName The name of the property to retrieve. - * @param nodeRef The original NodeRef (for error reporting). - * @return The property value. - */ - private Serializable getBuiltInProperty(Pair avmVersionPath, - QName qName, - NodeRef nodeRef) - { - if (qName.equals(ContentModel.PROP_CONTENT)) - { - try - { - ContentData contentData = - fAVMService.getContentDataForRead(avmVersionPath.getFirst(), - avmVersionPath.getSecond()); - return contentData; - } - catch (AVMException e) - { - // TODO This seems very wrong. Do something better - // sooner rather than later. - return null; - } - } - AVMNodeDescriptor desc = fAVMService.lookup(avmVersionPath.getFirst(), - avmVersionPath.getSecond()); - if (desc == null) - { - throw new InvalidNodeRefException(avmVersionPath.getSecond() + " not found.", nodeRef); - } - if (qName.equals(ContentModel.PROP_CREATED)) - { - return new Date(desc.getCreateDate()); - } - else if (qName.equals(ContentModel.PROP_CREATOR)) - { - return desc.getCreator(); - } - else if (qName.equals(ContentModel.PROP_MODIFIED)) - { - return new Date(desc.getModDate()); - } - else if (qName.equals(ContentModel.PROP_MODIFIER)) - { - return desc.getLastModifier(); - } - else if (qName.equals(ContentModel.PROP_OWNER)) - { - return desc.getOwner(); - } - else if (qName.equals(ContentModel.PROP_NAME)) - { - return desc.getName(); - } - else if (qName.equals(ContentModel.PROP_NODE_UUID)) - { - return "UNKNOWN"; - } - else if (qName.equals(ContentModel.PROP_NODE_DBID)) - { - return new Long(desc.getId()); - } - else if (qName.equals(ContentModel.PROP_STORE_PROTOCOL)) - { - return "avm"; - } - else if (qName.equals(ContentModel.PROP_STORE_IDENTIFIER)) - { - return nodeRef.getStoreRef().getIdentifier(); - } - else if (qName.equals(WCMModel.PROP_AVM_DIR_INDIRECTION)) - { - if (desc.isLayeredDirectory()) - { - return AVMNodeConverter.ToNodeRef(-1, desc.getIndirection()); - } - return null; - } - else if (qName.equals(WCMModel.PROP_AVM_FILE_INDIRECTION)) - { - if (desc.isLayeredFile()) - { - return AVMNodeConverter.ToNodeRef(-1, desc.getIndirection()); - } - return null; - } - else - { - logger.error("Invalid Built In Property: " + qName); - return null; - } - } - - /** - * Set the values of all properties to be an Serializable instances. - * The properties given must still fulfill the requirements of the class and - * aspects relevant to the node. - *

- * NOTE: Null values are allowed. - * - * @param nodeRef - * @param properties all the properties of the node keyed by their qualified names - * @throws InvalidNodeRefException if the node could not be found - */ - public void setProperties(NodeRef nodeRef, Map properties) throws InvalidNodeRefException - { - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - if (avmVersionPath.getFirst() >= 0) - { - throw new InvalidNodeRefException("Read only store.", nodeRef); - } - // TODO Not sure this try block is necessary. - try - { - // Prepare fr policy invocation. - Map propsBefore = null; - if (fInvokePolicies) - { - propsBefore = getProperties(nodeRef); - } - // Remove all properties - fAVMService.deleteNodeProperties(avmVersionPath.getSecond()); - // Rebuild node properties - Map values = new HashMap(); - for (Map.Entry entry : properties.entrySet()) - { - QName propertyQName = entry.getKey(); - Serializable value = entry.getValue(); - // For AVM nodes is in place. - if (isBuiltInProperty(propertyQName)) - { - if (propertyQName.equals(ContentModel.PROP_CONTENT)) - { - AVMNodeDescriptor desc = fAVMService.lookup(-1, avmVersionPath.getSecond()); - if (desc == null) - { - throw new InvalidNodeRefException(avmVersionPath.getSecond() + " not found.", nodeRef); - } - if (desc.isPlainFile()) - { - fAVMService.setContentData(avmVersionPath.getSecond(), - (ContentData)properties.get(propertyQName)); - } - } - } - PropertyDefinition propertyDef = dictionaryService.getProperty(propertyQName); - PropertyValue propertyValue = makePropertyValue(propertyDef, value); - values.put(propertyQName, propertyValue); - } - // Finally set node properties - fAVMService.setNodeProperties(avmVersionPath.getSecond(), values); - // Invoke policies - if (fInvokePolicies) - { - Map propsAfter = properties; - invokeOnUpdateProperties(nodeRef, propsBefore, propsAfter); - } - // Invoke policy behaviors. -// invokeOnUpdateNode(nodeRef); -// invokeOnUpdateProperties(nodeRef, oldProps, properties); - } - catch (AVMNotFoundException e) - { - throw new InvalidNodeRefException(avmVersionPath.getSecond() + " not found.", nodeRef); - } - } - - public void addProperties(NodeRef nodeRef, Map properties) - { - // Overwrite the current properties - Map currentProperties = getProperties(nodeRef); - currentProperties.putAll(properties); - setProperties(nodeRef, currentProperties); - } - - static QName [] fgBuiltinProperties = new QName [] - { - ContentModel.PROP_CREATED, - ContentModel.PROP_CREATOR, - ContentModel.PROP_MODIFIED, - ContentModel.PROP_MODIFIER, - ContentModel.PROP_OWNER, - ContentModel.PROP_CONTENT, - ContentModel.PROP_NAME, - ContentModel.PROP_NODE_UUID, - ContentModel.PROP_NODE_DBID, - ContentModel.PROP_STORE_PROTOCOL, - ContentModel.PROP_STORE_IDENTIFIER, - WCMModel.PROP_AVM_FILE_INDIRECTION, - WCMModel.PROP_AVM_DIR_INDIRECTION - }; - - /** - * Helper to distinguish built-in from generic properties. - * @param qName The name of the property to check. - * @return Whether qName is a built-in propety. - */ - private boolean isBuiltInProperty(QName qName) - { - for (QName name : fgBuiltinProperties) - { - if (name.equals(qName)) - { - return true; - } - } - return false; - } - - /** - * Sets the value of a property to be any Serializable instance. - * To remove a property value, use {@link #getProperties(NodeRef)}, remove the - * value and call {@link #setProperties(NodeRef, Map)}. - *

- * NOTE: Null values are allowed. - * - * @param nodeRef - * @param qname the fully qualified name of the property - * @param propertyValue the value of the property - never null - * @throws InvalidNodeRefException if the node could not be found - */ - public void setProperty(NodeRef nodeRef, QName qname, Serializable value) throws InvalidNodeRefException - { - // Invoke policy behaviors. - // invokeBeforeUpdateNode(nodeRef); - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - if (avmVersionPath.getFirst() >= 0) - { - throw new InvalidNodeRefException("Read only store.", nodeRef); - } - - Map propsBefore = null; - if (fInvokePolicies) - { - propsBefore = getProperties(nodeRef); - } - - if (isBuiltInProperty(qname)) - { - if (qname.equals(ContentModel.PROP_CONTENT)) - { - try - { - fAVMService.setContentData(avmVersionPath.getSecond(), (ContentData)value); - if (fInvokePolicies) - { - Map propsAfter = new HashMap(propsBefore); - propsAfter.put(ContentModel.PROP_CONTENT, value); - invokeOnUpdateProperties(nodeRef, propsBefore, propsAfter); - } - } - catch (ClassCastException e) - { - throw new AVMException("Invalid ContentData.", e); - } - } - return; - } - try - { - - PropertyDefinition propertyDef = dictionaryService.getProperty(qname); - PropertyValue propertyValue = makePropertyValue(propertyDef, value); - fAVMService.setNodeProperty(avmVersionPath.getSecond(), qname, propertyValue); - if (fInvokePolicies) - { - Map propsAfter = new HashMap(propsBefore); - propsAfter.put(qname, value); - invokeOnUpdateProperties(nodeRef, propsBefore, propsAfter); - } - // Map propsAfter = getProperties(nodeRef); - // Invoke policy behaviors. - // invokeOnUpdateNode(nodeRef); - // invokeOnUpdateProperties(nodeRef, propsBefore, propsAfter); - } - catch (AVMNotFoundException e) - { - throw new InvalidNodeRefException(avmVersionPath.getSecond() + " not found.", nodeRef); - } - } - - /** - * @param nodeRef the child node - * @return Returns a list of all parent-child associations that exist where the given - * node is the child - * @throws InvalidNodeRefException if the node could not be found - * - * @see #getParentAssocs(NodeRef, QNamePattern, QNamePattern) - */ - public List getParentAssocs(NodeRef nodeRef) throws InvalidNodeRefException - { - // TODO OK, for now we'll simply return the single parent that corresponds - // to the path stuffed in the NodeRef. - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - String path = avmVersionPath.getSecond(); - List result = new ArrayList(); - String [] splitPath = AVMNodeConverter.SplitBase(path); - if (splitPath[0] == null) - { - return result; - } - result.add(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, - AVMNodeConverter.ToNodeRef(avmVersionPath.getFirst(), - splitPath[0]), - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, - splitPath[1]), - nodeRef, - true, - -1)); - return result; - } - - /** - * Gets all parent associations where the pattern of the association qualified - * name is a match - *

- * The resultant list is ordered by (a) explicit index and (b) association creation time. - * - * @param nodeRef the child node - * @param typeQNamePattern the pattern that the type qualified name of the association must match - * @param qnamePattern the pattern that the qnames of the assocs must match - * @return Returns a list of all parent-child associations that exist where the given - * node is the child - * @throws InvalidNodeRefException if the node could not be found - * - * @see ChildAssociationRef#getNthSibling() - * @see #setChildAssociationIndex(ChildAssociationRef, int) - * @see QName - * @see org.alfresco.service.namespace.RegexQNamePattern#MATCH_ALL - */ - public List getParentAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) - throws InvalidNodeRefException - { - if (!typeQNamePattern.isMatch(ContentModel.ASSOC_CONTAINS)) - { - return new ArrayList(); - } - List result = getParentAssocs(nodeRef); - if (result.size() == 0) - { - return result; - } - if (qnamePattern.isMatch(result.get(0).getQName())) - { - return result; - } - return new ArrayList(); - } - - /** - * Get all child associations of the given node. - *

- * The resultant list is ordered by (a) explicit index and (b) association creation time. - * - * @param nodeRef the parent node - usually a container - * @return Returns a collection of ChildAssocRef instances. If the - * node is not a container then the result will be empty. - * @throws InvalidNodeRefException if the node could not be found - * - * @see #getChildAssocs(NodeRef, QNamePattern, QNamePattern) - * @see #setChildAssociationIndex(ChildAssociationRef, int) - * @see ChildAssociationRef#getNthSibling() - */ - public List getChildAssocs(NodeRef nodeRef) throws InvalidNodeRefException - { - - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = avmVersionPath.getFirst(); - String path = avmVersionPath.getSecond(); - List result = new ArrayList(); - SortedMap children = null; - try - { - children = - fAVMService.getDirectoryListing(version, - path); - } - catch (AVMNotFoundException e) - { - return result; - } - for (String name : children.keySet()) - { - result.add(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, - nodeRef, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, - name), - AVMNodeConverter.ToNodeRef( - version, - AVMNodeConverter.ExtendAVMPath(path, name)), - true, - -1)); - } - return result; - } - - /** - * Gets all child associations where the pattern of the association qualified - * name is a match. - * - * @param nodeRef the parent node - usually a container - * @param typeQNamePattern the pattern that the type qualified name of the association must match - * @param qnamePattern the pattern that the qnames of the assocs must match - * @return Returns a list of ChildAssocRef instances. If the - * node is not a container then the result will be empty. - * @throws InvalidNodeRefException if the node could not be found - * - * @see QName - * @see org.alfresco.service.namespace.RegexQNamePattern#MATCH_ALL - */ - public List getChildAssocs( - NodeRef nodeRef, - QNamePattern typeQNamePattern, - QNamePattern qnamePattern) - throws InvalidNodeRefException - { - List result = new ArrayList(); - if (!typeQNamePattern.isMatch(ContentModel.ASSOC_CONTAINS)) - { - return result; - } - // First check if we are matching on all - if (qnamePattern == null || !(qnamePattern instanceof QName)) - { - // Either null (always match) or we have to match on each, individually - List all = getChildAssocs(nodeRef); - for (ChildAssociationRef child : all) - { - if (qnamePattern == null || !qnamePattern.isMatch(child.getQName())) - { - continue; - } - result.add(child); - } - return result; - } - else - { - // We have a specific QName and therefore an exact path - QName qname = (QName) qnamePattern; - String name = qname.getLocalName(); - - // Resolve the container - Pair containerVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int containerVersion = containerVersionPath.getFirst(); - String containerPath = containerVersionPath.getSecond(); - try - { - // Get the descriptor for the container - AVMNodeDescriptor containerDescriptor = fAVMService.lookup(containerVersion, containerPath); - @SuppressWarnings("unused") // Might succeed or fail - AVMNodeDescriptor childDescriptor = fAVMService.lookup(containerDescriptor, name); - result.add( - new ChildAssociationRef( - ContentModel.ASSOC_CONTAINS, - nodeRef, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), - AVMNodeConverter.ToNodeRef( - containerVersion, - AVMNodeConverter.ExtendAVMPath(containerPath, name)), - true, - -1)); - } - catch (AVMNotFoundException e) - { - return result; - } - catch (AVMWrongTypeException e) - { - return result; - } - return result; - } - } - - @Override - public List getChildAssocs(NodeRef nodeRef, QNamePattern typeQName, QNamePattern qname, int maxResults, - boolean preload) throws InvalidNodeRefException - { - List result = getChildAssocs(nodeRef, typeQName, qname); - if (result.size() > maxResults) - { - return result.subList(0, maxResults); - } - return result; - } - - public List getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, - QNamePattern qnamePattern, boolean preload) throws InvalidNodeRefException - { - return getChildAssocs(nodeRef, typeQNamePattern, qnamePattern); - } - - public List getChildAssocs(NodeRef nodeRef, Set childNodeTypes) - { - /* - * ETWOTWO-961 forced an implementation, but this is just a workaround. - * We do a listing and then keep files or folders looking specifically - * for cm:folder and cm:content types from childNodeTypes. - */ - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = avmVersionPath.getFirst(); - String path = avmVersionPath.getSecond(); - List result = new ArrayList(); - SortedMap children = null; - try - { - children = - fAVMService.getDirectoryListing(version, - path); - } - catch (AVMNotFoundException e) - { - return result; - } - for (Map.Entry entry : children.entrySet()) - { - String name = entry.getKey(); - AVMNodeDescriptor descriptor = entry.getValue(); - if (descriptor.isFile()) - { - if (!childNodeTypes.contains(ContentModel.TYPE_CONTENT)) - { - continue; - } - } - else if (descriptor.isDirectory()) - { - if (!childNodeTypes.contains(ContentModel.TYPE_FOLDER)) - { - continue; - } - } - else - { - // Not a file or directory??? - continue; - } - result.add(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, - nodeRef, - QName.createQName( - NamespaceService.CONTENT_MODEL_1_0_URI, - name), - AVMNodeConverter.ToNodeRef( - version, - AVMNodeConverter.ExtendAVMPath(path, name)), - true, - -1)); - } - return result; - } - - /** - * getChildrenByName - */ - public List getChildrenByName(NodeRef nodeRef, QName assocTypeQName, Collection childNames) - { - final List results = new ArrayList(100); - - if (!assocTypeQName.equals(ContentModel.ASSOC_CONTAINS)) - { - throw new UnsupportedOperationException("AVM getChildrenByName only supports ASSOCS_CONTAINS."); - } - - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - try - { - for(String childName : childNames) - { - AVMNodeDescriptor child = fAVMService.lookup(avmVersionPath.getFirst(), - AVMUtil.extendAVMPath(avmVersionPath.getSecond(), childName)); - - if (child != null) - { - NodeRef childRef = AVMNodeConverter.ToNodeRef(avmVersionPath.getFirst(), - child.getPath()); - QName childQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, - childName); - ChildAssociationRef ref = new ChildAssociationRef(assocTypeQName, nodeRef, childQName, childRef); - - if(logger.isDebugEnabled()) - { - logger.debug("got a child node :" + ref); - } - results.add(ref); - } - } - return results; - } - catch (AVMException e) - { - logger.debug("exception in getChildrenByName ", e); - return results; - } - } - - - /** - * Get a child NodeRef by name. - * @param nodeRef The parent node. - * @param assocTypeQName The type of the Child Association. - * @param childName The name of the child to get. - */ - public NodeRef getChildByName(NodeRef nodeRef, QName assocTypeQName, String childName) - { - if (!assocTypeQName.equals(ContentModel.ASSOC_CONTAINS)) - { - return null; - } - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - try - { - AVMNodeDescriptor child = fAVMService.lookup(avmVersionPath.getFirst(), - AVMUtil.extendAVMPath(avmVersionPath.getSecond(), childName)); - if (child == null) - { - return null; - } - return AVMNodeConverter.ToNodeRef(avmVersionPath.getFirst(), - child.getPath()); - } - catch (AVMException e) - { - return null; - } - } - - /** - * Fetches the primary parent-child relationship. - *

- * For a root node, the parent node reference will be null. - * - * @param nodeRef - * @return Returns the primary parent-child association of the node - * @throws InvalidNodeRefException if the node could not be found - */ - public ChildAssociationRef getPrimaryParent(NodeRef nodeRef) throws InvalidNodeRefException - { - List parents = getParentAssocs(nodeRef); - if (parents.size() == 0) - { - return new ChildAssociationRef(null, null, null, nodeRef); - } - return parents.get(0); - } - - /** - * @throws UnsupportedOperationException always - */ - @Override - public AssociationRef createAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName) - throws InvalidNodeRefException, AssociationExistsException - { - throw new UnsupportedOperationException("AVM does not support arbitrary associations."); - } - - /** - * @throws UnsupportedOperationException always - */ - @Override - public void setAssociations(NodeRef sourceRef, QName assocTypeQName, List targetRefs) - { - throw new UnsupportedOperationException("AVM does not support arbitrary associations."); - } - - /** - * - * @param sourceRef the associaton source node - * @param targetRef the association target node - * @param assocTypeQName the qualified name of the association type - * @throws InvalidNodeRefException if either of the nodes could not be found - */ - public void removeAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName) - throws InvalidNodeRefException - { - throw new UnsupportedOperationException("AVM does not support arbitrary associations."); - } - - /** - * Gets an association by ID. - * - * @param assocId - * the association id - * @return the association, or null if it does not exist - */ - public AssociationRef getAssoc(Long id) - { - return null; - } - - /** - * Fetches all associations from the given source where the associations' - * qualified names match the pattern provided. - * - * @param sourceRef the association source - * @param qnamePattern the association qname pattern to match against - * @return Returns a list of NodeAssocRef instances for which the - * given node is a source - * @throws InvalidNodeRefException if the source node could not be found - * - * @see QName - * @see org.alfresco.service.namespace.RegexQNamePattern#MATCH_ALL - */ - public List getTargetAssocs(NodeRef sourceRef, QNamePattern qnamePattern) - throws InvalidNodeRefException - { - return new ArrayList(); - } - - /** - * Fetches all associations to the given target where the associations' - * qualified names match the pattern provided. - * - * @param targetRef the association target - * @param qnamePattern the association qname pattern to match against - * @return Returns a list of NodeAssocRef instances for which the - * given node is a target - * @throws InvalidNodeRefException - * - * @see QName - * @see org.alfresco.service.namespace.RegexQNamePattern#MATCH_ALL - */ - public List getSourceAssocs(NodeRef targetRef, QNamePattern qnamePattern) - throws InvalidNodeRefException - { - return new ArrayList(); - } - - /** - * The root node has an entry in the path(s) returned. For this reason, there - * will always be at least one path element in the returned path(s). - * The first element will have a null parent reference and qname. - * - * @param nodeRef - * @return Returns the path to the node along the primary node path - * @throws InvalidNodeRefException if the node could not be found - * - * @see #getPaths(NodeRef, boolean) - */ - public Path getPath(NodeRef nodeRef) throws InvalidNodeRefException - { - // TODO Review later. This may be wrong. - Path path = new Path(); - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = avmVersionPath.getFirst(); - String currPath = avmVersionPath.getSecond(); - while (!currPath.endsWith("/")) - { - String [] splitPath = AVMNodeConverter.SplitBase(currPath); - String parentPath = splitPath[0]; - String name = splitPath[1]; - ChildAssociationRef caRef = - new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, - AVMNodeConverter.ToNodeRef(version, parentPath), - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, - name), - AVMNodeConverter.ToNodeRef(version, currPath), - true, - -1); - path.prepend(new Path.ChildAssocElement(caRef)); - currPath = parentPath; - } - ChildAssociationRef caRef = new ChildAssociationRef(null, null, null, - AVMNodeConverter.ToNodeRef(version, - currPath)); - path.prepend(new Path.ChildAssocElement(caRef)); - return path; - } - - /** - * The root node has an entry in the path(s) returned. For this reason, there - * will always be at least one path element in the returned path(s). - * The first element will have a null parent reference and qname. - * - * @param nodeRef - * @param primaryOnly true if only the primary path must be retrieved. If true, the - * result will have exactly one entry. - * @return Returns a List of all possible paths to the given node - * @throws InvalidNodeRefException if the node could not be found - */ - public List getPaths(NodeRef nodeRef, boolean primaryOnly) throws InvalidNodeRefException - { - List result = new ArrayList(); - result.add(getPath(nodeRef)); - return result; - } - - /** - * Get the node where archived items will have gone when deleted from the given store. - * - * @param storeRef the store that items were deleted from - * @return Returns the archive node parent - */ - public NodeRef getStoreArchiveNode(StoreRef storeRef) - { - throw new UnsupportedOperationException("AVM does not support this operation."); - } - - /** - * Restore an individual node (along with its sub-tree nodes) to the target location. - * The archived node must have the {@link org.alfresco.model.ContentModel#ASPECT_ARCHIVED archived aspect} - * set against it. - * - * @param archivedNodeRef the archived node - * @param destinationParentNodeRef the parent to move the node into - * or null to use the original - * @param assocTypeQName the primary association type name to use in the new location - * or null to use the original - * @param assocQName the primary association name to use in the new location - * or null to use the original - * @return Returns the reference to the newly created node - */ - public NodeRef restoreNode( - NodeRef archivedNodeRef, - NodeRef destinationParentNodeRef, - QName assocTypeQName, - QName assocQName) - { - throw new UnsupportedOperationException("AVM does not support this operation."); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.repository.NodeService#getChildAssocsWithoutParentAssocsOfType(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - public Collection getChildAssocsWithoutParentAssocsOfType(NodeRef parent, QName assocTypeQName) - { - throw new UnsupportedOperationException("AVM does not support this operation."); - } - - public Long getNodeAclId(NodeRef nodeRef) throws InvalidNodeRefException - { - throw new UnsupportedOperationException("getNodeAclId is unsupported for AVMNodeService"); - } - - @Override - public List getChildAssocsByPropertyValue( - NodeRef nodeRef, QName propertyQName, Serializable value) - { - throw new UnsupportedOperationException("AVM does not support this operation."); - } - - @Override - public int countChildAssocs(NodeRef nodeRef, boolean isPrimary) throws InvalidNodeRefException - { - throw new UnsupportedOperationException("AVM does not support this operation."); - } - -} diff --git a/source/java/org/alfresco/repo/avm/AVMNodeType.java b/source/java/org/alfresco/repo/avm/AVMNodeType.java deleted file mode 100644 index b144254a03..0000000000 --- a/source/java/org/alfresco/repo/avm/AVMNodeType.java +++ /dev/null @@ -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 . */ - -package org.alfresco.repo.avm; - -/** - * This defines the different types of FolderEntrys. - * @author britt - */ -public interface AVMNodeType -{ - public static final int PLAIN_FILE = 0; - public static final int LAYERED_FILE = 1; - public static final int PLAIN_DIRECTORY = 2; - public static final int LAYERED_DIRECTORY = 3; - public static final int DELETED_NODE = 4; -} diff --git a/source/java/org/alfresco/repo/avm/AVMRemoteLocal.java b/source/java/org/alfresco/repo/avm/AVMRemoteLocal.java deleted file mode 100644 index d4382ca7a5..0000000000 --- a/source/java/org/alfresco/repo/avm/AVMRemoteLocal.java +++ /dev/null @@ -1,555 +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 . - */ -package org.alfresco.repo.avm; - -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.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.remote.AVMRemote; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; - -/** - * A loopback implementation of the AVMRemote interface? - * @author britt - */ -public class AVMRemoteLocal implements AVMRemote -{ - /** - * The AVMService instance. - */ - private AVMService fService; - - /** - * Default constructor. - */ - public AVMRemoteLocal() - { - } - - /** - * Setter for the AVMService instance. - */ - public void setAvmService(AVMService service) - { - fService = service; - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#createAVMStore(java.lang.String) - */ - public void createStore(String name) - { - fService.createStore(name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#createBranch(int, java.lang.String, java.lang.String, java.lang.String) - */ - public void createBranch(int version, String srcPath, String dstPath, - String name) - { - fService.createBranch(version, srcPath, dstPath, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#createDirectory(java.lang.String, java.lang.String) - */ - public void createDirectory(String path, String name) - { - fService.createDirectory(path, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#createFile(java.lang.String, java.lang.String) - */ - public OutputStream createFile(String path, String name) - { - return fService.createFile(path, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#createLayeredDirectory(java.lang.String, java.lang.String, java.lang.String) - */ - public void createLayeredDirectory(String targetPath, String parent, - String name) - { - fService.createLayeredDirectory(targetPath, parent, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#createLayeredFile(java.lang.String, java.lang.String, java.lang.String) - */ - public void createLayeredFile(String targetPath, String parent, String name) - { - fService.createLayeredFile(targetPath, parent, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#createSnapshot(java.lang.String) - */ - public Map createSnapshot(String store, String label, String comment) - { - return fService.createSnapshot(store, label, comment); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#deleteNodeProperties(java.lang.String) - */ - public void deleteNodeProperties(String path) - { - fService.deleteNodeProperties(path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#deleteNodeProperty(java.lang.String, org.alfresco.service.namespace.QName) - */ - public void deleteNodeProperty(String path, QName name) - { - fService.deleteNodeProperty(path, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#deleteStoreProperty(java.lang.String, org.alfresco.service.namespace.QName) - */ - public void deleteStoreProperty(String store, QName name) - { - fService.deleteStoreProperty(store, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getAVMStore(java.lang.String) - */ - public AVMStoreDescriptor getStore(String name) - { - return fService.getStore(name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getAVMStoreRoot(int, java.lang.String) - */ - public AVMNodeDescriptor getStoreRoot(int version, String name) - { - return fService.getStoreRoot(version, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getAVMStoreVersions(java.lang.String) - */ - public List getStoreVersions(String name) - { - return fService.getStoreVersions(name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getAVMStoreVersions(java.lang.String, java.util.Date, java.util.Date) - */ - public List getStoreVersions(String name, Date from, - Date to) - { - return fService.getStoreVersions(name, from, to); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getAVMStores() - */ - public List getStores() - { - return fService.getStores(); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getCommonAncestor(org.alfresco.service.cmr.avm.AVMNodeDescriptor, org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public AVMNodeDescriptor getCommonAncestor(AVMNodeDescriptor left, - AVMNodeDescriptor right) - { - return fService.getCommonAncestor(left, right); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getDeleted(int, java.lang.String) - */ - public List getDeleted(int version, String path) - { - return fService.getDeleted(version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getDirectoryListing(int, java.lang.String) - */ - public SortedMap getDirectoryListing( - int version, String path) - { - return fService.getDirectoryListing(version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getDirectoryListing(org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public SortedMap getDirectoryListing( - AVMNodeDescriptor dir) - { - return fService.getDirectoryListing(dir); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getDirectoryListingDirect(int, java.lang.String) - */ - public SortedMap getDirectoryListingDirect( - int version, String path) - { - return fService.getDirectoryListingDirect(version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getFileInputStream(int, java.lang.String) - */ - public InputStream getFileInputStream(int version, String path) - { - return fService.getFileInputStream(version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getFileInputStream(org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public InputStream getFileInputStream(AVMNodeDescriptor desc) - { - return fService.getFileInputStream(desc); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getFileOutputStream(java.lang.String) - */ - public OutputStream getFileOutputStream(String path) - { - return fService.getFileOutputStream(path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getHistory(org.alfresco.service.cmr.avm.AVMNodeDescriptor, int) - */ - public List getHistory(AVMNodeDescriptor desc, int count) - { - return fService.getHistory(desc, count); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getIndirectionPath(int, java.lang.String) - */ - public String getIndirectionPath(int version, String path) - { - return fService.getIndirectionPath(version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getLatestSnapshotID(java.lang.String) - */ - public int getLatestSnapshotID(String storeName) - { - return fService.getLatestSnapshotID(storeName); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getLatestVersionID(java.lang.String) - */ - public int getNextVersionID(String storeName) - { - return fService.getNextVersionID(storeName); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getLayeringInfo(int, java.lang.String) - */ - public LayeringDescriptor getLayeringInfo(int version, String path) - { - return fService.getLayeringInfo(version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getNodeProperties(int, java.lang.String) - */ - public Map getNodeProperties(int version, String path) - { - return fService.getNodeProperties(version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getNodeProperty(int, java.lang.String, org.alfresco.service.namespace.QName) - */ - public PropertyValue getNodeProperty(int version, String path, QName name) - { - return fService.getNodeProperty(version, path, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getStoreProperties(java.lang.String) - */ - public Map getStoreProperties(String store) - { - return fService.getStoreProperties(store); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getStoreProperty(java.lang.String, org.alfresco.service.namespace.QName) - */ - public PropertyValue getStoreProperty(String store, QName name) - { - return fService.getStoreProperty(store, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#lookup(int, java.lang.String) - */ - public AVMNodeDescriptor lookup(int version, String path) - { - return fService.lookup(version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#lookup(int, java.lang.String, boolean) - */ - public AVMNodeDescriptor lookup(int version, String path, boolean includeDeleted) - { - return fService.lookup(version, path, includeDeleted); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#lookup(org.alfresco.service.cmr.avm.AVMNodeDescriptor, java.lang.String) - */ - public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name) - { - return fService.lookup(dir, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#lookup(org.alfresco.service.cmr.avm.AVMNodeDescriptor, java.lang.String, boolean includeDeleted) - */ - public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name, boolean includeDeleted) - { - return fService.lookup(dir, name, includeDeleted); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#makePrimary(java.lang.String) - */ - public void makePrimary(String path) - { - fService.makePrimary(path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#purgeAVMStore(java.lang.String) - */ - public void purgeStore(String name) - { - fService.purgeStore(name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#purgeVersion(int, java.lang.String) - */ - public void purgeVersion(int version, String name) - { - fService.purgeVersion(version, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#queryStorePropertyKey(java.lang.String, org.alfresco.service.namespace.QName) - */ - public Map queryStorePropertyKey(String store, - QName keyPattern) - { - return fService.queryStorePropertyKey(store, keyPattern); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#queryStoresPropertyKey(org.alfresco.service.namespace.QName) - */ - public Map> queryStoresPropertyKey( - QName keyPattern) - { - return fService.queryStoresPropertyKeys(keyPattern); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#removeNode(java.lang.String, java.lang.String) - */ - public void removeNode(String parent, String name) - { - fService.removeNode(parent, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#rename(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - public void rename(String srcParent, String srcName, String dstParent, - String dstName) - { - fService.rename(srcParent, srcName, dstParent, dstName); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#retargetLayeredDirectory(java.lang.String, java.lang.String) - */ - public void retargetLayeredDirectory(String path, String target) - { - fService.retargetLayeredDirectory(path, target); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#setNodeProperties(java.lang.String, java.util.Map) - */ - public void setNodeProperties(String path, - Map properties) - { - fService.setNodeProperties(path, properties); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#setNodeProperty(java.lang.String, org.alfresco.service.namespace.QName, org.alfresco.repo.domain.PropertyValue) - */ - public void setNodeProperty(String path, QName name, PropertyValue value) - { - fService.setNodeProperty(path, name, value); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#setOpacity(java.lang.String, boolean) - */ - public void setOpacity(String path, boolean opacity) - { - fService.setOpacity(path, opacity); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#setStoreProperties(java.lang.String, java.util.Map) - */ - public void setStoreProperties(String store, Map props) - { - fService.setStoreProperties(store, props); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#setStoreProperty(java.lang.String, org.alfresco.service.namespace.QName, org.alfresco.repo.domain.PropertyValue) - */ - public void setStoreProperty(String store, QName name, PropertyValue value) - { - fService.setStoreProperty(store, name, value); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#uncover(java.lang.String, java.lang.String) - */ - public void uncover(String dirPath, String name) - { - fService.uncover(dirPath, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#renameStore(java.lang.String, java.lang.String) - */ - public void renameStore(String sourceName, String destName) - { - fService.renameStore(sourceName, destName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#addAspect(java.lang.String, org.alfresco.service.namespace.QName) - */ - public void addAspect(String path, QName aspectName) - { - fService.addAspect(path, aspectName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#getAspects(int, java.lang.String) - */ - public Set getAspects(int version, String path) - { - return fService.getAspects(version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#hasAspect(int, java.lang.String, org.alfresco.service.namespace.QName) - */ - public boolean hasAspect(int version, String path, QName aspectName) - { - return fService.hasAspect(version, path, aspectName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#removeAspect(java.lang.String, org.alfresco.service.namespace.QName) - */ - public void removeAspect(String path, QName aspectName) - { - fService.removeAspect(path, aspectName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#revert(java.lang.String, org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public void revert(String path, AVMNodeDescriptor toRevertTo) - { - fService.revert(path, toRevertTo); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#getAPath(org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public Pair getAPath(AVMNodeDescriptor desc) - { - return fService.getAPath(desc); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#setGuid(java.lang.String, java.lang.String) - */ - public void setGuid(String path, String guid) - { - fService.setGuid(path, guid); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#setEncoding(java.lang.String, java.lang.String) - */ - public void setEncoding(String path, String encoding) - { - fService.setEncoding(path, encoding); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#setMimeType(java.lang.String, java.lang.String) - */ - public void setMimeType(String path, String mimeType) - { - fService.setMimeType(path, mimeType); - } -} diff --git a/source/java/org/alfresco/repo/avm/AVMRemoteTransportService.java b/source/java/org/alfresco/repo/avm/AVMRemoteTransportService.java deleted file mode 100644 index b7c58a5a81..0000000000 --- a/source/java/org/alfresco/repo/avm/AVMRemoteTransportService.java +++ /dev/null @@ -1,1101 +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 . - */ -package org.alfresco.repo.avm; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -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.AVMException; -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.remote.AVMRemoteTransport; -import org.alfresco.service.cmr.security.AuthenticationService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.GUID; -import org.alfresco.util.Pair; - -/** - * Implementation of AVMRemoteTransport for the server side. It's - * job is to validate the authentication ticket passed with each - * method call, and to manage remote InputStreams and OutputStreams. - * @author britt - */ -public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable -{ - /** - * The map of handles to open input streams. - */ - private Map fInputStreams; - - /** - * The map of handles to last accesses for input streams. - */ - private Map fInputLastAccessTimes; - - /** - * The map of handles to busy flags. - */ - private Map fInputBusy; - - /** - * The map of handles to open output streams. - */ - private Map fOutputStreams; - - /** - * The map of handles to last accesses for output streams. - */ - private Map fOutputLastAccessTimes; - - /** - * The map of handles to busy flags. - */ - private Map fOutputBusy; - - /** - * The stale handle time. This is the maximum time a handle - * can stay idle in milliseconds. - */ - private long fIdleTimeout; - - /** - * Reference to AVMService. - */ - private AVMService fAVMService; - - /** - * Reference to the AuthenticationService. - */ - private AuthenticationService fAuthService; - - /** - * The thread for this Runnable. - */ - private Thread fThread; - - /** - * Flag for whether this Runnable is done. - */ - private boolean fDone; - - /** - * Default constructor. - */ - public AVMRemoteTransportService() - { - fIdleTimeout = 30000; - fInputStreams = new HashMap(); - fInputLastAccessTimes = new HashMap(); - fInputBusy = new HashMap(); - fOutputStreams = new HashMap(); - fOutputLastAccessTimes = new HashMap(); - fOutputBusy = new HashMap(); - } - - // Setters for Spring. - - /** - * Set the Idle Timeout value. - * @param timeout The value to set. - */ - public void setIdleTimeout(long timeout) - { - fIdleTimeout = timeout; - } - - /** - * Set the AVMService. - * @param service The service to set. - */ - public void setAvmService(AVMService service) - { - fAVMService = service; - } - - public void setAuthenticationService(AuthenticationService service) - { - fAuthService = service; - } - - /** - * The init method. This fires up a thread to check - * for closable streams. - */ - public void init() - { - fThread = new Thread(this); - fThread.setDaemon(true); - fDone = false; - fThread.start(); - } - - /** - * The body of this Runnable. - */ - public synchronized void run() - { - while (!fDone) - { - try - { - wait(fIdleTimeout); - } - catch (InterruptedException e) - { - // Do nothing. - } - long now = System.currentTimeMillis(); - List toClose = new ArrayList(); - for (String handle : fInputLastAccessTimes.keySet()) - { - if (fInputBusy.get(handle)) - { - continue; - } - if (now - fInputLastAccessTimes.get(handle) > fIdleTimeout) - { - toClose.add(handle); - } - } - for (String handle : toClose) - { - try - { - fInputStreams.get(handle).close(); - } - catch (IOException e) - { - // Do nothing. - } - fInputStreams.remove(handle); - fInputLastAccessTimes.remove(handle); - fInputBusy.remove(handle); - } - toClose.clear(); - for (String handle : fOutputLastAccessTimes.keySet()) - { - if (fOutputBusy.get(handle)) - { - continue; - } - if (now - fOutputLastAccessTimes.get(handle) > fIdleTimeout) - { - toClose.add(handle); - } - } - for (String handle : toClose) - { - try - { - fOutputStreams.get(handle).close(); - } - catch (IOException e) - { - // Do nothing. - } - fOutputStreams.remove(handle); - fOutputLastAccessTimes.remove(handle); - fOutputBusy.remove(handle); - } - } - } - - /** - * Shutdown the Runnable cleanly. - */ - public void shutDown() - { - synchronized (this) - { - fDone = true; - notifyAll(); - } - try - { - fThread.join(); - } - catch (InterruptedException e) - { - // Do nothing. - } - } - - /** - * Get an input handle. A handle is an opaque reference - * to a server side input stream. - * @param version The version to look under. - * @param path The path to the file. - * @return A handle. - */ - public String getInputHandle(String ticket, int version, String path) - { - fAuthService.validate(ticket); - InputStream in = fAVMService.getFileInputStream(version, path); - String handle = GUID.generate(); - synchronized (this) - { - fInputStreams.put(handle, in); - fInputLastAccessTimes.put(handle, System.currentTimeMillis()); - fInputBusy.put(handle, false); - } - return handle; - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemoteTransport#getInputHandle(java.lang.String, org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public String getInputHandle(String ticket, AVMNodeDescriptor desc) - { - fAuthService.validate(ticket); - InputStream in = fAVMService.getFileInputStream(desc); - String handle = GUID.generate(); - synchronized (this) - { - fInputStreams.put(handle, in); - fInputLastAccessTimes.put(handle, System.currentTimeMillis()); - fInputBusy.put(handle, false); - } - return handle; - } - - /** - * Read a chunk of data from a handle. - * @param handle The opaque input stream handle. - * @param count The number of bytes to try to read. - * @return An array of bytes. 0 length at eof. - */ - public byte [] readInput(String ticket, String handle, int count) - { - fAuthService.validate(ticket); - InputStream in = null; - synchronized (this) - { - in = fInputStreams.get(handle); - if (in == null) - { - throw new AVMException("Invalid Input Handle."); - } - fInputBusy.put(handle, true); - fInputLastAccessTimes.put(handle, System.currentTimeMillis()); - } - byte [] buff = new byte[count]; - try - { - int read = in.read(buff); - if (read == -1) - { - read = 0; - } - if (read != count) - { - byte [] newBuff = new byte[read]; - for (int i = 0; i < read; i++) - { - newBuff[i] = buff[i]; - } - return newBuff; - } - return buff; - } - catch (IOException e) - { - throw new AVMException("I/O Error."); - } - finally - { - synchronized (this) - { - fInputBusy.put(handle, false); - } - } - } - - /** - * Close an input stream. Server side input streams are - * timer limited, ie, they will be automatically closed - * after a given idle time. However, be nice, and close - * handles when you're done. - * @param handle The opaque handle to the server side stream. - */ - public synchronized void closeInputHandle(String ticket, String handle) - { - fAuthService.validate(ticket); - InputStream in = fInputStreams.get(handle); - if (in != null) - { - try - { - in.close(); - } - catch (IOException e) - { - // Do nothing. - } - fInputStreams.remove(handle); - fInputLastAccessTimes.remove(handle); - fInputBusy.remove(handle); - } - } - - /** - * Get an opaque handle to a server side output stream. - * @param path The path to the existing file. - * @return An opaque handle. - */ - public String getOutputHandle(String ticket, String path) - { - fAuthService.validate(ticket); - OutputStream out = fAVMService.getFileOutputStream(path); - String handle = GUID.generate(); - synchronized (this) - { - fOutputStreams.put(handle, out); - fOutputLastAccessTimes.put(handle, System.currentTimeMillis()); - fOutputBusy.put(handle, false); - } - return handle; - } - - /** - * Write count bytes from buffer buff - * starting at offset offset in buff - * @param handle The opaque handle to the server side output stream. - * @param buff The data buffer. - * @param offset The offset within the buffer. - * @param count The number of bytes to write. - */ - public void writeOutput(String ticket, String handle, byte [] buff, int count) - { - fAuthService.validate(ticket); - OutputStream out = null; - synchronized (this) - { - out = fOutputStreams.get(handle); - if (out == null) - { - throw new AVMException("Invalid Output Handle."); - } - fOutputBusy.put(handle, true); - fOutputLastAccessTimes.put(handle, System.currentTimeMillis()); - } - try - { - out.write(buff, 0, count); - } - catch (IOException e) - { - throw new AVMException("I/O Errror."); - } - finally - { - synchronized (this) - { - fOutputBusy.put(handle, false); - } - } - } - - /** - * Close the server side output stream designated by the handle. - * @param handle The handle to the server side output stream. - */ - public synchronized void closeOutputHandle(String ticket, String handle) - { - fAuthService.validate(ticket); - OutputStream out = fOutputStreams.get(handle); - if (out != null) - { - try - { - out.close(); - } - catch (IOException e) - { - // Do nothing. - } - fOutputStreams.remove(handle); - fOutputLastAccessTimes.remove(handle); - fOutputBusy.remove(handle); - } - } - - /** - * Get a listing of a directories direct contents. - * @param version The version to look under. - * @param path The path to the directory. - * @return A sorted listing. - */ - public SortedMap - getDirectoryListingDirect(String ticket, int version, String path) - { - fAuthService.validate(ticket); - return fAVMService.getDirectoryListingDirect(version, path); - } - - /** - * Get a listing of a directory. - * @param version The version to look under. - * @param path The path to the directory. - * @return A sorted listing. - */ - public SortedMap - getDirectoryListing(String ticket, int version, String path) - { - fAuthService.validate(ticket); - return fAVMService.getDirectoryListing(version, path); - } - - /** - * Get a directory listing from a node descriptor. - * @param dir The directory node descriptor. - * @return A sorted listing. - */ - public SortedMap - getDirectoryListing(String ticket, AVMNodeDescriptor dir) - { - fAuthService.validate(ticket); - return fAVMService.getDirectoryListing(dir); - } - - /** - * Get the names of nodes that have been deleted in a directory. - * @param version The version to look under. - * @param path The path to the directory. - * @return A list of deleted names. - */ - public List getDeleted(String ticket, int version, String path) - { - fAuthService.validate(ticket); - return fAVMService.getDeleted(version, path); - } - - /** - * Create a file and return a handle to an output stream. - * @param path The path to the file. - * @param name The name of the file to create. - * @return An opaque handle to a server side output stream. - */ - public String createFile(String ticket, String path, String name) - { - fAuthService.validate(ticket); - OutputStream out = fAVMService.createFile(path, name); - String handle = GUID.generate(); - synchronized (this) - { - fOutputStreams.put(handle, out); - fOutputLastAccessTimes.put(handle, System.currentTimeMillis()); - fOutputBusy.put(handle, false); - } - return handle; - } - - /** - * Create a directory. - * @param path The path to the containing directory. - * @param name The name for the new directory. - */ - public void createDirectory(String ticket, String path, String name) - { - fAuthService.validate(ticket); - fAVMService.createDirectory(path, name); - } - - /** - * Create a new layered file. - * @param targetPath The path that is targeted. - * @param parent The path to the parent directory. - * @param name The name for the new file. - */ - public void createLayeredFile(String ticket, String targetPath, String parent, String name) - { - fAuthService.validate(ticket); - fAVMService.createLayeredFile(targetPath, parent, name); - } - - /** - * Create a layered directory. - * @param targetPath The path that is targeted. - * @param parent The parent directory. - * @param name The name of the new directory. - */ - public void createLayeredDirectory(String ticket, String targetPath, String parent, String name) - { - fAuthService.validate(ticket); - fAVMService.createLayeredDirectory(targetPath, parent, name); - } - - /** - * Set a layered directory node to point at a different target. - * @param path The path to the layered directory node. - * @param target The new target. - */ - public void retargetLayeredDirectory(String ticket, String path, String target) - { - fAuthService.validate(ticket); - fAVMService.retargetLayeredDirectory(path, target); - } - - /** - * Create a new AVMStore. - * @param name The name to give the new store. - */ - public void createStore(String ticket, String name) - { - fAuthService.validate(ticket); - fAVMService.createStore(name); - } - - /** - * Create a new branch. - * @param version The version to look under for the source node. - * @param srcPath The path to the source node. - * @param dstPath The path to the destination directory. - * @param name The name of the new branch. - */ - public void createBranch(String ticket, int version, String srcPath, String dstPath, String name) - { - fAuthService.validate(ticket); - fAVMService.createBranch(version, srcPath, dstPath, name); - } - - /** - * Remove a node. - * @param parent The path to the parent directory. - * @param name The name of the node to remove. - */ - public void removeNode(String ticket, String parent, String name) - { - fAuthService.validate(ticket); - fAVMService.removeNode(parent, name); - } - - /** - * Rename a node. - * @param srcParent The source directory path. - * @param srcName The source node name. - * @param dstParent The destination directory path. - * @param dstName The destination name for the node. - */ - public void rename(String ticket, String srcParent, String srcName, String dstParent, String dstName) - { - fAuthService.validate(ticket); - fAVMService.rename(srcParent, srcName, dstParent, dstName); - } - - /** - * Uncover a name in a layered directory. - * @param dirPath The path to the directory. - * @param name The name to uncover. - */ - public void uncover(String ticket, String dirPath, String name) - { - fAuthService.validate(ticket); - fAVMService.uncover(dirPath, name); - } - - /** - * Get the latest version id of the given AVMStore. - * @param storeName The name of the AVMStore. - * @return The latest version id. - */ - public int getNextVersionID(String ticket, String storeName) - { - fAuthService.validate(ticket); - return fAVMService.getNextVersionID(storeName); - } - - /** - * Get the id of the latest version snapshot. - * @param storeName The store name. - * @return The id. - */ - public int getLatestSnapshotID(String ticket, String storeName) - { - return fAVMService.getLatestSnapshotID(storeName); - } - - /** - * Snapshot an AVMStore. - * @param store The name of the AVMStore to snapshot. - * @return The version id of the new snapshot. - */ - public Map createSnapshot(String ticket, String store, String label, String comment) - { - fAuthService.validate(ticket); - return fAVMService.createSnapshot(store, label, comment); - } - - /** - * Get a List of all versions in a given store. - * @param name The name of the store. - * @return A List of VersionDescriptors. - */ - public List getStoreVersions(String ticket, String name) - { - fAuthService.validate(ticket); - return fAVMService.getStoreVersions(name); - } - - /** - * Get AVMStore versions between given dates. - * @param name The name of the store. - * @param from The date from which (inclusive). - * @param to The date to which (inclusive). - * @return A List of VersionDescriptors. - */ - public List getStoreVersions(String ticket, String name, Date from, Date to) - { - fAuthService.validate(ticket); - return fAVMService.getStoreVersions(name, from, to); - } - - /** - * Get a list of all AVM stores. - * @return A List of AVMStoreDescriptors. - */ - public List getStores(String ticket) - { - fAuthService.validate(ticket); - return fAVMService.getStores(); - } - - /** - * Get the descriptor for a given AVMStore. - * @param name The name of the store. - * @return An AVMStoreDescriptor. - */ - public AVMStoreDescriptor getStore(String ticket, String name) - { - fAuthService.validate(ticket); - return fAVMService.getStore(name); - } - - /** - * Get the specified root of the specified store. - * @param version The version number to fetch. - * @param name The name of the store. - * @return The AVMNodeDescriptor for the root. - */ - public AVMNodeDescriptor getStoreRoot(String ticket, int version, String name) - { - fAuthService.validate(ticket); - return fAVMService.getStoreRoot(version, name); - } - - /** - * Get a descriptor for the specified node. - * @param version The version to look under. - * @param path The path to the node. - * @return An AVMNodeDescriptor. - */ - public AVMNodeDescriptor lookup(String ticket, int version, String path) - { - fAuthService.validate(ticket); - return fAVMService.lookup(version, path); - } - - /** - * Lookup a node identified by version ID and path; optionally, - * if the node is deleted, its descriptor can still - * be retrieved. - * - * @param version The version ID to look under. - * @param path The simple absolute path to the parent directory. - * @param includeDeleted Whether to allow a deleted node to be retrieved - * @return An AVMNodeDescriptor, or null if the version does not exist. - */ - public AVMNodeDescriptor lookup(String ticket, int version, String path, boolean includeDeleted) - { - fAuthService.validate(ticket); - return fAVMService.lookup(version, path, includeDeleted); - } - - - /** - * Get a descriptor for the specified node. - * @param dir The descriptor for the directory node. - * @param name The name of the node to lookup. - * @return An AVMNodeDescriptor. - */ - public AVMNodeDescriptor lookup(String ticket, AVMNodeDescriptor dir, String name) - { - fAuthService.validate(ticket); - return fAVMService.lookup(dir, name); - } - - /** - * Lookup a node identified by the directory that contains it, and its name; - * optionally, the lookup can retrive the descriptor of a node even if - * it has been deleted from its containing directory. - * - * @param dir The descriptor for the directory node. - * @param name The name to lookup. - * @param includeDeleted Whether to allow a deleted node to be retrieved via the lookup - * @return The descriptor for the child, null if the child doesn't exist. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public AVMNodeDescriptor lookup(String ticket, AVMNodeDescriptor dir, String name, boolean includeDeleted) - { - fAuthService.validate(ticket); - return fAVMService.lookup(dir, name, includeDeleted); - } - - - /** - * Get the indirection path for a node. - * @param version The version to look under. - * @param path The path to the node. - * @return The indirection path/target. - */ - public String getIndirectionPath(String ticket, int version, String path) - { - fAuthService.validate(ticket); - return fAVMService.getIndirectionPath(version, path); - } - - /** - * Purge an AVMStore. - * @param name The name of the store to purge. - */ - public void purgeStore(String ticket, String name) - { - fAuthService.validate(ticket); - fAVMService.purgeStore(name); - } - - /** - * Purge a given version from a given store. - * @param version The version id. - * @param name The name of the store. - */ - public void purgeVersion(String ticket, int version, String name) - { - fAuthService.validate(ticket); - fAVMService.purgeVersion(version, name); - } - - /** - * Turn a directory into a primary indirection node. - * @param path The path to the directory. - */ - public void makePrimary(String ticket, String path) - { - fAuthService.validate(ticket); - fAVMService.makePrimary(path); - } - - /** - * Get a list of ancestors of a node. - * @param desc The descriptor of the node whose history is to be fetched. - * @param count The maximum number of ancestors that will be returned. - * @return A List of descriptors for ancestors starting most recent first. - */ - public List getHistory(String ticket, AVMNodeDescriptor desc, int count) - { - fAuthService.validate(ticket); - return fAVMService.getHistory(desc, count); - } - - /** - * Turn on or off a directory's opacity. - * @param path The path to the directory. - * @param opacity Whether the directory should be opaque or not. - */ - public void setOpacity(String ticket, String path, boolean opacity) - { - fAuthService.validate(ticket); - fAVMService.setOpacity(path, opacity); - } - - /** - * Get the most recent common ancestor of two nodes. - * @param left One node. - * @param right The other node. - * @return The common ancestor. - */ - public AVMNodeDescriptor getCommonAncestor(String ticket, AVMNodeDescriptor left, AVMNodeDescriptor right) - { - fAuthService.validate(ticket); - return fAVMService.getCommonAncestor(left, right); - } - - /** - * Get layering information about a path. - * @param version The version to look under. - * @param path The path to the node. - * @return A LayeringDescriptor. - */ - public LayeringDescriptor getLayeringInfo(String ticket, int version, String path) - { - fAuthService.validate(ticket); - return fAVMService.getLayeringInfo(version, path); - } - - /** - * 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 give the property. - */ - public void setNodeProperty(String ticket, String path, QName name, PropertyValue value) - { - fAuthService.validate(ticket); - fAVMService.setNodeProperty(path, name, value); - } - - /** - * Set a group of properties on a node. - * @param path The path to the node. - * @param properties A Map of QNames to PropertyValues to set. - */ - public void setNodeProperties(String ticket, String path, Map properties) - { - fAuthService.validate(ticket); - fAVMService.setNodeProperties(path, properties); - } - - /** - * Get the value of a node property. - * @param version The version to look under. - * @param path The path to the node. - * @param name The name of the property. - * @return A PropertyValue. - */ - public PropertyValue getNodeProperty(String ticket, int version, String path, QName name) - { - fAuthService.validate(ticket); - return fAVMService.getNodeProperty(version, path, name); - } - - /** - * Get all properties of a node. - * @param version The version. - * @param path The path to the node. - * @return A Map of QNames to PropertyValues. - */ - public Map getNodeProperties(String ticket, int version, String path) - { - fAuthService.validate(ticket); - return fAVMService.getNodeProperties(version, path); - } - - /** - * Delete a property from a node. - * @param path The path to the node. - * @param name The name of the property. - */ - public void deleteNodeProperty(String ticket, String path, QName name) - { - fAuthService.validate(ticket); - fAVMService.deleteNodeProperty(path, name); - } - - /** - * Delete all properties from a node. - * @param path The path to the node. - */ - public void deleteNodeProperties(String ticket, String path) - { - fAuthService.validate(ticket); - fAVMService.deleteNodeProperties(path); - } - - /** - * Set a property on a store. - * @param store The name of the store. - * @param name The name of the property to set. - * @param value The value of the property to set. - */ - public void setStoreProperty(String ticket, String store, QName name, PropertyValue value) - { - fAuthService.validate(ticket); - fAVMService.setStoreProperty(store, name, value); - } - - /** - * Set a group of properties on a store. - * @param store The name of the store. - * @param props A Map of QNames to PropertyValues to set. - */ - public void setStoreProperties(String ticket, String store, Map props) - { - fAuthService.validate(ticket); - fAVMService.setStoreProperties(store, props); - } - - /** - * Get a property from a store. - * @param store The name of the store. - * @param name The name of the property. - * @return A PropertyValue. - */ - public PropertyValue getStoreProperty(String ticket, String store, QName name) - { - fAuthService.validate(ticket); - return fAVMService.getStoreProperty(store, name); - } - - /** - * Query a store for keys that match a pattern. - * @param store The store name. - * @param keyPattern The sql 'like' pattern. - * @return A Map of keys to values. - */ - public Map queryStorePropertyKey(String ticket, String store, QName keyPattern) - { - fAuthService.validate(ticket); - return fAVMService.queryStorePropertyKey(store, keyPattern); - } - - /** - * Query all stores for keys that match a pattern. - * @param keyPattern The sql 'like' pattern. - * @return A Map of store names to Maps of matching keys to values. - */ - public Map> queryStoresPropertyKey(String ticket, QName keyPattern) - { - fAuthService.validate(ticket); - return fAVMService.queryStoresPropertyKeys(keyPattern); - } - - /** - * Get all the properties on a store. - * @param store The name of the store. - * @return A Map of QNames to PropertyValues. - */ - public Map getStoreProperties(String ticket, String store) - { - fAuthService.validate(ticket); - return fAVMService.getStoreProperties(store); - } - - /** - * Delete a property from a store. - * @param store The name of the store. - * @param name The name of the property. - */ - public void deleteStoreProperty(String ticket, String store, QName name) - { - fAuthService.validate(ticket); - fAVMService.deleteStoreProperty(store, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemoteTransport#renameStore(java.lang.String, java.lang.String, java.lang.String) - */ - public void renameStore(String ticket, String sourceName, String destName) - { - fAuthService.validate(ticket); - fAVMService.renameStore(sourceName, destName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemoteTransport#addAspect(java.lang.String, java.lang.String, org.alfresco.service.namespace.QName) - */ - public void addAspect(String ticket, String path, QName aspectName) - { - fAuthService.validate(ticket); - fAVMService.addAspect(path, aspectName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemoteTransport#getAspects(java.lang.String, int, java.lang.String) - */ - public Set getAspects(String ticket, int version, String path) - { - fAuthService.validate(ticket); - return fAVMService.getAspects(version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemoteTransport#hasAspect(java.lang.String, int, java.lang.String, org.alfresco.service.namespace.QName) - */ - public boolean hasAspect(String ticket, int version, String path, QName aspectName) - { - fAuthService.validate(ticket); - return fAVMService.hasAspect(version, path, aspectName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemoteTransport#removeAspect(java.lang.String, java.lang.String, org.alfresco.service.namespace.QName) - */ - public void removeAspect(String ticket, String path, QName aspectName) - { - fAuthService.validate(ticket); - fAVMService.removeAspect(path, aspectName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemoteTransport#revert(java.lang.String, java.lang.String, org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public void revert(String ticket, String path, AVMNodeDescriptor toRevertTo) - { - fAuthService.validate(ticket); - fAVMService.revert(path, toRevertTo); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemoteTransport#getAPath(java.lang.String, org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public Pair getAPath(String ticket, AVMNodeDescriptor desc) - { - fAuthService.validate(ticket); - return fAVMService.getAPath(desc); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemoteTransport#setGuid(java.lang.String, java.lang.String, java.lang.String) - */ - public void setGuid(String ticket, String path, String guid) - { - fAuthService.validate(ticket); - fAVMService.setGuid(path, guid); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemoteTransport#setEncoding(java.lang.String, java.lang.String, java.lang.String) - */ - public void setEncoding(String ticket, String path, String encoding) - { - fAuthService.validate(ticket); - fAVMService.setEncoding(path, encoding); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemoteTransport#setMimeType(java.lang.String, java.lang.String, java.lang.String) - */ - public void setMimeType(String ticket, String path, String mimeType) - { - fAuthService.validate(ticket); - fAVMService.setMimeType(path, mimeType); - } -} diff --git a/source/java/org/alfresco/repo/avm/AVMServiceNOOPImpl.java b/source/java/org/alfresco/repo/avm/AVMServiceNOOPImpl.java deleted file mode 100644 index 60f99d948d..0000000000 --- a/source/java/org/alfresco/repo/avm/AVMServiceNOOPImpl.java +++ /dev/null @@ -1,735 +0,0 @@ -/* - * 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 . */ - -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 getDirectoryListing( - int version, String path) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public SortedMap getDirectoryListingDirect( - int version, String path) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public SortedMap getDirectoryListing( - AVMNodeDescriptor dir) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public SortedMap getDirectoryListing( - AVMNodeDescriptor dir, String childNamePattern) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public List 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 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 createSnapshot(String store, String tag, - String description) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public List getStoreVersions(String name) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public List getStoreVersions(String name, Date from, - Date to) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public List 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 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 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 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 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 props) - { - // TODO Auto-generated method stub - - } - - @Override - public PropertyValue getStoreProperty(String store, QName name) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map getStoreProperties(String store) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map 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 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> queryStoresPropertyKeys( - QName keyPattern) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public void createDirectory(String path, String name, List aspects, - Map 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 aspects, Map properties) - { - // TODO Auto-generated method stub - - } - - @Override - public SortedMap 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 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 getDirectoryListingDirect( - AVMNodeDescriptor dir, boolean includeDeleted) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public SortedMap 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> getPaths(AVMNodeDescriptor desc) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public List> getHeadPaths(AVMNodeDescriptor desc) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public List> getPathsInStoreHead( - AVMNodeDescriptor desc, String store) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public List getPathsInStoreVersion(AVMNodeDescriptor desc, - String store, int version) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map getNodeProperties(AVMNodeDescriptor desc) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public Set 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 getStoreVersionsFrom(String name, int version) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public List getStoreVersionsTo(String name, int version) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public List getStoreVersionsBetween(String name, - int startVersion, int endVersion) - { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/source/java/org/alfresco/repo/avm/AVMSyncServiceNOOPImpl.java b/source/java/org/alfresco/repo/avm/AVMSyncServiceNOOPImpl.java deleted file mode 100644 index 5e224508d5..0000000000 --- a/source/java/org/alfresco/repo/avm/AVMSyncServiceNOOPImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 . */ - -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 compare(int srcVersion, String srcPath, - int dstVersion, String dstPath, NameMatcher excluder) - { - // TODO Auto-generated method stub - return null; - } - - @Override - public List 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 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 - - } -} diff --git a/source/java/org/alfresco/repo/avm/AVMSyncServiceTransportImpl.java b/source/java/org/alfresco/repo/avm/AVMSyncServiceTransportImpl.java deleted file mode 100644 index a05e8c5fbd..0000000000 --- a/source/java/org/alfresco/repo/avm/AVMSyncServiceTransportImpl.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2005-2012 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 . - */ -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.service.cmr.remote.AVMSyncServiceTransport; -import org.alfresco.service.cmr.security.AuthenticationService; -import org.alfresco.util.NameMatcher; - -/** - * Server side implementation of the remote wrapper of AVMSyncService. - * @author britt - */ -public class AVMSyncServiceTransportImpl implements AVMSyncServiceTransport -{ - /** - * Reference to the AVMSyncService instance. - */ - private AVMSyncService fSyncService; - - /** - * Reference to the AuthenticationService instance. - */ - private AuthenticationService fAuthenticationService; - - /** - * Default constructor. - */ - public AVMSyncServiceTransportImpl() - { - } - - public void setAvmSyncService(AVMSyncService service) - { - fSyncService = service; - } - - public void setAuthenticationService(AuthenticationService service) - { - fAuthenticationService = service; - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avmsync.AVMSyncServiceTransport#compare(java.lang.String, int, java.lang.String, int, java.lang.String) - */ - public List compare(String ticket, int srcVersion, - String srcPath, int dstVersion, String dstPath, NameMatcher excluder) - { - fAuthenticationService.validate(ticket); - return fSyncService.compare(srcVersion, srcPath, dstVersion, dstPath, excluder); - } - - @Override - public List compare(String ticket, int srcVersion, String srcPath, int dstVersion, String dstPath, NameMatcher excluder, boolean expandDirs) - { - fAuthenticationService.validate(ticket); - return fSyncService.compare(srcVersion, srcPath, dstVersion, dstPath, excluder, expandDirs); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avmsync.AVMSyncServiceTransport#flatten(java.lang.String, java.lang.String, java.lang.String) - */ - public void flatten(String ticket, String layerPath, String underlyingPath) - { - fAuthenticationService.validate(ticket); - fSyncService.flatten(layerPath, underlyingPath); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avmsync.AVMSyncServiceTransport#resetLayer(java.lang.String, java.lang.String) - */ - public void resetLayer(String ticket, String layerPath) - { - fAuthenticationService.validate(ticket); - fSyncService.resetLayer(layerPath); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avmsync.AVMSyncServiceTransport#update(java.lang.String, java.util.List, boolean, boolean, boolean, boolean, java.lang.String, java.lang.String) - */ - public void update(String ticket, List diffList, NameMatcher excluder, - boolean ignoreConflicts, boolean ignoreOlder, - boolean overrideConflicts, boolean overrideOlder, String tag, - String description) - { - fAuthenticationService.validate(ticket); - fSyncService.update(diffList, excluder, ignoreConflicts, ignoreOlder, overrideConflicts, overrideOlder, tag, description); - } -} diff --git a/source/java/org/alfresco/repo/avm/AvmMetadataExtracter.java b/source/java/org/alfresco/repo/avm/AvmMetadataExtracter.java deleted file mode 100644 index 9a74c36017..0000000000 --- a/source/java/org/alfresco/repo/avm/AvmMetadataExtracter.java +++ /dev/null @@ -1,92 +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 . - */ -package org.alfresco.repo.avm; - -import org.alfresco.repo.action.executer.ContentMetadataExtracter; -import org.alfresco.repo.content.ContentServicePolicies; -import org.alfresco.repo.policy.JavaBehaviour; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - -/** - * A component that listens for changes to the content - * - * @since 2.1 - * @author Derek Hulley - */ -public class AvmMetadataExtracter - implements ContentServicePolicies.OnContentUpdatePolicy -{ - /** the component to register the behaviour with */ - private PolicyComponent policyComponent; - /** the action that will do the work */ - private ContentMetadataExtracter extracterAction; - - /** - * @param policyComponent used for registrations - */ - public void setPolicyComponent(PolicyComponent policyComponent) - { - this.policyComponent = policyComponent; - } - - /** - * @param extracterAction the action that will perform the actual extraction - */ - public void setExtracterAction(ContentMetadataExtracter extracterAction) - { - this.extracterAction = extracterAction; - } - - /** - * Registers the policy behaviour methods - */ - public void init() - { - policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onContentUpdate"), - this, - new JavaBehaviour(this, "onContentUpdate")); - } - - /** - * When the content changes, the metadata is extracted. - */ - public void onContentUpdate(NodeRef nodeRef, boolean newContent) - { - /* - * The use of the action here is a supreme hack. The code within the action is - * what we are after and it would be a shame to duplicate it. Also, it is the - * intention that rules will eventually work against AVM, making this class - * obsolete. - */ - - // Ignore everything non-AVM - if (!nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) - { - return; - } - - // We extract the content whether it is new or not - extracterAction.executeImpl(null, nodeRef); - } -} diff --git a/source/java/org/alfresco/repo/avm/BasicAttributes.java b/source/java/org/alfresco/repo/avm/BasicAttributes.java deleted file mode 100644 index edc99b0f96..0000000000 --- a/source/java/org/alfresco/repo/avm/BasicAttributes.java +++ /dev/null @@ -1,98 +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 . - */ -package org.alfresco.repo.avm; - -/** - * Ownership, timestamps, later perhaps ACLs - * @author britt - */ -public interface BasicAttributes -{ - /** - * Set the creator of the node. - * @param creator The creator to set. - */ - public void setCreator(String creator); - - /** - * Get the creator of the node. - * @return The creator. - */ - public String getCreator(); - - /** - * Set the owner of the node. - * @param owner The owner to set. - */ - public void setOwner(String owner); - - /** - * Get the owner of the node. - * @return The owner. - */ - public String getOwner(); - - /** - * Set the last modifier of the node. - * @param lastModifier - */ - public void setLastModifier(String lastModifier); - - /** - * Get the last modifier of the node. - * @return The last modifier. - */ - public String getLastModifier(); - - /** - * Set the create date. - * @param createDate The date to set. - */ - public void setCreateDate(long createDate); - - /** - * Get the create date. - * @return The create date. - */ - public long getCreateDate(); - - /** - * Set the modification date. - * @param modDate The date to set. - */ - public void setModDate(long modDate); - - /** - * Get the modification date. - * @return The modification date. - */ - public long getModDate(); - - /** - * Set the access date of the node. - * @param accessDate The access date. - */ - public void setAccessDate(long accessDate); - - /** - * Get the access date of the node. - * @return The access date. - */ - public long getAccessDate(); -} diff --git a/source/java/org/alfresco/repo/avm/BasicAttributesImpl.java b/source/java/org/alfresco/repo/avm/BasicAttributesImpl.java deleted file mode 100644 index 5418aef953..0000000000 --- a/source/java/org/alfresco/repo/avm/BasicAttributesImpl.java +++ /dev/null @@ -1,214 +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 . */ -package org.alfresco.repo.avm; - -import java.io.Serializable; - - -/** - * Implementation of the BasicAttributesBean. - * @author britt - */ -public class BasicAttributesImpl implements BasicAttributes, Serializable -{ - private static final long serialVersionUID = -3796354564923670005L; - - /** - * The creator. - */ - private String fCreator; - - /** - * The owner. - */ - private String fOwner; - - /** - * The last modifier. - */ - private String fLastModifier; - - /** - * The creation date. - */ - private long fCreateDate; - - /** - * The modification date. - */ - private long fModDate; - - /** - * The access date. - */ - private long fAccessDate; - - /** - * Default constructor. - */ - public BasicAttributesImpl() - { - } - - /** - * A Copy constructor. - * @param other - */ - public BasicAttributesImpl(BasicAttributes other) - { - fCreator = other.getCreator(); - fOwner = other.getOwner(); - fLastModifier = other.getLastModifier(); - fCreateDate = other.getCreateDate(); - fModDate = other.getModDate(); - fAccessDate = other.getAccessDate(); - } - - /** - * Fill in the blanks constructor. - * @param creator - * @param owner - * @param modifier - * @param createDate - * @param modDate - * @param accessDate - */ - public BasicAttributesImpl(String creator, - String owner, - String modifier, - long createDate, - long modDate, - long accessDate) - { - fCreator = creator; - fOwner = owner; - fLastModifier = modifier; - fCreateDate = createDate; - fModDate = modDate; - fAccessDate = accessDate; - } - - /** - * Set the creator. - * @param creator - */ - public void setCreator(String creator) - { - fCreator = creator; - } - - /** - * Get the creator. - * @return The creator. - */ - public String getCreator() - { - return fCreator; - } - - /** - * Set the owner. - * @param owner - */ - public void setOwner(String owner) - { - fOwner = owner; - } - - /** - * Get the owner. - * @return The owner. - */ - public String getOwner() - { - return fOwner; - } - - /** - * Set the last modifier. - * @param lastModifier - */ - public void setLastModifier(String lastModifier) - { - fLastModifier = lastModifier; - } - - /** - * Get the last modifier. - * @return The last modifier. - */ - public String getLastModifier() - { - return fLastModifier; - } - - /** - * Set the create date. - * @param createDate - */ - public void setCreateDate(long createDate) - { - fCreateDate = createDate; - } - - /** - * Get the create date. - * @return The create date. - */ - public long getCreateDate() - { - return fCreateDate; - } - - /** - * Set the modification date. - * @param modDate - */ - public void setModDate(long modDate) - { - fModDate = modDate; - } - - /** - * Get the modification date. - * @return modDate - */ - public long getModDate() - { - return fModDate; - } - - // TODO Do we want this? - /** - * Set the access date. - * @param accessDate - */ - public void setAccessDate(long accessDate) - { - fAccessDate = accessDate; - } - - /** - * Get the access date. - * @return The access date. - */ - public long getAccessDate() - { - return fAccessDate; - } -} diff --git a/source/java/org/alfresco/repo/avm/CreateStoreCallback.java b/source/java/org/alfresco/repo/avm/CreateStoreCallback.java deleted file mode 100644 index a949e86ca0..0000000000 --- a/source/java/org/alfresco/repo/avm/CreateStoreCallback.java +++ /dev/null @@ -1,33 +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 . - */ -package org.alfresco.repo.avm; - -/** - * Interface for listeners to new store events. - * @author britt - */ -public interface CreateStoreCallback -{ - /** - * A new store has been created. - * @param storeName The name of the new store. - */ - public void storeCreated(String storeName); -} - diff --git a/source/java/org/alfresco/repo/avm/CreateStoreTxnListener.java b/source/java/org/alfresco/repo/avm/CreateStoreTxnListener.java deleted file mode 100644 index dc56ef74ee..0000000000 --- a/source/java/org/alfresco/repo/avm/CreateStoreTxnListener.java +++ /dev/null @@ -1,107 +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 . - */ -package org.alfresco.repo.avm; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.repo.transaction.TransactionListenerAdapter; - -/** - * Transaction listener for firing create store events. - * @author britt - */ -public class CreateStoreTxnListener extends TransactionListenerAdapter -{ - /** - * Storage for stores created in a transaction. - */ - private ThreadLocal> fCreatedStores; - - /** - * Callbacks to invoke on commit. - */ - private List fCallbacks; - - /** - * Default constructor. - */ - public CreateStoreTxnListener() - { - fCreatedStores = new ThreadLocal>(); - fCallbacks = new ArrayList(); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterCommit() - */ - @Override - public void afterCommit() - { - List created = fCreatedStores.get(); - if (created != null) - { - for (String name : created) - { - synchronized (this) - { - for (CreateStoreCallback cb : fCallbacks) - { - cb.storeCreated(name); - } - } - } - fCreatedStores.set(null); - } - } - - /* (non-Javadoc) - * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterRollback() - */ - @Override - public void afterRollback() - { - fCreatedStores.set(null); - } - - /** - * During the transaction somebody is responsible for - * calling this. - * @param storeName The name of the store that has been created. - */ - public void storeCreated(String storeName) - { - List created = fCreatedStores.get(); - if (created == null) - { - created = new ArrayList(); - fCreatedStores.set(created); - } - created.add(storeName); - } - - /** - * Register a callback. - * @param cb The callback. - */ - public synchronized void addCallback(CreateStoreCallback cb) - { - fCallbacks.add(cb); - } -} diff --git a/source/java/org/alfresco/repo/avm/CreateVersionCallback.java b/source/java/org/alfresco/repo/avm/CreateVersionCallback.java deleted file mode 100644 index 121f1a10b6..0000000000 --- a/source/java/org/alfresco/repo/avm/CreateVersionCallback.java +++ /dev/null @@ -1,33 +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 . - */ -package org.alfresco.repo.avm; - -/** - * Callback interface for those interested in new version creation. - * @author britt - */ -public interface CreateVersionCallback -{ - /** - * A version of a store has been created. - * @param storeName The name of the store in which a new version has been created. - * @param versionID The version id of the new version. - */ - public void versionCreated(String storeName, int versionID); -} diff --git a/source/java/org/alfresco/repo/avm/CreateVersionTxnListener.java b/source/java/org/alfresco/repo/avm/CreateVersionTxnListener.java deleted file mode 100644 index 8fee684fbd..0000000000 --- a/source/java/org/alfresco/repo/avm/CreateVersionTxnListener.java +++ /dev/null @@ -1,109 +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 . - */ -package org.alfresco.repo.avm; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.repo.transaction.TransactionListenerAdapter; -import org.alfresco.util.Pair; - -/** - * Transaction listener that fires create version events. - * @author britt - */ -public class CreateVersionTxnListener extends TransactionListenerAdapter -{ - /** - * Storage for versions created in a transaction. - */ - private ThreadLocal>> fCreatedVersions; - - /** - * Callbacks to invoke on commit. - */ - private List fCallbacks; - - /** - * Default constructor. - */ - public CreateVersionTxnListener() - { - fCreatedVersions = new ThreadLocal>>(); - fCallbacks = new ArrayList(); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterCommit() - */ - @Override - public void afterCommit() - { - List> created = fCreatedVersions.get(); - if (created != null) - { - for (Pair version : created) - { - synchronized (this) - { - for (CreateVersionCallback cb : fCallbacks) - { - cb.versionCreated(version.getFirst(), version.getSecond()); - } - } - } - fCreatedVersions.set(null); - } - } - - /* (non-Javadoc) - * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterRollback() - */ - @Override - public void afterRollback() - { - fCreatedVersions.set(null); - } - - /** - * During the transaction somebody is responsible for - * calling this. - * @param storeName The name of the store that just created a new version - * @param versionID The id of the new version. - */ - public void versionCreated(String storeName, int versionID) - { - List> created = fCreatedVersions.get(); - if (created == null) - { - created = new ArrayList>(); - fCreatedVersions.set(created); - } - created.add(new Pair(storeName, versionID)); - } - - /** - * Register a callback. - * @param cb The callback. - */ - public synchronized void addCallback(CreateVersionCallback cb) - { - fCallbacks.add(cb); - } -} diff --git a/source/java/org/alfresco/repo/avm/LayeredFolderType.java b/source/java/org/alfresco/repo/avm/LayeredFolderType.java deleted file mode 100644 index e3d2d48871..0000000000 --- a/source/java/org/alfresco/repo/avm/LayeredFolderType.java +++ /dev/null @@ -1,332 +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 . */ - -package org.alfresco.repo.avm; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.WCMAppModel; -import org.alfresco.model.WCMModel; -import org.alfresco.repo.avm.util.AVMUtil; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour; -import org.alfresco.repo.policy.JavaBehaviour; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.PropertyCheck; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Class defines policy behaviour for avmlayeredfolder type - * - * @author Ivan Rybnikov - * @since 4.0.2 - */ -public class LayeredFolderType implements NodeServicePolicies.OnMoveNodePolicy -{ - - private static Log logger = LogFactory.getLog(LayeredFolderType.class); - - /** The policy component */ - private PolicyComponent policyComponent; - - private FileFolderService fileFolderService; - - transient private AVMService avmService; - - /** Used to determine was the policy executed by Web-Client operation */ - private static ThreadLocal issuedByWebClient = new ThreadLocal(); - - /** Default max time allowed for the external issuers (CIFS, FTP) */ - private static long EXTERNAL_MAX_TIME = 2000; - - /** Max time allowed for the external issuers (CIFS, FTP). - * can be overridden by bean definition */ - private long maxTime = EXTERNAL_MAX_TIME; - - /** - * Initialize the avmlayeredfolder type policies - */ - - public void init() - { - if (maxTime < 0) - { - logger.warn( - "Unable to set 'wcm.rename.max.time.milliseconds' property value: '" + maxTime + " ms', " + - "set default value: '" + EXTERNAL_MAX_TIME + " ms'"); - setMaxTime(EXTERNAL_MAX_TIME); - } - PropertyCheck.mandatory(this, "policyComponent", policyComponent); - PropertyCheck.mandatory(this, "fileFolderService", fileFolderService); - PropertyCheck.mandatory(this, "avmService", avmService); - - this.policyComponent.bindClassBehaviour( - NodeServicePolicies.OnMoveNodePolicy.QNAME, - WCMModel.TYPE_AVM_LAYERED_FOLDER, - new JavaBehaviour(this, "onMoveNode", Behaviour.NotificationFrequency.EVERY_EVENT)); - } - - @Override - public synchronized void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) - { - // Storing start time - long startTime = System.currentTimeMillis(); - - NodeRef oldNodeRef = oldChildAssocRef.getChildRef(); - NodeRef newNodeRef = newChildAssocRef.getChildRef(); - String name = newChildAssocRef.getQName().getLocalName(); - - String[] splittedPath = AVMUtil.splitPath(AVMNodeConverter.ToAVMVersionPath(oldNodeRef).getSecond()); - // Get AVM store name - String avmStore = splittedPath[0]; - // Get stale path - String oldPathToReplace = splittedPath[1]; - // Create new path - String newPathToInsert = oldPathToReplace.substring(0, oldPathToReplace.lastIndexOf(AVMUtil.AVM_PATH_SEPARATOR_CHAR) + 1) + name; - - AVMNodeDescriptor desc = avmService.lookup(-1, AVMNodeConverter.ToAVMVersionPath(newNodeRef).getSecond()); - - if (desc.isDirectory()) - { - // Create the initial list of descriptors - List descriptors = new ArrayList(10); - descriptors.add(desc); - - // List of next level of descriptors - List nextDescriptors = new ArrayList(10); - - while (descriptors.size() != 0) - { - if (nextDescriptors != null) - { - nextDescriptors.clear(); - } - - for (AVMNodeDescriptor curDescriptor : descriptors) - { - Map listing = avmService.getDirectoryListing(curDescriptor); - if (listing.size() == 0) - { - continue; - } - - for (AVMNodeDescriptor descriptor : listing.values()) - { - if (descriptor.isDirectory()) - { - nextDescriptors.add(descriptor); - } - else if (descriptor.isFile()) - { - refreshPath(descriptor, avmStore, oldPathToReplace, newPathToInsert, startTime); - } - } - } - - descriptors.clear(); - if(nextDescriptors != null) - { - descriptors.addAll(nextDescriptors); - } - } - } - } - - private void refreshPath(AVMNodeDescriptor descriptor, String avmStore, String oldPathToReplace, String newPathToInsert, long startTime) - { - checkDuration(startTime); - String path = descriptor.getPath(); - - // If file is a form instance data refresh its paths to renditions - if (avmService.hasAspect(-1, path, WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) - { - refreshFormInstanceData(avmStore, oldPathToReplace, newPathToInsert, -1, path); - } - // If file is a rendition find its form instance data and refresh its paths to renditions - else if (avmService.hasAspect(-1, path, WCMAppModel.ASPECT_RENDITION)) - { - refreshRendition(avmStore, oldPathToReplace, newPathToInsert, -1, path); - } - } - - private void refreshFormInstanceData(String avmStore, String pathToReplace, String pathToInsert, int nodeVersion, String nodePath) - { - // Get all renditions - final PropertyValue pv = avmService.getNodeProperty(nodeVersion, nodePath, WCMAppModel.PROP_RENDITIONS); - - // Skip if there is no renditions. - if (pv == null) - return; - - final Collection renditionPaths = pv.getCollection(DataTypeDefinition.TEXT); - final List newRenditionPaths = new ArrayList(renditionPaths.size()); - - // Refresh all renditions paths - for (Serializable renditionPath : renditionPaths) - { - // Get old path which become stale - String oldPath = (String) renditionPath; - - // Refresh path to make it actual - String newPath = oldPath.replaceFirst(pathToReplace, pathToInsert); - newRenditionPaths.add(newPath); - - // Refresh property WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA of the rendition - // which is the path from rendition to the form instance data - String fullRenditionPath = avmStore + ":" + newPath; - String primaryFormInstanceData = avmService.getNodeProperty(-1, fullRenditionPath, WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA).getStringValue(); - primaryFormInstanceData = primaryFormInstanceData.replaceFirst(pathToReplace, pathToInsert); - avmService.setNodeProperty(fullRenditionPath, WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA, new PropertyValue(DataTypeDefinition.TEXT, - primaryFormInstanceData)); - } - avmService.setNodeProperty(nodePath, WCMAppModel.PROP_RENDITIONS, new PropertyValue(DataTypeDefinition.TEXT, (Serializable) newRenditionPaths)); - - } - - private void refreshRendition(String avmStore, String pathToReplace, String pathToInsert, int nodeVersion, String nodePath) - { - // Get form instance data - String primaryFormInstanceData = avmService.getNodeProperty(nodeVersion, nodePath, WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA).getStringValue(); - - // If form instance data is under the same folder skip it because it will be processed by refreshFormInstanceData() method - if (primaryFormInstanceData.startsWith(pathToReplace + AVMUtil.AVM_PATH_SEPARATOR_CHAR)) - return; - - // If form instance data contains new path skip it because it have already been processed - if (primaryFormInstanceData.startsWith(pathToInsert + AVMUtil.AVM_PATH_SEPARATOR_CHAR)) - return; - - // Get paths to renditions - final PropertyValue pv = avmService.getNodeProperty(-1, avmStore + ":" + primaryFormInstanceData, WCMAppModel.PROP_RENDITIONS); - - // Return if renditions list is empty - if (pv == null) - return; - - final Collection renditionPaths = pv.getCollection(DataTypeDefinition.TEXT); - final List newRenditionPaths = new ArrayList(renditionPaths.size()); - - // Refresh all paths - for (Serializable renditionPath : renditionPaths) - { - // Form instance data have already been refreshed - if (((String) renditionPath).startsWith(pathToInsert)) - return; - - String newPath = ((String) renditionPath).replaceFirst(pathToReplace, pathToInsert); - newRenditionPaths.add(newPath); - } - - avmService.setNodeProperty( - avmStore + ":" + primaryFormInstanceData, - WCMAppModel.PROP_RENDITIONS, - new PropertyValue(DataTypeDefinition.TEXT, (Serializable) newRenditionPaths)); - } - - /** - * Set the policy component - * - * @param policyComponent the policy component - */ - public void setPolicyComponent(PolicyComponent policyComponent) - { - this.policyComponent = policyComponent; - } - - /** - * Set the fileFolderService - * - * @param fileFolderService - */ - public void setFileFolderService(FileFolderService fileFolderService) - { - this.fileFolderService = fileFolderService; - } - - /** - * Set the avmService - * - * @param avmService - */ - public void setAvmService(AVMService avmService) - { - this.avmService = avmService; - } - - /** - * Checks policy duration. - * If policy was fired by the external calls (FTP, CIFS) - * and exceeds value set in wcm.rename.max.time.milliseconds exception is thrown. - * Default time is set to 2 seconds. - * - * @throws AlfrescoRuntimeException if operation exceeds max time duration - */ - private void checkDuration(long startTime) - { - if (!isIssuedByWebClient() && ((System.currentTimeMillis() - startTime) > maxTime)) - { - logger.warn("Operation exceeds max time duration and was aborted"); - throw new AlfrescoRuntimeException("Operation exceeds max time duration and was aborted"); - } - } - - /** - * Thread variable used to determine whether policy - * fired by Web-Client or by external issuers (FTP, CIFS) - * - * @param isWebClient - */ - public static void setIssuedByWebClient(Boolean isWebClient) - { - issuedByWebClient.set(isWebClient); - } - - /** - * Get the issuedByWebClient - * - * @return issuedByWebClient - */ - public static Boolean isIssuedByWebClient() - { - Boolean result = issuedByWebClient.get(); - return result == null ? Boolean.FALSE : result; - } - - /** - * Set the max time - * - * @param maxTime - */ - public void setMaxTime(long maxTime) - { - this.maxTime = maxTime; - } -} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/avm/LookupKey.java b/source/java/org/alfresco/repo/avm/LookupKey.java deleted file mode 100644 index 40f857bdcc..0000000000 --- a/source/java/org/alfresco/repo/avm/LookupKey.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.avm; - -import java.io.Serializable; - -import org.alfresco.repo.avm.util.SimplePath; - -/** - * This is the key by which Lookup's are retrieved from the cache. - * @author britt - */ -public class LookupKey implements Serializable -{ - private static final long serialVersionUID = 8471482833953423406L; - - /** - * The name of the store. - */ - private String fStoreName; - - /** - * The path being looked up. - */ - private SimplePath fPath; - - /** - * The version being looked up. - */ - private int fVersion; - - /** - * Whether the lookup is a write lookup. - */ - private boolean fWrite; - - /** - * Whether the lookup includes deleted nodes. - */ - private boolean fIncludeDeleted; - - /** - * Create one from whole cloth. - * @param version The version we're looking under. - * @param path The path. - * @param storeName The name of the store. - * @param write Whether this is a write lookup. - * @param includeDeleted Whether this lookup should include deleted items. - */ - public LookupKey(int version, - SimplePath path, - String storeName, - boolean write, - boolean includeDeleted) - { - fVersion = version; - fPath = path; - fStoreName = storeName; - fWrite = write; - fIncludeDeleted = includeDeleted; - } - - public LookupKey(LookupKey other) - { - fVersion = other.fVersion; - fPath = other.fPath; - fStoreName = other.fStoreName; - fWrite = other.fWrite; - fIncludeDeleted = other.fIncludeDeleted; - } - - /** - * Set the writeness of this key. - */ - public void setWrite(boolean write) - { - fWrite = write; - } - - /** - * Get the store name for this key. - * @return The store name. - */ - public String getStoreName() - { - return fStoreName; - } - - /** - * Is this a write lookup. - * @return Whether this is a write lookup. - */ - public boolean isWrite() - { - return fWrite; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (!(obj instanceof LookupKey)) - { - return false; - } - LookupKey o = (LookupKey)obj; - return fStoreName.equalsIgnoreCase(o.fStoreName) && - fVersion == o.fVersion && - fPath.equals(o.fPath) && - fWrite == o.fWrite && - fIncludeDeleted == o.fIncludeDeleted; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() - { - int hash = fStoreName.toLowerCase().hashCode(); - hash += fPath.hashCode(); - hash += fVersion; - hash += fWrite ? 1 : 0; - hash += fIncludeDeleted ? 1 : 0; - return hash; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() - { - return fStoreName + ":" + fPath + "-" + fVersion + "-" + fWrite + "-" + fIncludeDeleted; - } -} diff --git a/source/java/org/alfresco/repo/avm/MultiTAVMService.java b/source/java/org/alfresco/repo/avm/MultiTAVMService.java deleted file mode 100644 index 6137677782..0000000000 --- a/source/java/org/alfresco/repo/avm/MultiTAVMService.java +++ /dev/null @@ -1,1066 +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 . - */ - -package org.alfresco.repo.avm; - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.tenant.TenantService; -import org.alfresco.service.cmr.avm.AVMBadArgumentException; -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.EqualsHelper; -import org.alfresco.util.Pair; - -/** - * An MT-aware wrapper of AVMService - * - * @author janv - */ -public class MultiTAVMService implements AVMService -{ - private AVMService fService; - private TenantService tenantService; - - Boolean enabled = null; - - public void setAvmService(AVMService fService) - { - this.fService = fService; - } - - public void setTenantService(TenantService tenantService) - { - this.tenantService = tenantService; - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#addAspect(java.lang.String, org.alfresco.service.namespace.QName) - */ - public void addAspect(String path, QName aspectName) - { - fService.addAspect(getTenantPath(path), aspectName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#copy(int, java.lang.String, java.lang.String, java.lang.String) - */ - public void copy(int srcVersion, String srcPath, String dstPath, String name) - { - fService.copy(srcVersion, getTenantPath(srcPath), getTenantPath(dstPath), name); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#createBranch(int, java.lang.String, java.lang.String, java.lang.String) - */ - public void createBranch(int version, String srcPath, String dstPath, String name) - { - fService.createBranch(version, getTenantPath(srcPath), getTenantPath(dstPath), name); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#createDirectory(java.lang.String, java.lang.String) - */ - public void createDirectory(String path, String name) - { - fService.createDirectory(getTenantPath(path), name); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#createFile(java.lang.String, java.lang.String) - */ - public OutputStream createFile(String path, String name) - { - return fService.createFile(getTenantPath(path), name); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#createFile(java.lang.String, java.lang.String, java.io.InputStream) - */ - public void createFile(String path, String name, InputStream in) - { - fService.createFile(getTenantPath(path), name, in); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#createLayeredDirectory(java.lang.String, java.lang.String, java.lang.String) - */ - public void createLayeredDirectory(String targetPath, String parentPath, String name) - { - fService.createLayeredDirectory(getTenantPath(targetPath), getTenantPath(parentPath), name); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#createLayeredFile(java.lang.String, java.lang.String, java.lang.String) - */ - public void createLayeredFile(String targetPath, String parentPath, String name) - { - fService.createLayeredFile(getTenantPath(targetPath), getTenantPath(parentPath), name); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#createSnapshot(java.lang.String, java.lang.String, java.lang.String) - */ - public Map createSnapshot(String storeName, String tag, String description) - { - // TODO - return fService.createSnapshot(getTenantStoreName(storeName), tag, description); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#createStore(java.lang.String) - */ - public void createStore(String storeName) - { - fService.createStore(getTenantStoreName(storeName)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#createStore(java.lang.String, java.util.Map) - */ - public void createStore(String name, Map props) - { - fService.createStore(name, props); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#deleteNodeProperties(java.lang.String) - */ - public void deleteNodeProperties(String path) - { - fService.deleteNodeProperties(getTenantPath(path)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#deleteNodeProperty(java.lang.String, org.alfresco.service.namespace.QName) - */ - public void deleteNodeProperty(String path, QName name) - { - fService.deleteNodeProperty(getTenantPath(path), name); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#deleteStoreProperty(java.lang.String, org.alfresco.service.namespace.QName) - */ - public void deleteStoreProperty(String storeName, QName name) - { - fService.deleteStoreProperty(getTenantStoreName(storeName), name); - } - - public void updateLink(String parentPath, String name, AVMNodeDescriptor toLink) - { - fService.updateLink(getTenantPath(parentPath), name, toLink); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#forceCopy(java.lang.String) - */ - public AVMNodeDescriptor forceCopy(String path) - { - return getBaseNode(fService.forceCopy(getTenantPath(path))); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getAPath(org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public Pair getAPath(AVMNodeDescriptor desc) - { - return getBaseVPath(fService.getAPath(getTenantNode(desc))); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getPathsInStoreVersion(org.alfresco.service.cmr.avm.AVMNodeDescriptor, java.lang.String, int) - */ - public List getPathsInStoreVersion(AVMNodeDescriptor desc, String storeName, int version) - { - return getBasePaths(fService.getPathsInStoreVersion(getTenantNode(desc), getTenantStoreName(storeName), version)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getAspects(int, java.lang.String) - */ - public Set getAspects(int version, String path) - { - return fService.getAspects(version, getTenantPath(path)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getAspects(org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public Set getAspects(AVMNodeDescriptor desc) - { - return fService.getAspects(getTenantNode(desc)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getCommonAncestor(org.alfresco.service.cmr.avm.AVMNodeDescriptor, org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public AVMNodeDescriptor getCommonAncestor(AVMNodeDescriptor left, AVMNodeDescriptor right) - { - return getBaseNode(fService.getCommonAncestor(getTenantNode(left), getTenantNode(right))); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getContentDataForRead(int, java.lang.String) - */ - public ContentData getContentDataForRead(int version, String path) - { - return fService.getContentDataForRead(version, getTenantPath(path)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getContentDataForRead(org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public ContentData getContentDataForRead(AVMNodeDescriptor desc) - { - return fService.getContentDataForRead(getTenantNode(desc)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getContentDataForWrite(java.lang.String) - */ - public ContentData getContentDataForWrite(String path) - { - return fService.getContentDataForWrite(getTenantPath(path)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getContentReader(int, java.lang.String) - */ - public ContentReader getContentReader(int version, String path) - { - return fService.getContentReader(version, getTenantPath(path)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getContentWriter(java.lang.String, boolean) - */ - public ContentWriter getContentWriter(String path, boolean update) - { - return fService.getContentWriter(getTenantPath(path), update); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getDeleted(int, java.lang.String) - */ - public List getDeleted(int version, String path) - { - return fService.getDeleted(version, getTenantPath(path)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getDirectoryListing(int, java.lang.String) - */ - public SortedMap getDirectoryListing(int version, String path) - { - return getBaseNodes(fService.getDirectoryListing(version, getTenantPath(path))); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getDirectoryListing(int, java.lang.String, boolean) - */ - public SortedMap getDirectoryListing(int version, String path, boolean includeDeleted) - { - return getBaseNodes(fService.getDirectoryListing(version, getTenantPath(path), includeDeleted)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getDirectoryListing(org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public SortedMap getDirectoryListing(AVMNodeDescriptor dir) - { - return getBaseNodes(fService.getDirectoryListing(getTenantNode(dir))); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getDirectoryListing(org.alfresco.service.cmr.avm.AVMNodeDescriptor, boolean) - */ - public SortedMap getDirectoryListing(AVMNodeDescriptor dir, boolean includeDeleted) - { - return getBaseNodes(fService.getDirectoryListing(getTenantNode(dir), includeDeleted)); - } - - public SortedMap getDirectoryListing(AVMNodeDescriptor dir, String childNamePattern) - { - return getBaseNodes(fService.getDirectoryListing(getTenantNode(dir), childNamePattern)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getDirectoryListingArray(int, java.lang.String, boolean) - */ - public AVMNodeDescriptor[] getDirectoryListingArray(int version, String path, boolean includeDeleted) - { - return getBaseNodes(fService.getDirectoryListingArray(version, getTenantPath(path), includeDeleted)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getDirectoryListingArray(org.alfresco.service.cmr.avm.AVMNodeDescriptor, boolean) - */ - public AVMNodeDescriptor[] getDirectoryListingArray(AVMNodeDescriptor dir, boolean includeDeleted) - { - return getBaseNodes(fService.getDirectoryListingArray(getTenantNode(dir), includeDeleted)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getDirectoryListingDirect(int, java.lang.String) - */ - public SortedMap getDirectoryListingDirect(int version, String path) - { - return getBaseNodes(fService.getDirectoryListingDirect(version, getTenantPath(path))); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getDirectoryListingDirect(int, java.lang.String, boolean) - */ - public SortedMap getDirectoryListingDirect(int version, String path, boolean includeDeleted) - { - return getBaseNodes(fService.getDirectoryListingDirect(version, getTenantPath(path), includeDeleted)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getDirectoryListingDirect(org.alfresco.service.cmr.avm.AVMNodeDescriptor, boolean) - */ - public SortedMap getDirectoryListingDirect(AVMNodeDescriptor dir, boolean includeDeleted) - { - return getBaseNodes(fService.getDirectoryListingDirect(getTenantNode(dir), includeDeleted)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getFileInputStream(int, java.lang.String) - */ - public InputStream getFileInputStream(int version, String path) - { - return fService.getFileInputStream(version, getTenantPath(path)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getFileInputStream(org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public InputStream getFileInputStream(AVMNodeDescriptor desc) - { - return fService.getFileInputStream(getTenantNode(desc)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getFileOutputStream(java.lang.String) - */ - public OutputStream getFileOutputStream(String path) - { - return fService.getFileOutputStream(getTenantPath(path)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getHeadPaths(org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public List> getHeadPaths(AVMNodeDescriptor desc) - { - return fService.getHeadPaths(getTenantNode(desc)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getHistory(org.alfresco.service.cmr.avm.AVMNodeDescriptor, int) - */ - public List getHistory(AVMNodeDescriptor desc, int count) - { - return getBaseNodes(fService.getHistory(getTenantNode(desc), count)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getIndirectionPath(int, java.lang.String) - */ - public String getIndirectionPath(int version, String path) - { - return getBasePath(fService.getIndirectionPath(version, getTenantPath(path))); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getLatestSnapshotID(java.lang.String) - */ - public int getLatestSnapshotID(String storeName) - { - return fService.getLatestSnapshotID(getTenantStoreName(storeName)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getLayeringInfo(int, java.lang.String) - */ - public LayeringDescriptor getLayeringInfo(int version, String path) - { - return fService.getLayeringInfo(version, getTenantPath(path)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getNextVersionID(java.lang.String) - */ - public int getNextVersionID(String storeName) - { - return fService.getNextVersionID(storeName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getNodeProperties(int, java.lang.String) - */ - public Map getNodeProperties(int version, String path) - { - return fService.getNodeProperties(version, getTenantPath(path)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getNodeProperties(org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public Map getNodeProperties(AVMNodeDescriptor desc) - { - // TODO - review - return fService.getNodeProperties(getTenantNode(desc)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getNodeProperty(int, java.lang.String, org.alfresco.service.namespace.QName) - */ - public PropertyValue getNodeProperty(int version, String path, QName name) - { - // TODO - review - return fService.getNodeProperty(version, getTenantPath(path), name); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getPaths(org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public List> getPaths(AVMNodeDescriptor desc) - { - return getBaseVPaths(fService.getPaths(getTenantNode(desc))); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getPathsInStoreHead(org.alfresco.service.cmr.avm.AVMNodeDescriptor, java.lang.String) - */ - public List> getPathsInStoreHead(AVMNodeDescriptor desc, String storeName) - { - return getBaseVPaths(fService.getPathsInStoreHead(getTenantNode(desc), getTenantStoreName(storeName))); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getStore(java.lang.String) - */ - public AVMStoreDescriptor getStore(String storeName) - { - return getBaseStore(fService.getStore(getTenantStoreName(storeName))); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getStoreProperties(java.lang.String) - */ - public Map getStoreProperties(String storeName) - { - return fService.getStoreProperties(getTenantStoreName(storeName)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getStoreProperty(java.lang.String, org.alfresco.service.namespace.QName) - */ - public PropertyValue getStoreProperty(String storeName, QName name) - { - return fService.getStoreProperty(getTenantStoreName(storeName), name); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getStoreRoot(int, java.lang.String) - */ - public AVMNodeDescriptor getStoreRoot(int version, String storeName) - { - return getBaseNode(fService.getStoreRoot(version, getTenantStoreName(storeName))); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getStoreVersions(java.lang.String) - */ - public List getStoreVersions(String storeName) - { - // TODO - review - return fService.getStoreVersions(getTenantStoreName(storeName)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getStoreVersions(java.lang.String, java.util.Date, java.util.Date) - */ - public List getStoreVersions(String storeName, Date from, Date to) - { - // TODO - review - return fService.getStoreVersions(getTenantStoreName(storeName), from, to); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getStores() - */ - public List getStores() - { - List allAvmStores = fService.getStores(); - if (isTenantServiceEnabled()) - { - List convertedValues = new ArrayList(); - for (AVMStoreDescriptor store : allAvmStores) - { - try - { - // MT: return tenant stores only (although for super System return all stores) - String runAsUser = AuthenticationUtil.getRunAsUser(); - if (! EqualsHelper.nullSafeEquals(runAsUser, AuthenticationUtil.SYSTEM_USER_NAME)) - { - tenantService.checkDomain(store.getName()); - store = getBaseStore(store); - } - - convertedValues.add(store); - } - catch (RuntimeException re) - { - // deliberately ignore - stores in different domain will not be listed - } - } - - return convertedValues; - } - else - { - return allAvmStores; - } - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#getSystemStore() - */ - public AVMStoreDescriptor getSystemStore() - { - return getBaseStore(fService.getSystemStore()); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#hasAspect(int, java.lang.String, org.alfresco.service.namespace.QName) - */ - public boolean hasAspect(int version, String path, QName aspectName) - { - return fService.hasAspect(version, getTenantPath(path), aspectName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#link(java.lang.String, java.lang.String, org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public void link(String parentPath, String name, AVMNodeDescriptor toLink) - { - fService.link(getTenantPath(parentPath), name, getTenantNode(toLink)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#lookup(int, java.lang.String) - */ - public AVMNodeDescriptor lookup(int version, String path) - { - return getBaseNode(fService.lookup(version, getTenantPath(path))); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#lookup(int, java.lang.String, boolean) - */ - public AVMNodeDescriptor lookup(int version, String path, boolean includeDeleted) - { - return getBaseNode(fService.lookup(version, getTenantPath(path), includeDeleted)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#lookup(org.alfresco.service.cmr.avm.AVMNodeDescriptor, java.lang.String) - */ - public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name) - { - return getBaseNode(fService.lookup(getTenantNode(dir), name)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#lookup(org.alfresco.service.cmr.avm.AVMNodeDescriptor, java.lang.String, boolean) - */ - public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name, boolean includeDeleted) - { - return getBaseNode(fService.lookup(getTenantNode(dir), name, includeDeleted)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#makePrimary(java.lang.String) - */ - public void makePrimary(String path) - { - fService.makePrimary(getTenantPath(path)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#makeTransparent(java.lang.String, java.lang.String) - */ - public void makeTransparent(String dirPath, String name) - { - fService.makeTransparent(getTenantPath(dirPath), name); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#purgeStore(java.lang.String) - */ - public void purgeStore(String storeName) - { - fService.purgeStore(getTenantStoreName(storeName)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#purgeVersion(int, java.lang.String) - */ - public void purgeVersion(int version, String storeName) - { - fService.purgeVersion(version, getTenantStoreName(storeName)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#queryStorePropertyKey(java.lang.String, org.alfresco.service.namespace.QName) - */ - public Map queryStorePropertyKey(String storeName, QName keyPattern) - { - return fService.queryStorePropertyKey(getTenantStoreName(storeName), keyPattern); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#queryStoresPropertyKeys(org.alfresco.service.namespace.QName) - */ - public Map> queryStoresPropertyKeys(QName keyPattern) - { - // TODO - review - return fService.queryStoresPropertyKeys(keyPattern); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#removeAspect(java.lang.String, org.alfresco.service.namespace.QName) - */ - public void removeAspect(String path, QName aspectName) - { - fService.removeAspect(getTenantPath(path), aspectName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#removeNode(java.lang.String, java.lang.String) - */ - public void removeNode(String parent, String name) - { - fService.removeNode(getTenantPath(parent), name); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#removeNode(java.lang.String) - */ - public void removeNode(String path) - { - fService.removeNode(getTenantPath(path)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#rename(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - public void rename(String srcParent, String srcName, String dstParent, String dstName) - { - fService.rename(getTenantPath(srcParent), srcName, getTenantPath(dstParent), dstName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#renameStore(java.lang.String, java.lang.String) - */ - public void renameStore(String sourceStoreName, String destStoreName) - { - fService.renameStore(getTenantStoreName(sourceStoreName), getTenantStoreName(destStoreName)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#retargetLayeredDirectory(java.lang.String, java.lang.String) - */ - public void retargetLayeredDirectory(String path, String target) - { - fService.retargetLayeredDirectory(getTenantPath(path), target); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#revert(java.lang.String, org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public void revert(String path, AVMNodeDescriptor toRevertTo) - { - fService.revert(getTenantPath(path), getTenantNode(toRevertTo)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#setContentData(java.lang.String, org.alfresco.service.cmr.repository.ContentData) - */ - public void setContentData(String path, ContentData data) - { - fService.setContentData(getTenantPath(path), data); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#setEncoding(java.lang.String, java.lang.String) - */ - public void setEncoding(String path, String encoding) - { - fService.setEncoding(getTenantPath(path), encoding); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#setGuid(java.lang.String, java.lang.String) - */ - public void setGuid(String path, String guid) - { - fService.setGuid(getTenantPath(path), guid); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#setMetaDataFrom(java.lang.String, org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public void setMetaDataFrom(String path, AVMNodeDescriptor from) - { - fService.setMetaDataFrom(getTenantPath(path), getTenantNode(from)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#setMimeType(java.lang.String, java.lang.String) - */ - public void setMimeType(String path, String mimeType) - { - fService.setMimeType(getTenantPath(path), mimeType); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#setNodeProperties(java.lang.String, java.util.Map) - */ - public void setNodeProperties(String path, Map properties) - { - fService.setNodeProperties(getTenantPath(path), properties); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#setNodeProperty(java.lang.String, org.alfresco.service.namespace.QName, org.alfresco.repo.domain.PropertyValue) - */ - public void setNodeProperty(String path, QName name, PropertyValue value) - { - fService.setNodeProperty(getTenantPath(path), name, value); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#setOpacity(java.lang.String, boolean) - */ - public void setOpacity(String path, boolean opacity) - { - fService.setOpacity(getTenantPath(path), opacity); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#setStoreProperties(java.lang.String, java.util.Map) - */ - public void setStoreProperties(String storeName, Map props) - { - fService.setStoreProperties(getTenantStoreName(storeName), props); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#setStoreProperty(java.lang.String, org.alfresco.service.namespace.QName, org.alfresco.repo.domain.PropertyValue) - */ - public void setStoreProperty(String storeName, QName name, PropertyValue value) - { - fService.setStoreProperty(getTenantStoreName(storeName), name, value); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#uncover(java.lang.String, java.lang.String) - */ - public void uncover(String dirPath, String name) - { - fService.uncover(getTenantPath(dirPath), name); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#createDirectory(java.lang.String, java.lang.String, java.util.List, java.util.Map) - */ - public void createDirectory(String path, String name, List aspects, Map properties) - { - fService.createDirectory(getTenantPath(path), name, aspects, properties); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.AVMService#createFile(java.lang.String, java.lang.String, java.io.InputStream, java.util.List, java.util.Map) - */ - public void createFile(String path, String name, InputStream in, List aspects, Map properties) - { - fService.createFile(getTenantPath(path), name, in, aspects, properties); - } - - - public List getStoreVersionsTo(String name, int version) - { - // TODO - review - return fService.getStoreVersionsTo(name, version); - } - - public List getStoreVersionsFrom(String name, int version) - { - // TODO - review - return fService.getStoreVersionsFrom(name, version); - } - - public List getStoreVersionsBetween(String name, int from, int to) - { - // TODO - review - return fService.getStoreVersionsBetween(name, from, to); - } - - private String getTenantStoreName(String avmStoreName) - { - if ((avmStoreName == null) || (! isTenantServiceEnabled())) - { - return avmStoreName; - } - - return tenantService.getName(avmStoreName); - } - - private String getBaseStoreName(String avmStoreName) - { - if ((avmStoreName == null) || (! isTenantServiceEnabled())) - { - return avmStoreName; - } - - return tenantService.getBaseName(avmStoreName); - } - - private String getTenantPath(String avmPath) - { - if ((avmPath == null) || (! isTenantServiceEnabled()) || avmPath.equals("UNKNOWN/UNKNOWN")) - { - return avmPath; - } - - String[] storePath = splitPath(avmPath); - return tenantService.getName(storePath[0]) + ':' + storePath[1]; - } - - private String getBasePath(String avmPath) - { - // note: ALFCOM-2893 - getCommonAncestor can return node with path = "/" - if ((avmPath == null) || (! isTenantServiceEnabled()) || (avmPath.equals("/")) || avmPath.equals("UNKNOWN/UNKNOWN")) - { - return avmPath; - } - - String[] storePath = splitPath(avmPath); - return tenantService.getBaseName(storePath[0]) + ':' + storePath[1]; - } - - private Pair getBaseVPath(Pair p) - { - if ((p == null) || (! isTenantServiceEnabled())) - { - return p; - } - - return new Pair(p.getFirst(), getBasePath(p.getSecond())); - } - - private List> getBaseVPaths(List> paths) - { - if ((paths == null) || (! isTenantServiceEnabled())) - { - return paths; - } - - List> convertedPaths = new ArrayList>(paths.size()); - for (Pair path : paths) - { - convertedPaths.add(getBaseVPath(path)); - } - return convertedPaths; - } - - private List getBasePaths(List paths) - { - if ((paths == null) || (! isTenantServiceEnabled())) - { - return paths; - } - - List convertedPaths = new ArrayList(paths.size()); - for (String path : paths) - { - convertedPaths.add(getBasePath(path)); - } - return convertedPaths; - } - - private String[] splitPath(String path) - { - String[] storePath = path.split(":"); - if (storePath.length != 2) - { - throw new AVMBadArgumentException("Invalid Path: " + path); - } - return storePath; - } - - private AVMNodeDescriptor getTenantNode(AVMNodeDescriptor node) - { - if ((node == null) || (! isTenantServiceEnabled())) - { - return node; - } - - return new AVMNodeDescriptor( - getTenantPath(node.getPath()), - node.getName(), - node.getType(), - node.getCreator(), - node.getOwner(), - node.getLastModifier(), - node.getCreateDate(), - node.getModDate(), - node.getAccessDate(), - node.getId(), - node.getGuid(), - node.getVersionID(), - node.getIndirection(), - node.getIndirectionVersion(), - node.isPrimary(), - node.getLayerID(), - node.getOpacity(), - node.getLength(), - node.getDeletedType()); - } - - private AVMNodeDescriptor getBaseNode(AVMNodeDescriptor node) - { - if ((node == null) || (! isTenantServiceEnabled())) - { - return node; - } - - return new AVMNodeDescriptor( - getBasePath(node.getPath()), - node.getName(), - node.getType(), - node.getCreator(), - node.getOwner(), - node.getLastModifier(), - node.getCreateDate(), - node.getModDate(), - node.getAccessDate(), - node.getId(), - node.getGuid(), - node.getVersionID(), - node.getIndirection(), - node.getIndirectionVersion(), - node.isPrimary(), - node.getLayerID(), - node.getOpacity(), - node.getLength(), - node.getDeletedType()); - } - - private AVMStoreDescriptor getBaseStore(AVMStoreDescriptor store) - { - if ((store == null) || (! isTenantServiceEnabled())) - { - return store; - } - - return new AVMStoreDescriptor( - store.getId(), - getBaseStoreName(store.getName()), - store.getCreator(), - store.getCreateDate()); - } - - private SortedMap getBaseNodes(SortedMap nodes) - { - if ((nodes == null) || (! isTenantServiceEnabled())) - { - return nodes; - } - - SortedMap convertedNodes = new TreeMap(String.CASE_INSENSITIVE_ORDER); - for (Map.Entry entry : nodes.entrySet()) - { - convertedNodes.put(entry.getKey(), getBaseNode(entry.getValue())); - } - return convertedNodes; - } - - private AVMNodeDescriptor[] getBaseNodes(AVMNodeDescriptor[] nodes) - { - if ((nodes == null) || (! isTenantServiceEnabled())) - { - return nodes; - } - - AVMNodeDescriptor[] convertedNodes = new AVMNodeDescriptor[nodes.length]; - for (int i = 0; i < nodes.length; i++) - { - convertedNodes[i] = getBaseNode(nodes[i]); - } - return convertedNodes; - } - - private List getBaseNodes(List nodes) - { - if ((nodes == null) || (! isTenantServiceEnabled())) - { - return nodes; - } - - List convertedNodes = new ArrayList(nodes.size()); - for (AVMNodeDescriptor node : nodes) - { - convertedNodes.add(getBaseNode(node)); - } - return convertedNodes; - } - - private boolean isTenantServiceEnabled() - { - if (enabled == null) - { - enabled = tenantService.isEnabled(); - } - - return enabled; - } - -} diff --git a/source/java/org/alfresco/repo/avm/PurgeStoreCallback.java b/source/java/org/alfresco/repo/avm/PurgeStoreCallback.java deleted file mode 100644 index ae7e86cdfa..0000000000 --- a/source/java/org/alfresco/repo/avm/PurgeStoreCallback.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.avm; - -/** - * Callback interface for those interested in store purges. - * @author britt - */ -public interface PurgeStoreCallback -{ - /** - * A store has been purged. - * @param storeName The name of the purged store. - */ - public void storePurged(String storeName); -} diff --git a/source/java/org/alfresco/repo/avm/PurgeStoreTxnListener.java b/source/java/org/alfresco/repo/avm/PurgeStoreTxnListener.java deleted file mode 100644 index e24c81c61f..0000000000 --- a/source/java/org/alfresco/repo/avm/PurgeStoreTxnListener.java +++ /dev/null @@ -1,107 +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 . - */ -package org.alfresco.repo.avm; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.repo.transaction.TransactionListenerAdapter; - -/** - * Transaction listener for firing purge store events. - * @author britt - */ -public class PurgeStoreTxnListener extends TransactionListenerAdapter -{ - /** - * Storage for stores purged in a transaction. - */ - private ThreadLocal> fPurgedStores; - - /** - * Callbacks to invoke on commit. - */ - private List fCallbacks; - - /** - * Default constructor. - */ - public PurgeStoreTxnListener() - { - fPurgedStores = new ThreadLocal>(); - fCallbacks = new ArrayList(); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterCommit() - */ - @Override - public void afterCommit() - { - List created = fPurgedStores.get(); - if (created != null) - { - for (String name : created) - { - synchronized (this) - { - for (PurgeStoreCallback cb : fCallbacks) - { - cb.storePurged(name); - } - } - } - fPurgedStores.set(null); - } - } - - /* (non-Javadoc) - * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterRollback() - */ - @Override - public void afterRollback() - { - fPurgedStores.set(null); - } - - /** - * During the transaction somebody is responsible for - * calling this. - * @param storeName The name of the store that has been purged. - */ - public void storePurged(String storeName) - { - List purged = fPurgedStores.get(); - if (purged == null) - { - purged = new ArrayList(); - fPurgedStores.set(purged); - } - purged.add(storeName); - } - - /** - * Register a callback. - * @param cb The callback. - */ - public synchronized void addCallback(PurgeStoreCallback cb) - { - fCallbacks.add(cb); - } -} diff --git a/source/java/org/alfresco/repo/avm/PurgeVersionCallback.java b/source/java/org/alfresco/repo/avm/PurgeVersionCallback.java deleted file mode 100644 index 056fab8437..0000000000 --- a/source/java/org/alfresco/repo/avm/PurgeVersionCallback.java +++ /dev/null @@ -1,33 +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 . - */ -package org.alfresco.repo.avm; - -/** - * A Callback interface for those interested in versions being purged. - * @author britt - */ -public interface PurgeVersionCallback -{ - /** - * A version was purged from a store. - * @param storeName The name of the store from which a version was purged. - * @param versionID The id of the purged version. - */ - public void versionPurged(String storeName, int versionID); -} diff --git a/source/java/org/alfresco/repo/avm/PurgeVersionTxnListener.java b/source/java/org/alfresco/repo/avm/PurgeVersionTxnListener.java deleted file mode 100644 index 323af2aa35..0000000000 --- a/source/java/org/alfresco/repo/avm/PurgeVersionTxnListener.java +++ /dev/null @@ -1,109 +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 . - */ -package org.alfresco.repo.avm; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.repo.transaction.TransactionListenerAdapter; -import org.alfresco.util.Pair; - -/** - * Transaction listener that fires purge version events. - * @author britt - */ -public class PurgeVersionTxnListener extends TransactionListenerAdapter -{ - /** - * Storage for versions purged in a transaction. - */ - private ThreadLocal>> fPurgedVersions; - - /** - * Callbacks to invoke on commit. - */ - private List fCallbacks; - - /** - * Default constructor. - */ - public PurgeVersionTxnListener() - { - fPurgedVersions = new ThreadLocal>>(); - fCallbacks = new ArrayList(); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterCommit() - */ - @Override - public void afterCommit() - { - List> created = fPurgedVersions.get(); - if (created != null) - { - for (Pair version : created) - { - synchronized (this) - { - for (PurgeVersionCallback cb : fCallbacks) - { - cb.versionPurged(version.getFirst(), version.getSecond()); - } - } - } - fPurgedVersions.set(null); - } - } - - /* (non-Javadoc) - * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterRollback() - */ - @Override - public void afterRollback() - { - fPurgedVersions.set(null); - } - - /** - * During the transaction somebody is responsible for - * calling this. - * @param storeName The name of the store that just created a new version - * @param versionID The id of the new version. - */ - public void versionPurged(String storeName, int versionID) - { - List> purged = fPurgedVersions.get(); - if (purged == null) - { - purged = new ArrayList>(); - fPurgedVersions.set(purged); - } - purged.add(new Pair(storeName, versionID)); - } - - /** - * Register a callback. - * @param cb The callback. - */ - public synchronized void addCallback(PurgeVersionCallback cb) - { - fCallbacks.add(cb); - } -} diff --git a/source/java/org/alfresco/repo/avm/actions/AVMDeployWebsiteAction.java b/source/java/org/alfresco/repo/avm/actions/AVMDeployWebsiteAction.java deleted file mode 100644 index c2f156b81a..0000000000 --- a/source/java/org/alfresco/repo/avm/actions/AVMDeployWebsiteAction.java +++ /dev/null @@ -1,601 +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 . - */ - -package org.alfresco.repo.avm.actions; - -import java.io.PrintWriter; -import java.io.Serializable; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.model.WCMAppModel; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.avm.deploy.DeploymentCallback; -import org.alfresco.service.cmr.avm.deploy.DeploymentEvent; -import org.alfresco.service.cmr.avm.deploy.DeploymentReport; -import org.alfresco.service.cmr.avm.deploy.DeploymentReportCallback; -import org.alfresco.service.cmr.avm.deploy.DeploymentService; -import org.alfresco.service.cmr.avmsync.AVMSyncException; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.Pair; -import org.alfresco.util.RegexNameMatcher; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Deploys a website to a remote server. - * - * TODO refactor and add to WCM services (when we support WCM deployment config) - * - * @author gavinc - */ -public class AVMDeployWebsiteAction extends ActionExecuterAbstractBase -{ - public static final String NAME = "avm-deploy-website"; - public static final String FILE_SERVER_PREFIX = "\\\\"; - - public static final String PARAM_WEBPROJECT = "webproject"; - public static final String PARAM_SERVER = "server"; - public static final String PARAM_ATTEMPT = "attempt"; - public static final String PARAM_CALLBACK = "callback"; - - public static final String ASYNC_QUEUE_NAME = "deployment"; - - public static final String LIVE_SUFFIX = "live"; - - private int delay = -1; - private int defaultAlfRmiPort = 50500; - private int defaultReceiverRmiPort = 44100; - private String defaultRemoteUsername = "admin"; - private String defaultRemotePassword = "admin"; - private String defaultTargetName = "default"; - private String defaultAdapterName = "default"; - private List configuredCallbacks; - private DeploymentService deployService; - private ContentService contentService; - private NodeService nodeService; - private TransactionService transactionService; - - private static Log logger = LogFactory.getLog(AVMDeployWebsiteAction.class); - private static Log delayDeploymentLogger = LogFactory.getLog("alfresco.deployment.delay"); - - /** - * Calculate the URI representation of a server from the given set of properties - * - * @param props Set of properties to calculate URI from - */ - public static String calculateServerUri(Map props) - { - StringBuilder uri = new StringBuilder(); - - // prefix the uri if necessary - String type = (String)props.get(WCMAppModel.PROP_DEPLOYTYPE); - if (WCMAppModel.CONSTRAINT_FILEDEPLOY.equals(type)) - { - uri.append(FILE_SERVER_PREFIX); - } - - // append server name - uri.append((String)props.get(WCMAppModel.PROP_DEPLOYSERVERHOST)); - - // append port (if present) - Integer port = (Integer)props.get(WCMAppModel.PROP_DEPLOYSERVERPORT); - if (port != null) - { - uri.append(":"); - uri.append(port.toString()); - } - - return uri.toString(); - } - - /** - * Sets the delay to use before starting the deployment - * - * @param delay The delay in seconds - */ - public void setDelay(int delay) - { - this.delay = delay; - } - - /** - * Sets the default RMI port for Alfresco server deployments - * - * @param defaultAlfrescoRmiPort port number - */ - public void setDefaultAlfrescoRmiPort(int defaultAlfrescoRmiPort) - { - this.defaultAlfRmiPort = defaultAlfrescoRmiPort; - } - - /** - * Sets the default RMI port for File system deployments - * - * @param defaultReceiverRmiPort port number - */ - public void setDefaultReceiverRmiPort(int defaultReceiverRmiPort) - { - this.defaultReceiverRmiPort = defaultReceiverRmiPort; - } - - /** - * Sets the default remote username to use for deployments - * - * @param defaultRemoteUsername Default remote username - */ - public void setDefaultRemoteUsername(String defaultRemoteUsername) - { - this.defaultRemoteUsername = defaultRemoteUsername; - } - - /** - * Sets the default remote password to use for deployments - * - * @param defaultRemotePassword Default remote password - */ - public void setDefaultRemotePassword(String defaultRemotePassword) - { - this.defaultRemotePassword = defaultRemotePassword; - } - - /** - * Sets the default target name to use on file system receivers - * - * @param defaultTargetName Default target name - */ - public void setDefaultTargetName(String defaultTargetName) - { - this.defaultTargetName = defaultTargetName; - } - - public void setCallbacks(List callbacks) - { - this.configuredCallbacks = callbacks; - } - - /** - * @param service The NodeService instance - */ - public void setNodeService(NodeService service) - { - this.nodeService = service; - } - - /** - * @param contentService The ContentService instance - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * @param service The AVM Deployment Service instance - */ - public void setDeploymentService(DeploymentService service) - { - deployService = service; - } - - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_WEBPROJECT, DataTypeDefinition.NODE_REF, true, - getParamDisplayLabel(PARAM_WEBPROJECT))); - paramList.add(new ParameterDefinitionImpl(PARAM_SERVER, DataTypeDefinition.NODE_REF, true, - getParamDisplayLabel(PARAM_SERVER))); - paramList.add(new ParameterDefinitionImpl(PARAM_ATTEMPT, DataTypeDefinition.NODE_REF, false, - getParamDisplayLabel(PARAM_ATTEMPT))); - paramList.add(new ParameterDefinitionImpl(PARAM_CALLBACK, DataTypeDefinition.ANY, false, - getParamDisplayLabel(PARAM_CALLBACK))); - } - - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - // the actionedUponNodeRef is the path of the sandbox to deploy - Pair 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 NodeRef representing the website being deployed - NodeRef websiteRef = (NodeRef)action.getParameterValue(PARAM_WEBPROJECT); - if (this.nodeService.exists(websiteRef) == false) - { - throw new IllegalStateException("The website NodeRef (" + websiteRef + - ") provided does not exist!"); - } - - // get the NodeRef representing the server to deploy to - NodeRef serverRef = (NodeRef)action.getParameterValue(PARAM_SERVER); - if (this.nodeService.exists(serverRef) == false) - { - throw new IllegalStateException("The server NodeRef (" + serverRef + - ") provided does not exist!"); - } - - // get the NodeRef representing the deployment attempt this one is part of - NodeRef attemptRef = (NodeRef)action.getParameterValue(PARAM_ATTEMPT); - - // TODO: if attempt reference is null create one now for this deployment, for now throw error - if (this.nodeService.exists(attemptRef) == false) - { - throw new IllegalStateException("The attempt NodeRef (" + serverRef + - ") provided does not exist!"); - } - - // get the callback object - DeploymentCallback callback = (DeploymentCallback)action.getParameterValue(PARAM_CALLBACK); - - // get the other data from the deploymentserver object - Map serverProps = nodeService.getProperties(serverRef); - String serverUri = calculateServerUri(serverProps); - String host = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERHOST); - Integer port = (Integer)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERPORT); - String remoteUsername = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERUSERNAME); - String remotePassword = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERPASSWORD); - boolean fileServerDeployment = WCMAppModel.CONSTRAINT_FILEDEPLOY.equals( - serverProps.get(WCMAppModel.PROP_DEPLOYTYPE)); - String sourcePath = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSOURCEPATH); - String excludes = (String)serverProps.get(WCMAppModel.PROP_DEPLOYEXCLUDES); - String targetName = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERTARGET); - String adapterName = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERADPTERNAME); - String targetPath = path; - - if (fileServerDeployment == false) - { - // if "localhost" is passed as the target server add "live" to the end of the - // store name, this store will then get created automatically. - - // TODO: Check that the actual host name of the machine hasn't been passed - - if (port == null && (host.equalsIgnoreCase("localhost") || host.equalsIgnoreCase("127.0.0.1"))) - { - targetPath = storePath[0] + LIVE_SUFFIX + ":" + storePath[1]; - } - } - else - { - if (adapterName == null) { - adapterName = defaultAdapterName; - } - } - - // get defaults for data not provided in server node - if (port == null) - { - if (fileServerDeployment) - { - port = this.defaultReceiverRmiPort; - } - else - { - port = this.defaultAlfRmiPort; - } - } - - if (remoteUsername == null || remoteUsername.length() == 0) - { - remoteUsername = this.defaultRemoteUsername; - } - - if (remotePassword == null || remotePassword.length() == 0) - { - remotePassword = this.defaultRemotePassword; - } - - if (targetName == null || targetName.length() == 0) - { - targetName = this.defaultTargetName; - } - - // determine the actual source path - if (sourcePath != null && sourcePath.length() > 0) - { - // make sure the path starts with / - if (sourcePath.startsWith("/") == false) - { - sourcePath = "/" + sourcePath; - } - - // append to the root path - path = path + sourcePath; - } - - // determine if a NameMatcher is required (if an exclude is present) - RegexNameMatcher regexMatcher = null; - if (excludes != null && excludes.length() > 0) - { - regexMatcher = new RegexNameMatcher(); - List patterns = new ArrayList(1); - patterns.add(excludes); - regexMatcher.setPatterns(patterns); - } - - // create a list of all the callback objects - List callbacks = new ArrayList(); - if (callback != null) - { - // if present add the callback passed as a parameter (usually for UI purposes) - callbacks.add(callback); - } - if (this.configuredCallbacks != null && this.configuredCallbacks.size() > 0) - { - // add the configured callbacks - callbacks.addAll(this.configuredCallbacks); - } - - // take a note of the current date/time - Date startDate = new Date(); - - if (logger.isDebugEnabled()) - logger.debug("Starting deployment of " + actionedUponNodeRef.toString() + - " to " + serverUri + " at " + startDate); - -// if (delayDeploymentLogger.isDebugEnabled() && delay > 0) -// { -// delayDeploymentLogger.debug("Delaying deployment by " + delay + "s..."); -// -// // add a delay for testing purposes if the delay logger level is debug -// try { Thread.sleep(1000*delay); } catch (Throwable e) {} -// } - - // make the deploy call passing in the DeploymentCallback, if present - Throwable deployError = null; - - DeploymentReport report = new DeploymentReport(); - callbacks.add(new DeploymentReportCallback(report)); - - try - { - // overwrite the password before logging - serverProps.put(WCMAppModel.PROP_DEPLOYSERVERPASSWORD, "*****"); - - // call the appropriate method to deploy - if (fileServerDeployment) - { - if (logger.isDebugEnabled()) - logger.debug("Performing file server deployment to " + host + ":" + port + - " using deploymentserver: " + serverProps); - - this.deployService.deployDifferenceFS(version, - path, - adapterName, - host, - port, - remoteUsername, - remotePassword, - targetName, - regexMatcher, - true, - false, - false, - callbacks); - } - else - { - if (logger.isDebugEnabled()) - logger.debug("Performing Alfresco deployment to " + host + ":" + port + - " using deploymentserver: " + serverProps); - - this.deployService.deployDifference(version, - path, - host, - port, - remoteUsername, - remotePassword, - targetPath, - regexMatcher, - true, - false, - false, - callbacks); - } - } - catch (Throwable err) - { - deployError = err; - logger.error("Deployment Error", deployError); - } - - if (report != null) - { - if (logger.isDebugEnabled()) - logger.debug("Differences successfully applied to " + serverUri); - } - else - { - if (logger.isDebugEnabled()) - logger.debug("Failed to apply differences to " + serverUri); - } - - // create the deployment report node - createDeploymentReportNode(report, attemptRef, serverProps, version, - websiteRef, startDate, deployError); - - } - - /** - * Creates a deployment report node as a child of the given website. - * - * @param report The DeploymentReport result from the deploy, - * will be null if the deploy failed - * @param attempt NodeRef of the attempt the deploy was part of - * @param serverProps The properties of the server the deploy was going to - * @param version The version of the site bebing deployed (the snapshot) - * @param websiteRef The NodeRef of the folder representing the website - * @param startDate The date/time the deployment started - * @param error The error that caused the deployment to fail, null if the - * deployment was successful - * @return The created deployment report NodeRef - */ - private NodeRef createDeploymentReportNode(final DeploymentReport report, - final NodeRef attempt, - final Map serverProps, - final int version, - final NodeRef websiteRef, - final Date startDate, - final Throwable error) - { - logger.debug("createDeploymentReportNode called "); - NodeRef reportRef = null; - - final String serverUri = calculateServerUri(serverProps); - final Map reportProps = new HashMap(4, 1.0f); - reportProps.put(WCMAppModel.PROP_DEPLOYSERVER, serverUri); - reportProps.put(WCMAppModel.PROP_DEPLOYVERSION, version); - reportProps.put(WCMAppModel.PROP_DEPLOYSTARTTIME, startDate); - reportProps.put(WCMAppModel.PROP_DEPLOYENDTIME, new Date()); - reportProps.put(WCMAppModel.PROP_DEPLOYSERVERNAMEUSED, - serverProps.get(WCMAppModel.PROP_DEPLOYSERVERNAME)); - reportProps.put(WCMAppModel.PROP_DEPLOYSERVERUSERNAMEUSED, - serverProps.get(WCMAppModel.PROP_DEPLOYSERVERUSERNAME)); - reportProps.put(WCMAppModel.PROP_DEPLOYSERVERTARGETUSED, - serverProps.get(WCMAppModel.PROP_DEPLOYSERVERTARGET)); - reportProps.put(WCMAppModel.PROP_DEPLOYSOURCEPATHUSED, - serverProps.get(WCMAppModel.PROP_DEPLOYSOURCEPATH)); - reportProps.put(WCMAppModel.PROP_DEPLOYEXCLUDESUSED, - serverProps.get(WCMAppModel.PROP_DEPLOYEXCLUDES)); - reportProps.put(WCMAppModel.PROP_DEPLOYSERVERURLUSED, - serverProps.get(WCMAppModel.PROP_DEPLOYSERVERURL)); - - reportProps.put(WCMAppModel.PROP_DEPLOYSUCCESSFUL, (report != null) && (error == null)); - if (report == null && error != null) - { - // add error message as fail reason if appropriate (the reported - // exception is a wrapper so get the detail from the cause) - String errorMsg = error.getMessage(); - Throwable cause = error.getCause(); - if (cause != null) - { - errorMsg = cause.getMessage(); - } - - reportProps.put(WCMAppModel.PROP_DEPLOYFAILEDREASON, errorMsg); - } - - RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper(); - - RetryingTransactionCallback cb = new RetryingTransactionCallback() - { - public NodeRef execute() throws Throwable - { - /** - * Write out the deployment report - */ - NodeRef reportRef = nodeService.createNode(attempt, - WCMAppModel.ASSOC_DEPLOYMENTREPORTS, WCMAppModel.ASSOC_DEPLOYMENTREPORTS, - WCMAppModel.TYPE_DEPLOYMENTREPORT, reportProps).getChildRef(); - ContentWriter writer = contentService.getWriter(reportRef, ContentModel.PROP_CONTENT, true); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.setEncoding("UTF-8"); - - if (report == null) - { - // There is no report - if (error == null) - { - writer.putContent(""); - } - else - { - // add the full stack trace of the error as the content - StringWriter stack = new StringWriter(); - PrintWriter stackPrint = new PrintWriter(stack); - error.printStackTrace(stackPrint); - writer.putContent(stack.toString()); - } - } - else - { - // There is a deployment report - StringBuilder builder = new StringBuilder(); - for (DeploymentEvent event : report) - { - builder.append(event.getType()); - builder.append(" "); - builder.append(event.getDestination()); - builder.append("\r\n"); - } - - if(error != null) - { - builder.append("\r\n"); - - // add the full stack trace of the error as the content - StringWriter stack = new StringWriter(); - PrintWriter stackPrint = new PrintWriter(stack); - error.printStackTrace(stackPrint); - - builder.append(stack.toString()); - } - - writer.putContent(builder.toString()); - } - - return reportRef; - } - }; - - // Run the creation of the deployment report in its own write transaction - reportRef = tran.doInTransaction(cb, false, true); - - if (logger.isDebugEnabled()) - logger.debug("Created deplyoment report node (" + reportRef + ") for server " + - serverUri); - - return reportRef; - } - - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - public TransactionService getTransactionService() - { - return transactionService; - } -} diff --git a/source/java/org/alfresco/repo/avm/actions/AVMRevertListAction.java b/source/java/org/alfresco/repo/avm/actions/AVMRevertListAction.java deleted file mode 100644 index 4b8dad9bf4..0000000000 --- a/source/java/org/alfresco/repo/avm/actions/AVMRevertListAction.java +++ /dev/null @@ -1,106 +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 . - */ -package org.alfresco.repo.avm.actions; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.avmsync.AVMDifference; -import org.alfresco.service.cmr.avmsync.AVMSyncService; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * This action handles reverting a selected set of nodes to a particular version. - * The actionedUponNodeRef is a dummy and can be null. - * @author britt - * - * @deprecated - */ -public class AVMRevertListAction extends ActionExecuterAbstractBase -{ - @SuppressWarnings("unused") - private static Log fgLogger = LogFactory.getLog(AVMRevertListAction.class); - - public static final String NAME = "avm-revert-list"; - // The version to revert to. - public static final String PARAM_VERSION = "version"; - // The encoded list of nodes. - public static final String PARAM_NODE_LIST = "node-list"; - // Flag for whether we should flatten after revert. - - /** - * The sync service. - */ - private AVMSyncService fSyncService; - - /** - * Set the sync service. - */ - public void setAvmSyncService(AVMSyncService service) - { - fSyncService = service; - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("unchecked") - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - int revertVersion = (Integer)action.getParameterValue(PARAM_VERSION); - List paths = - (List)action.getParameterValue(PARAM_NODE_LIST); - List diffs = new ArrayList(); - for (String path : paths) - { - List diffSet = - fSyncService.compare(revertVersion, path, - -1, path, null); - diffs.addAll(diffSet); - } - String message = "Reverted to version " + revertVersion; - fSyncService.update(diffs, null, false, false, true, true, message, message); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add( - new ParameterDefinitionImpl(PARAM_VERSION, - DataTypeDefinition.INT, - true, - getParamDisplayLabel(PARAM_VERSION))); - paramList.add( - new ParameterDefinitionImpl(PARAM_NODE_LIST, - DataTypeDefinition.ANY, - true, - getParamDisplayLabel(PARAM_NODE_LIST))); - } -} diff --git a/source/java/org/alfresco/repo/avm/actions/AVMRevertStoreAction.java b/source/java/org/alfresco/repo/avm/actions/AVMRevertStoreAction.java deleted file mode 100644 index d6b36ea582..0000000000 --- a/source/java/org/alfresco/repo/avm/actions/AVMRevertStoreAction.java +++ /dev/null @@ -1,93 +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 . - */ -package org.alfresco.repo.avm.actions; - -import java.util.List; - -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.avmsync.AVMDifference; -import org.alfresco.service.cmr.avmsync.AVMSyncService; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.Pair; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Reverts a node and everything underneath it to a specified version. - * @author britt - * - * @deprecated see org.alfresco.wcm.actions.WCMSandboxRevertSnapshotAction or org.alfresco.wcm.SandboxService.revertSnapshot - */ -public class AVMRevertStoreAction extends ActionExecuterAbstractBase -{ - @SuppressWarnings("unused") - private static Log fgLogger = LogFactory.getLog(AVMRevertStoreAction.class); - - public static final String NAME = "avm-revert-store"; - public static final String PARAM_VERSION = "version"; - - /** - * The AVM Synchronization Service. - */ - private AVMSyncService fSyncService; - - /** - * Set the Sync Service. - */ - public void setAvmSyncService(AVMSyncService service) - { - fSyncService = service; - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - // All this does is an override submit from the older version - // to head of the store implied in the path. - Pair pathVersion = - AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef); - int revertVersion = (Integer)action.getParameterValue(PARAM_VERSION); - List diffs = - fSyncService.compare(revertVersion, pathVersion.getSecond(), - -1, pathVersion.getSecond(), null); - String message = "Reverted to Version " + revertVersion + "."; - fSyncService.update(diffs, null, false, false, true, true, message, message); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add( - new ParameterDefinitionImpl(PARAM_VERSION, - DataTypeDefinition.INT, - true, - getParamDisplayLabel(PARAM_VERSION))); - } -} diff --git a/source/java/org/alfresco/repo/avm/actions/AVMRevertToVersionAction.java b/source/java/org/alfresco/repo/avm/actions/AVMRevertToVersionAction.java deleted file mode 100644 index f20ed262dd..0000000000 --- a/source/java/org/alfresco/repo/avm/actions/AVMRevertToVersionAction.java +++ /dev/null @@ -1,95 +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 . - */ -package org.alfresco.repo.avm.actions; - -import java.util.List; - -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.repo.avm.util.AVMUtil; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.Pair; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Revert a single path to a specified node. The path in head is passed - * as actionedUponNodeRef. The node to revert to is passed as an AVMNodeDescriptor - * parameter. - * - * TODO refactor and add to WCM services - * - * @author britt - * - * @deprecated - */ -public class AVMRevertToVersionAction extends ActionExecuterAbstractBase -{ - @SuppressWarnings("unused") - private static Log fgLogger = LogFactory.getLog(AVMRevertToVersionAction.class); - - public static final String NAME = "avm-revert-to-version"; - // The node to revert to. Passed as an AVMNodeDescriptor. - public static final String TOREVERT = "to-revert"; - - private AVMService fAVMService; - - /** - * Set the AVMService. - */ - public void setAvmService(AVMService service) - { - fAVMService = service; - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - Pair versionPath = - AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef); - AVMNodeDescriptor toRevertTo = - (AVMNodeDescriptor)action.getParameterValue(TOREVERT); - fAVMService.revert(versionPath.getSecond(), toRevertTo); - - String[] storePath = AVMUtil.splitPath(versionPath.getSecond()); - fAVMService.createSnapshot(storePath[0], null, "Reverted "+versionPath.getSecond()+" to version "+toRevertTo.getVersionID()); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add( - new ParameterDefinitionImpl(TOREVERT, - DataTypeDefinition.ANY, - true, - getParamDisplayLabel(TOREVERT))); - } -} diff --git a/source/java/org/alfresco/repo/avm/actions/AVMUndoSandboxListAction.java b/source/java/org/alfresco/repo/avm/actions/AVMUndoSandboxListAction.java deleted file mode 100644 index ec8b2c3016..0000000000 --- a/source/java/org/alfresco/repo/avm/actions/AVMUndoSandboxListAction.java +++ /dev/null @@ -1,144 +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 . - */ -package org.alfresco.repo.avm.actions; - -import java.util.List; - -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.repo.avm.util.AVMUtil; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -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.dictionary.DataTypeDefinition; -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; - -/** - * Undos a list of changed nodes in a user sandbox. The set of nodes to undo is - * passed in as a packed string (Obtained by VersionPathStuffer). - * The actionedUponNodeRef is a dummy and can be null. - * @author britt - * - * @deprecated see org.alfresco.wcm.actions.WCMSandboxRevertListAction or org.alfresco.wcm.SandboxService.revert - */ -public class AVMUndoSandboxListAction extends ActionExecuterAbstractBase -{ - private static Log fgLogger = LogFactory.getLog(AVMUndoSandboxListAction.class); - - public static final String NAME = "avm-undo-list"; - // The encoded list of nodes. - public static final String PARAM_NODE_LIST = "node-list"; - - /** - * The AVM Service reference. - */ - private AVMService fAVMService; - - /** - * The AVM Locking Service reference. - */ - private AVMLockingService fAVMLockingService; - - public void setAvmService(AVMService service) - { - fAVMService = service; - } - - public void setAvmLockingService(AVMLockingService service) - { - fAVMLockingService = service; - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("unchecked") - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - List> versionPaths = - (List>)action.getParameterValue(PARAM_NODE_LIST); - for (Pair item : versionPaths) - { - String avmPath = item.getSecond(); - AVMNodeDescriptor desc = fAVMService.lookup(-1, avmPath, true); - if (desc == null) - { - continue; - } - String [] parentChild = AVMNodeConverter.SplitBase(avmPath); - if (parentChild.length != 2) - { - continue; - } - AVMNodeDescriptor parent = fAVMService.lookup(-1, parentChild[0], true); - if (parent.isLayeredDirectory()) - { - if (fgLogger.isDebugEnabled()) - fgLogger.debug("reverting " + parentChild[1] + " in " + parentChild[0]); - fAVMService.makeTransparent(parentChild[0], parentChild[1]); - } - - if (desc.isFile() || desc.isDeletedFile()) - { - String parts[] = AVMUtil.splitPath(avmPath); - String avmStore = parts[0]; - String path = parts[1]; // store relative path - - String webProject = WCMUtil.getWebProject(fAVMService, avmStore); - if (webProject != null) - { - if (fgLogger.isDebugEnabled()) - { - fgLogger.debug("unlocking file " + path + " in web project " + webProject); - } - - if (fAVMLockingService.getLockOwner(webProject, path) != null) - { - fAVMLockingService.removeLock(webProject, path); - } - else - { - fgLogger.warn("expected file " + path + " in " + webProject + " to be locked"); - } - } - } - } - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add( - new ParameterDefinitionImpl(PARAM_NODE_LIST, - DataTypeDefinition.ANY, - true, - getParamDisplayLabel(PARAM_NODE_LIST))); - } -} diff --git a/source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java b/source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java deleted file mode 100644 index e0e2ccacab..0000000000 --- a/source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java +++ /dev/null @@ -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 . - */ -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.action.ParameterDefinitionImpl; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -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.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.Pair; - -/** - * An ActionExecuter that promotes content from one store to another. - * The NodeRef argument is in the source AVMStore. The 'target-store' - * mandatory argument is the name of the destination store. - * @author britt - * - * @deprecated - */ -public class SimpleAVMPromoteAction extends ActionExecuterAbstractBase -{ - public static final String NAME = "simple-avm-promote"; - public static final String PARAM_TARGET_STORE = "target-store"; - - /** - * The AVMSyncService instance. - */ - private AVMSyncService fAVMSyncService; - - /** - * Default constructor. - */ - public SimpleAVMPromoteAction() - { - super(); - } - - /** - * Set the AVMSyncService instance. - * @param avmSyncService - */ - public void setAvmSyncService(AVMSyncService avmSyncService) - { - fAVMSyncService = avmSyncService; - } - - /** - * Do a promotion of an asset from one sandbox to another. - * Takes a mandatory parameter 'target-store' which is the name of the - * target AVMStore. - * @param action The source of parameters. - * @param actionedUponNodeRef The source AVM NodeRef. - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - String targetStoreName = (String)action.getParameterValue(PARAM_TARGET_STORE); - // Crack the NodeRef. - Pair 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); - } - // Compute the corresponding target path. - String targetPath = targetStoreName + ":" + storePath[1]; - // Find the differences. - List diffs = - fAVMSyncService.compare(version, path, -1, targetPath, null); - // TODO fix update comments at some point. - // Do the promote. - fAVMSyncService.update(diffs, null, true, true, false, false, null, null); - // Flatten the source on top of the destination. - fAVMSyncService.flatten(storePath[0] + ":/" + JNDIConstants.DIR_DEFAULT_WWW, - targetStoreName + ":/" + JNDIConstants.DIR_DEFAULT_WWW); - } - - /** - * Define needed parameters. - * @param paramList The List of ParameterDefinitions to add to. - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_TARGET_STORE, - DataTypeDefinition.TEXT, - true, - getParamDisplayLabel(PARAM_TARGET_STORE))); - } -} diff --git a/source/java/org/alfresco/repo/avm/actions/StartAVMWorkflowAction.java b/source/java/org/alfresco/repo/avm/actions/StartAVMWorkflowAction.java deleted file mode 100644 index cc74b3db59..0000000000 --- a/source/java/org/alfresco/repo/avm/actions/StartAVMWorkflowAction.java +++ /dev/null @@ -1,152 +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 . - */ -package org.alfresco.repo.avm.actions; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.repo.workflow.WorkflowModel; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.cmr.workflow.WorkflowDefinition; -import org.alfresco.service.cmr.workflow.WorkflowPath; -import org.alfresco.service.cmr.workflow.WorkflowService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * This action knows how to start an AVM specific workflow. - * @author britt - * - * @deprecated - */ -public class StartAVMWorkflowAction extends ActionExecuterAbstractBase -{ - private static Log fgLogger = LogFactory.getLog(StartAVMWorkflowAction.class); - - public static final String NAME = "start-avm-workflow"; - public static final String PARAM_WORKFLOW_NAME = "workflow-name"; - - /** - * Reference to workflow service. - */ - private WorkflowService fWorkflowService; - - /** - * Reference to person service. - */ - private PersonService fPersonService; - - /** - * Set the workflow service. - * @param service The workflow service. - */ - public void setWorkflowService(WorkflowService service) - { - fWorkflowService = service; - } - - /** - * Set the person service. - * @param service The person service. - */ - public void setPersonService(PersonService service) - { - fPersonService = service; - } - - /** - * Default constructor. - */ - public StartAVMWorkflowAction() - { - super(); - } - - /** - * Start an AVM specific workflow. - * @param action The action instance. - * @param actionedUponNodeRef This should be an AVM folder that contains - * the nodes to be flowed. - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - String workflowName = (String)action.getParameterValue(PARAM_WORKFLOW_NAME); - WorkflowDefinition def = fWorkflowService.getDefinitionByName(workflowName); - Map wfParams = new HashMap(); - wfParams.put(WorkflowModel.ASSOC_PACKAGE, actionedUponNodeRef); -// ArrayList assigneeList = new ArrayList(); -// assigneeList.add(fPersonService.getPerson("admin")); -// wfParams.put(QName.createQName("http://www.alfresco.org/model/wcmwf/1.0", "assignee"), -// assigneeList); - wfParams.put(QName.createQName("http://www.alfresco.org/model/wcmwf/1.0", "description"), - "This performs a submit."); - wfParams.put(WorkflowModel.PROP_CONTEXT, actionedUponNodeRef); - for (QName name : wfParams.keySet()) - { - fgLogger.error(name); - fgLogger.error(wfParams.get(name).getClass()); - fgLogger.error(wfParams.get(name)); - } - WorkflowPath path = fWorkflowService.startWorkflow(def.id, wfParams); - /* - if (path != null) - { - fgLogger.error("Workflow path is not null."); - // extract the start task - List tasks = fWorkflowService.getTasksForWorkflowPath(path.id); - fgLogger.error(tasks.size() + " tasks."); - if (tasks.size() == 1) - { - WorkflowTask startTask = tasks.get(0); - - if (startTask.state == WorkflowTaskState.IN_PROGRESS) - { - fgLogger.error("Calling End Task."); - // end the start task to trigger the first 'proper' - // task in the workflow - fWorkflowService.endTask(startTask.id, null); - } - } - } - */ - } - - /** - * Setup any parameters for this action. - * @param paramList The list of parameters to add to. - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_WORKFLOW_NAME, - DataTypeDefinition.TEXT, - true, - getParamDisplayLabel(PARAM_WORKFLOW_NAME))); - } -} diff --git a/source/java/org/alfresco/repo/avm/locking/AVMLockingServiceImpl.java b/source/java/org/alfresco/repo/avm/locking/AVMLockingServiceImpl.java deleted file mode 100644 index ddb4a268cd..0000000000 --- a/source/java/org/alfresco/repo/avm/locking/AVMLockingServiceImpl.java +++ /dev/null @@ -1,518 +0,0 @@ -/* - * 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 . - */ - -package org.alfresco.repo.avm.locking; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.WCMAppModel; -import org.alfresco.repo.domain.avm.AVMLockDAO; -import org.alfresco.service.cmr.attributes.AttributeService; -import org.alfresco.service.cmr.attributes.DuplicateAttributeException; -import org.alfresco.service.cmr.avm.AVMBadArgumentException; -import org.alfresco.service.cmr.avm.locking.AVMLockingException; -import org.alfresco.service.cmr.avm.locking.AVMLockingService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.util.ParameterCheck; -import org.alfresco.wcm.util.WCMUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Implementation of the lock service. - * - * @author Derek Hulley, janv - */ -public class AVMLockingServiceImpl implements AVMLockingService -{ - public static final String KEY_AVM_LOCKS = ".avm_locks"; - public static final String KEY_LOCK_OWNER = "lock-owner"; - - private static final String ROLE_CONTENT_MANAGER = "ContentManager"; - - private static final Log logger = LogFactory.getLog(AVMLockingServiceImpl.class); - - private String webProjectStore; - private SearchService searchService; - private AttributeService attributeService; - private AuthorityService authorityService; - private PersonService personService; - private NodeService nodeService; - - private AVMLockDAO avmLockDAO; - - /** - * @param webProjectStore The webProjectStore to set - */ - public void setWebProjectStore(String webProjectStore) - { - this.webProjectStore = webProjectStore; - } - - /** - * @param attributeService the service to persist attributes - */ - public void setAttributeService(AttributeService attributeService) - { - this.attributeService = attributeService; - } - - /** - * @param authorityService the service to check validity of usernames - */ - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - /** - * @param personService checks validity of person names - */ - public void setPersonService(PersonService personService) - { - this.personService = personService; - } - - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setAvmLockDAO(AVMLockDAO avmLockDAO) - { - this.avmLockDAO = avmLockDAO; - } - - /** - * Appends the lock owner to the lock data. - */ - private HashMap createLockAttributes(String lockOwner, Map lockData) - { - HashMap lockAttributes = new HashMap(lockData); - lockAttributes.put(KEY_LOCK_OWNER, lockOwner); - return lockAttributes; - } - - /** - * {@inheritDoc} - */ - public void lock(String avmStore, String path, String lockOwner, Map lockData) - { - ParameterCheck.mandatoryString("avmStore", avmStore); - ParameterCheck.mandatoryString("path", path); - ParameterCheck.mandatoryString("lockOwner", lockOwner); - path = AVMLockingServiceImpl.normalizePath(path); - - if (!authorityService.authorityExists(lockOwner) && - !personService.personExists(lockOwner)) - { - throw new AVMBadArgumentException("Not an Authority: " + lockOwner); - } - - LockState lockState = getLockState(avmStore, path, lockOwner); - switch (lockState) - { - case LOCK_NOT_OWNER: - throw new AVMLockingException("avmlockservice.locked", path, lockOwner); - case NO_LOCK: - // Lock it, assuming that the lock doesn't exist (concurrency-safe). - try - { - HashMap lockAttributes = createLockAttributes(lockOwner, lockData); - attributeService.createAttribute( - lockAttributes, - KEY_AVM_LOCKS, avmStore, path); - } - catch (DuplicateAttributeException e) - { - String currentLockOwner = getLockOwner(avmStore, path); - // Should trigger a retry, hence we pass the exception out - throw new AVMLockingException(e, "avmlockservice.locked", path, currentLockOwner); - } - break; - case LOCK_OWNER: - // Nothing to do - break; - } - } - - /** - * {@inheritDoc} - */ - public boolean modifyLock( - String avmStore, String path, String lockOwner, - String newAvmStore, String newPath, - Map lockData) - { - ParameterCheck.mandatoryString("avmStore", avmStore); - ParameterCheck.mandatoryString("path", path); - ParameterCheck.mandatoryString("lockOwner", lockOwner); - ParameterCheck.mandatoryString("newAvmStore", newAvmStore); - ParameterCheck.mandatoryString("newPath", newPath); - path = AVMLockingServiceImpl.normalizePath(path); - newPath = AVMLockingServiceImpl.normalizePath(newPath); - - LockState currentLockState = getLockState(avmStore, path, lockOwner); - switch (currentLockState) - { - case LOCK_NOT_OWNER: - case LOCK_OWNER: - // Remove the lock first - attributeService.removeAttribute(KEY_AVM_LOCKS, avmStore, path); - HashMap lockAttributes = createLockAttributes(lockOwner, lockData); - attributeService.setAttribute( - lockAttributes, - KEY_AVM_LOCKS, newAvmStore, newPath); - return true; - case NO_LOCK: - // Do nothing - return false; - default: - throw new IllegalStateException("Unexpected enum constant"); - } - } - - /** - * {@inheritDoc} - */ - public String getLockOwner(String avmStore, String path) - { - ParameterCheck.mandatoryString("path", path); - path = AVMLockingServiceImpl.normalizePath(path); - - Map lockAttributes = getLockData(avmStore, path); - if (lockAttributes == null) - { - return null; - } - else if (!lockAttributes.containsKey(KEY_LOCK_OWNER)) - { - logger.warn("AVM lock does not have a lock owner: " + avmStore + "-" + path); - return null; - } - return lockAttributes.get(KEY_LOCK_OWNER); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public Map getLockData(String avmStore, String path) - { - ParameterCheck.mandatoryString("avmStore", avmStore); - ParameterCheck.mandatoryString("path", path); - path = AVMLockingServiceImpl.normalizePath(path); - - Map lockAttributes = (Map) attributeService.getAttribute( - KEY_AVM_LOCKS, avmStore, path); - return lockAttributes; - } - - /** - * {@inheritDoc} - */ - public LockState getLockState(String avmStore, String path, String lockOwner) - { - ParameterCheck.mandatoryString("avmStore", avmStore); - ParameterCheck.mandatoryString("lockOwner", lockOwner); - path = AVMLockingServiceImpl.normalizePath(path); - - String currentLockOwner = getLockOwner(avmStore, path); - if (currentLockOwner == null) - { - return LockState.NO_LOCK; - } - else if (currentLockOwner.equals(lockOwner)) - { - return LockState.LOCK_OWNER; - } - else - { - return LockState.LOCK_NOT_OWNER; - } - } - - /** - * {@inheritDoc} - */ - public void removeLock(String avmStore, String path) - { - ParameterCheck.mandatoryString("avmStore", avmStore); - ParameterCheck.mandatoryString("path", path); - path = AVMLockingServiceImpl.normalizePath(path); - - attributeService.removeAttribute(KEY_AVM_LOCKS, avmStore, path); - } - - /** - * {@inheritDoc} - */ - public void removeLocks(String avmStore) - { - ParameterCheck.mandatoryString("avmStore", avmStore); - - attributeService.removeAttributes(KEY_AVM_LOCKS, avmStore); - } - - /** - * {@inheritDoc} - */ - public void removeLocks(String avmStore, String dirPath, final Map lockDataToMatch) - { - ParameterCheck.mandatoryString("avmStore", avmStore); - ParameterCheck.mandatory("lockDataToMatch", lockDataToMatch); - - final String dirPathStart; - if (dirPath == null) - { - dirPathStart = null; - } - else - { - dirPath = normalizePath(dirPath); - if (! dirPath.endsWith("/")) - { - dirPath = dirPath + '/'; - } - - dirPathStart = dirPath; - } - - // optimised to delete with single DB query - avmLockDAO.removeLocks(avmStore, dirPathStart, lockDataToMatch); - } - - /** - * {@inheritDoc} - */ - public void removeLocks(String avmStore, final Map lockDataToMatch) - { - removeLocks(avmStore, null, lockDataToMatch); - } - - /** - * {@inheritDoc} - */ - public boolean hasAccess(String webProject, String avmPath, String lockOwner) - { - if (personService.getPerson(lockOwner) == null && !authorityService.authorityExists(lockOwner)) - { - return false; - } - if (authorityService.isAdminAuthority(lockOwner)) - { - return true; - } - StoreRef storeRef = new StoreRef(this.webProjectStore); - ResultSet results = searchService.query( - storeRef, - SearchService.LANGUAGE_LUCENE, - "@wca\\:avmstore:\"" + webProject + '"'); - try - { - if (results.getNodeRefs().size() == 1) - { - return hasAccess(webProject, results.getNodeRefs().get(0), avmPath, lockOwner); - } - return false; - } - finally - { - results.close(); - } - } - - /** - * {@inheritDoc} - */ - public boolean hasAccess(NodeRef webProjectRef, String avmPath, String lockOwner) - { - if (personService.getPerson(lockOwner) == null && - !authorityService.authorityExists(lockOwner)) - { - return false; - } - if (authorityService.isAdminAuthority(lockOwner)) - { - return true; - } - String webProject = (String)nodeService.getProperty(webProjectRef, WCMAppModel.PROP_AVMSTORE); - return hasAccess(webProject, webProjectRef, avmPath, lockOwner); - } - - private boolean hasAccess(String webProject, NodeRef webProjectRef, String avmPath, String lockOwner) - { - String[] storePath = avmPath.split(":"); - if (storePath.length != 2) - { - throw new AVMBadArgumentException("Malformed AVM Path : " + avmPath); - } - - if (logger.isDebugEnabled()) - logger.debug( - "Testing lock access on path: " + avmPath + - " for user: " + lockOwner + " in webproject: " + webProject); - - // check if a lock exists at all for this path in the specified webproject id - String path = normalizePath(storePath[1]); - - Map lockData = getLockData(webProject, path); - - if (lockData == null) - { - if (logger.isDebugEnabled()) - logger.debug(" GRANTED: No lock found."); - return true; - } - - String currentLockOwner = lockData.get(KEY_LOCK_OWNER); - String currentLockStore = lockData.get(WCMUtil.LOCK_KEY_STORE_NAME); - - - // locks are ignored in a workflow store - if (storePath[0].contains("--workflow")) - { - if (logger.isDebugEnabled()) - logger.debug(" GRANTED: Workflow store path."); - return true; - } - - // locks are specific to a store - no access if the stores are different - if (! ((currentLockStore != null) && (currentLockStore.equals(storePath[0])))) - { - if (logger.isDebugEnabled()) - logger.debug(" DENIED: Store on path and lock (" + currentLockStore + ") do not match."); - return false; - } - - // check for content manager role - we allow access to all managers within the same store - // TODO as part of WCM refactor, consolidate with WebProject.getWebProjectUserRole - StringBuilder query = new StringBuilder(128); - query.append("+PARENT:\"").append(webProjectRef).append("\" "); - query.append("+TYPE:\"").append(WCMAppModel.TYPE_WEBUSER).append("\" "); - query.append("+@").append(NamespaceService.WCMAPP_MODEL_PREFIX).append("\\:username:\""); - query.append(lockOwner); - query.append("\""); - ResultSet resultSet = null; - List nodes =null; - - try - { - resultSet = searchService.query( - new StoreRef(this.webProjectStore), - SearchService.LANGUAGE_LUCENE, - query.toString()); - nodes = resultSet.getNodeRefs(); - } - finally - { - if (resultSet != null) {resultSet.close();} - } - if (nodes.size() == 1) - { - String userrole = (String)nodeService.getProperty(nodes.get(0), WCMAppModel.PROP_WEBUSERROLE); - if (ROLE_CONTENT_MANAGER.equals(userrole)) - { - if (logger.isDebugEnabled()) - { - logger.debug("GRANTED: Store match and user is ContentManager role in webproject."); - } - return true; - } - } - else if (nodes.size() == 0) - { - logger.warn("hasAccess: user role not found for " + lockOwner); - } - else - { - logger.warn("hasAccess: more than one user role found for " + lockOwner); - } - - // finally check the owner of the lock against the specified authority - if (AuthorityType.getAuthorityType(currentLockOwner) == AuthorityType.EVERYONE) - { - if (logger.isDebugEnabled()) - logger.debug(" GRANTED: Authority EVERYONE matched lock owner."); - return true; - } - - if (checkAgainstAuthority(lockOwner, currentLockOwner)) - { - if (logger.isDebugEnabled()) - logger.debug(" GRANTED: User matched as lock owner."); - return true; - } - - if (logger.isDebugEnabled()) - logger.debug(" DENIED: User did not match as lock owner."); - return false; - } - - /** - * Helper function that checks the transitive closure of authorities for user. - */ - private boolean checkAgainstAuthority(String user, String authority) - { - if (user.equalsIgnoreCase(authority)) - { - return true; - } - return authorityService.getAuthoritiesForUser(user).contains(authority); - } - - /** - * Utility to get relative paths into canonical lock form - * - * - remove first forward slash - * - multiple forward slashes collapsed into single foward slash - * - * @param path The incoming path. - * @return The normalized path. - */ - public static String normalizePath(String path) - { - path = path.toLowerCase(); // note: enables optimised removal of locks (based on path dir start) - - while (path.startsWith("/")) - { - path = path.substring(1); - } - while (path.endsWith("/")) - { - path = path.substring(0, path.length() - 1); - } - return path.replaceAll("/+", "/"); - } -} diff --git a/source/java/org/alfresco/repo/avm/util/AVMUtil.java b/source/java/org/alfresco/repo/avm/util/AVMUtil.java deleted file mode 100644 index 4d795fe727..0000000000 --- a/source/java/org/alfresco/repo/avm/util/AVMUtil.java +++ /dev/null @@ -1,151 +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 . - */ -package org.alfresco.repo.avm.util; - -import org.alfresco.service.cmr.avm.AVMBadArgumentException; -import org.alfresco.service.cmr.avm.AVMException; - - -/** - * Helper methods and constants related to AVM (not WCM-specific) - * - * @author janv - */ -public class AVMUtil -{ - /** - * Utility to get AVM store name from AVM path, for example "foo:/bar/baz" returns "foo" - * - * @param avmPath - * @return - */ - public static String getStoreName(String avmPath) - { - int i = avmPath.indexOf(AVM_STORE_SEPARATOR_CHAR); - if (i == -1) - { - throw new AVMBadArgumentException("path " + avmPath + " does not contain a store"); - } - return avmPath.substring(0, i); - } - - /** - * Utility to split an AVM path, for example "foo:/bar/baz", into its AVM repository store name ("foo") and path ("/bar/baz") parts. - * - * @param path The fully qualified path. - * @return The store name and the store relative path. - */ - public static String[] splitPath(String path) - { - String[] pathParts = path.split(AVM_STORE_SEPARATOR); - if (pathParts.length != 2) - { - throw new AVMBadArgumentException("Invalid path: " + path); - } - return pathParts; - } - - /** - * Split a path into its parent path and its base name. If the store root path is passed, then return [null, ""]. - * - * @param path The initial AVM path. - * - * @return An array of 2 Strings containing the parent AVM path (or null) and the base - * name. - */ - public static String[] splitBase(String path) - { - path = path.replaceAll("/+", AVM_PATH_SEPARATOR); - while (path.endsWith(AVM_PATH_SEPARATOR) && !path.endsWith(AVM_STORE_PATH_SEPARATOR)) - { - // ends with "/" not ":/" - path = path.substring(0, path.length() - 1); - } - if (path.endsWith(AVM_STORE_PATH_SEPARATOR)) - { - // end with ":/" - return new String[] { null, "" }; - } - int off = path.lastIndexOf(AVM_PATH_SEPARATOR); - if (off == -1) - { - throw new AVMException("Invalid Path: " + path); - } - String [] decomposed = new String[2]; - decomposed[0] = path.substring(0, off); - if (decomposed[0].charAt(decomposed[0].length()-1) == AVM_STORE_SEPARATOR_CHAR) - { - decomposed[0] = decomposed[0] + AVM_PATH_SEPARATOR_CHAR; - } - decomposed[1] = path.substring(off + 1); - return decomposed; - } - - public static String buildAVMPath(String storeName, String storeRelativePath) - { - // note: assumes storeRelativePath is not null and does not contain ':', although will add leading slash (if missing) - StringBuilder builder = new StringBuilder(); - builder.append(storeName).append(AVMUtil.AVM_STORE_SEPARATOR_CHAR); - if ((storeRelativePath.length() == 0) || (storeRelativePath.charAt(0) != AVM_PATH_SEPARATOR_CHAR)) - { - builder.append(AVM_PATH_SEPARATOR_CHAR); - } - builder.append(storeRelativePath); - return builder.toString(); - } - - public static String extendAVMPath(String path, String name) - { - if (path.endsWith(AVM_PATH_SEPARATOR)) - { - return path + name; - } - else - { - return path + AVM_PATH_SEPARATOR_CHAR + name; - } - } - - public static String normalizePath(String path) - { - path = path.replaceAll("/+", AVM_PATH_SEPARATOR); - path = path.replaceAll("/$", ""); - return path; - } - - public static String addLeadingSlash(String relativePath) - { - if ((relativePath.length() == 0) || (relativePath.charAt(0) != AVM_PATH_SEPARATOR_CHAR)) - { - relativePath = AVM_PATH_SEPARATOR_CHAR + relativePath; - } - - return relativePath; - } - - public static final char AVM_PATH_SEPARATOR_CHAR = '/'; - public static final String AVM_PATH_SEPARATOR = AVM_PATH_SEPARATOR_CHAR+""; - - public static final char AVM_STORE_SEPARATOR_CHAR = ':'; - public static final String AVM_STORE_SEPARATOR = AVM_STORE_SEPARATOR_CHAR+""; - - private static final String AVM_STORE_PATH_SEPARATOR = AVM_STORE_SEPARATOR_CHAR+AVM_PATH_SEPARATOR; - - public static final String INITIAL_SNAPSHOT = "Initial Empty Version."; -} diff --git a/source/java/org/alfresco/repo/avm/util/BulkLoader.java b/source/java/org/alfresco/repo/avm/util/BulkLoader.java deleted file mode 100644 index 837aab48d3..0000000000 --- a/source/java/org/alfresco/repo/avm/util/BulkLoader.java +++ /dev/null @@ -1,144 +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 . */ - -package org.alfresco.repo.avm.util; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.repo.avm.AVMRemoteLocal; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.service.cmr.avm.AVMException; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.remote.AVMRemote; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; - -/** - * This takes a filesystem directory path and a repository path and name - * and bulk loads recursively from the filesystem. - * @author britt - */ -public class BulkLoader -{ - private AVMRemote fService; - - private int fPropertyCount = 0; - - /** - * Create a new one. - */ - public BulkLoader() - { - } - - /** - * Set the AVMService. - * @param service - */ - public void setAvmService(AVMService service) - { - fService = new AVMRemoteLocal(); - ((AVMRemoteLocal)fService).setAvmService(service); - - } - - /** - * Set the AVMService. - * @param service - */ - protected void setAvmRemoteService(AVMRemote service) - { - fService = service; - } - - public void setPropertyCount(int propCount) - { - fPropertyCount = propCount; - } - - /** - * Recursively load content. - * @param fsPath The path in the filesystem. - * @param repPath - */ - public void recursiveLoad(String fsPath, String repPath) - { - Pair cnts = recursiveLoadImpl(fsPath, repPath, 0, 0); - - System.out.println("Loaded: "+cnts.getFirst()+" directories, "+cnts.getSecond()+" files"); - } - private Pair recursiveLoadImpl(String fsPath, String repPath, int dirCount, int fileCount) - { - Map props = new HashMap(); - for (int i = 0; i < fPropertyCount; i++) - { - props.put(QName.createQName("silly", "prop" + i), new PropertyValue(DataTypeDefinition.TEXT, "I am property " + i)); - } - File file = new File(fsPath); - String name = file.getName(); - if (file.isDirectory()) - { - fService.createDirectory(repPath, name); - dirCount++; - - String[] children = file.list(); - String baseName = repPath.endsWith("/") ? repPath + name : repPath + "/" + name; - fService.setNodeProperties(baseName, props); - for (String child : children) - { - Pair cnts = recursiveLoadImpl(fsPath + "/" + child, baseName, dirCount, fileCount); - dirCount = cnts.getFirst(); - fileCount = cnts.getSecond(); - } - - return new Pair(dirCount, fileCount); - } - else - { - try - { - InputStream in = new FileInputStream(file); - OutputStream out = fService.createFile(repPath, name); - fileCount++; - fService.setNodeProperties(repPath + "/" + name, props); - byte[] buff = new byte[8192]; - int read = 0; - while ((read = in.read(buff)) != -1) - { - out.write(buff, 0, read); - } - out.close(); - in.close(); - - return new Pair(dirCount, fileCount); - } - catch (IOException e) - { - e.printStackTrace(System.err); - throw new AVMException("I/O Error", e); - } - } - } -} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/avm/util/BulkReader.java b/source/java/org/alfresco/repo/avm/util/BulkReader.java deleted file mode 100644 index 56698de2d0..0000000000 --- a/source/java/org/alfresco/repo/avm/util/BulkReader.java +++ /dev/null @@ -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 . - */ - -package org.alfresco.repo.avm.util; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Random; - -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMService; - -/** - * Testing utility class. Reads a tree recursively. - * @author britt - */ -public class BulkReader -{ - private AVMService fService; - - public BulkReader() - { - } - - public void setAvmService(AVMService service) - { - fService = service; - } - - public void recursiveFutz(String store, String path, int futz) - { - List paths = new ArrayList(); - recursiveRead(path, paths); - Random random = new Random(System.currentTimeMillis()); - int futzed = 0; - while (futzed < futz) - { - String futzPath = paths.get(random.nextInt(paths.size())); - AVMNodeDescriptor desc = fService.lookup(-1, futzPath); - if (desc.isFile()) - { - try - { - fService.getFileOutputStream(futzPath).close(); - } - catch (IOException e) - { - // Do nothing. - } - futzed++; - } - } - fService.createSnapshot(store, null, null); - } - - public void recursiveRead(String path, List paths) - { - AVMNodeDescriptor desc = fService.lookup(-1, path); - paths.add(desc.getPath()); - if (desc.isFile()) - { - InputStream in = fService.getFileInputStream(desc); - try - { - byte[] buff = new byte[8192]; - while (in.read(buff) != -1); - in.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - return; - } - Map listing = fService.getDirectoryListing(desc); - for (Map.Entry entry : listing.entrySet()) - { - recursiveRead(entry.getValue().getPath(), paths); - } - } -} diff --git a/source/java/org/alfresco/repo/avm/util/FileExtensionNameMatcher.java b/source/java/org/alfresco/repo/avm/util/FileExtensionNameMatcher.java deleted file mode 100644 index 26d83e7c5a..0000000000 --- a/source/java/org/alfresco/repo/avm/util/FileExtensionNameMatcher.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.avm.util; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.util.NameMatcher; - -/** - * NameMatcher that matches a list of extensions (case insensitively). - * @author britt - */ -public class FileExtensionNameMatcher implements NameMatcher, Serializable -{ - private static final long serialVersionUID = -1498029477935181998L; - - /** - * The extensions to match. - */ - private List fExtensions; - - /** - * Default constructor. - */ - public FileExtensionNameMatcher() - { - fExtensions = new ArrayList(); - } - - /** - * Set the extensions case insensitively. - * @param extensions - */ - public void setExtensions(List extensions) - { - for (String extension : extensions) - { - fExtensions.add(extension.toLowerCase()); - } - } - - /* (non-Javadoc) - * @see org.alfresco.util.NameMatcher#matches(java.lang.String) - */ - public boolean matches(String name) - { - String lcName = name.toLowerCase(); - for (String ext : fExtensions) - { - if (lcName.endsWith(ext)) - { - return true; - } - } - return false; - } -} diff --git a/source/java/org/alfresco/repo/avm/util/RemoteBulkLoader.java b/source/java/org/alfresco/repo/avm/util/RemoteBulkLoader.java deleted file mode 100644 index 5c5b8882db..0000000000 --- a/source/java/org/alfresco/repo/avm/util/RemoteBulkLoader.java +++ /dev/null @@ -1,36 +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 . */ - -package org.alfresco.repo.avm.util; - -import org.alfresco.service.cmr.remote.AVMRemote; - -/** - * - */ -public class RemoteBulkLoader extends BulkLoader -{ - /** - * Set the AVMService. - * @param service - */ - public void setAvmRemoteService(AVMRemote service) - { - super.setAvmRemoteService(service); - } -} diff --git a/source/java/org/alfresco/repo/avm/util/SimplePath.java b/source/java/org/alfresco/repo/avm/util/SimplePath.java deleted file mode 100644 index 46b7e6eaa0..0000000000 --- a/source/java/org/alfresco/repo/avm/util/SimplePath.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.avm.util; - -import java.io.Serializable; - -/** - * Holds a simple path. - * @author britt - */ -public class SimplePath implements Serializable -{ - private static final long serialVersionUID = 2696828491008988470L; - - /** - * The names of the path's components. - */ - private String [] fNames; - - /** - * Construct a new one from a string. - * @param path The String representation of the path. - */ - public SimplePath(String path) - { - if (path.length() == 0) - { - fNames = new String[0]; - return; - } - while (path.startsWith("/")) - { - path = path.substring(1); - } - while (path.endsWith("/")) - { - path = path.substring(0, path.length() - 1); - } - fNames = path.split("/+"); - } - - /** - * Get the component name at index. - * @param index The index of the component to get. - * @return The name of the component. - */ - public String get(int index) - { - return fNames[index]; - } - - /** - * Get the number of components in this path. - * @return The number of components. - */ - public int size() - { - return fNames.length; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (!(obj instanceof SimplePath)) - { - return false; - } - SimplePath o = (SimplePath)obj; - if (fNames.length != o.fNames.length) - { - return false; - } - for (int i = 0; i < fNames.length; i++) - { - if (!fNames[i].equalsIgnoreCase(o.fNames[i])) - { - return false; - } - } - return true; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() - { - int hash = 0; - for (String name : fNames) - { - hash += name.toLowerCase().hashCode(); - } - return hash; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - for (String name : fNames) - { - builder.append('/'); - builder.append(name); - } - return builder.toString(); - } -} diff --git a/source/java/org/alfresco/repo/avm/util/UriSchemeNameMatcher.java b/source/java/org/alfresco/repo/avm/util/UriSchemeNameMatcher.java deleted file mode 100644 index 93bdf10f2d..0000000000 --- a/source/java/org/alfresco/repo/avm/util/UriSchemeNameMatcher.java +++ /dev/null @@ -1,201 +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 . -* -* -* Author Jon Cox -* File UriSchemeNameMatcher.java -*----------------------------------------------------------------------------*/ - -package org.alfresco.repo.avm.util; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; - -import org.alfresco.util.NameMatcher; - -/** - * A NameMatcher that matches an incoming URL against list of schemes - * (less formally known as "protocols"), case insensitively. - * The formal spec for parsing URIs is RFC-3986 - *

- * Perhaps someday, it might be worthwhile to create a specific - * parser for each registered scheme-specific part, and validate - * that; for now, we'll just be be more lax, and assume the URI - * is alwasy scheme-qualified. This matcher will look no further - * than the leading colon, and declare "no match" otherwise. - * The discussion below explains why. - *

- * See: http://tools.ietf.org/html/rfc3986): - *

- *  The following regex parses URIs:
- *       ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
- *
- *  Given the following URI:   
- *        http://www.ics.uci.edu/pub/ietf/uri/#Related
- *
- *  The captured subexpressions are:
- *
- *        $1 = http:
- *        $2 = http
- *        $3 = //www.ics.uci.edu
- *        $4 = www.ics.uci.edu
- *        $5 = /pub/ietf/uri/
- *        $6 = 
- *        $7 = 
- *        $8 = #Related
- *        $9 = Related   
- *
- *   N0TE:
- *      A URI can be non-scheme qualified because $1 is optional.  Therefore,
- *      the following are all exaples of valid non-scheme qualified URIS:
- *
- *         ""
- *         "moo@cow.com"
- *         "moo@cow.com?wow"
- *         "moo@cow.com?wow#zow"
- *         "moo@cow.com#zow"
- *         "/"
- *         "/moo/cow"
- *         "/moo/cow?wow"
- *         "/moo/cow?wow#zow"
- *         "/moo/cow#zow"
- *         "//moo/cow"
- *         "//moo.com/cow"
- *         "//moo.com/cow/"
- *         "//moo.com/cow?wow"
- *         "//moo.com/cow?wow#zow"
- *         "//moo.com/cow#zow"
- *         "//moo.com:8080/cow"
- *         "//moo.com:/cow"
- *         "//moo.com:8080/cow?wow"
- *         "//moo.com:8080/cow?wow#zow"
- *         "//moo.com:8080/cow#zow"
- *         "///moo/cow"
- *         "///moo/cow?wow"
- *         "///moo/cow?wow#zow"
- *         "///moo/cow#zow"
- *
- *      And so forth...
- *      
- * 
- *
- *  Thus the business end of things as far as scheme matching is: $2,
- *  Most schemes will have a $3 that starts with '//', but not all.
- *  Specificially, the following have no "network path '//' segment,
- *  or aren't required to (source: http://en.wikipedia.org/wiki/URI_scheme):
- *  
- *
- *      cid data dns fax go h323 iax2 mailto mid news pres sip
- *      sips tel urn xmpp about aim callto feed magnet msnim 
- *      psyc skype sms stream xfire ymsgr
- *
- *  
- * - * Visually the parts are as follows: - *
- * 
- *         foo://example.com:10042/over/there?name=ferret#nose
- *         \_/   \_______________/\_________/ \_________/ \__/
- *          |           |            |            |        |
- *       scheme     authority       path        query   fragment
- *          |   _____________________|__
- *         / \ /                        \
- *         urn:example:animal:ferret:nose
- *
- * 
- * - * This is useful for classifying URLs for things like whether or not - * they're supported by an application. - * - * For example, the LinkValidationService supports http, and https, - * is willing to ignore certain well-formed URLs, but treats URLs - * will unknown and unsupported protocols as broken. Concretely, - * we'd like to avoid treating something like the following one - * as being non-broken even though you can't apply GET or HEAD - * to it. - * - *
- * Email
- * 
- * - * As of June 2007,IANA had over 70 registered and provisional protocols - * listed at http://www.iana.org/assignments/uri-schemes.html but sometimes - * people create their own too (e.g.: cvs). Here's the official list: - *
- *
- *    aaa aaas acap afs cap cid crid data dav dict dns dtn fax file
- *    ftp go gopher h323 http https iax2 icap im imap info ipp iris
- *    iris.beep iris.lwz iris.xpc iris.xpcs ldap mailserver mailto
- *    mid modem msrp msrps mtqp mupdate news nfs nntp opaquelocktoken
- *    pop pres prospero rtsp service shttp sip sips snmp soap.beep
- *    soap.beeps tag tel telnet tftp thismessage tip tn3270 tv urn
- *    vemmi wais xmlrpc.beep xmlrpc.beeps xmpp z39.50r z39.50s
- * 
- * - */ -public class UriSchemeNameMatcher implements NameMatcher, Serializable -{ - /** - * The extensions to match. - */ - HashMap scheme_; - - /** - * Default constructor. - */ - public UriSchemeNameMatcher() - { - scheme_ = new HashMap(); - } - - /** - * Set the protocols case insensitively (cannonicalized to lower-case). - * - * @param protocols - */ - public void setExtensions(List protocols) - { - for (String protocol : protocols) - { - scheme_.put( protocol.toLowerCase(), null ); - } - } - - /** - * Returns true if the URL's protocol is in the of - * being matched. Everything up to but not including - * the intial colon is - */ - public boolean matches(String uri) - { - if ( uri == null ) { return false; } - - int colon_index = uri.indexOf(':'); - - if ( colon_index >= 0) - { - String proto = - uri.substring(0, colon_index).toLowerCase(); - - return scheme_.containsKey( proto ); - } - return false; - } -} - diff --git a/source/java/org/alfresco/repo/avm/util/VersionPathStuffer.java b/source/java/org/alfresco/repo/avm/util/VersionPathStuffer.java deleted file mode 100644 index 75723a8466..0000000000 --- a/source/java/org/alfresco/repo/avm/util/VersionPathStuffer.java +++ /dev/null @@ -1,86 +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 . - */ -package org.alfresco.repo.avm.util; - -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.Pair; - -/** - * A utility to build a (possibly long) String representation of - * a collection of AVM path,versions. The path,versions can be recovered - * by VersionPathUnStuffer. - * @author britt - */ -public final class VersionPathStuffer -{ - /** - * The internal buffer. - */ - private StringBuilder fBuilder; - - /** - * Whether any paths have been added yet. - */ - private boolean fAnyAdded; - - /** - * Make up one. - */ - public VersionPathStuffer() - { - fBuilder = new StringBuilder(); - fAnyAdded = false; - } - - /** - * Add a version path expressed by the version and path. - */ - public VersionPathStuffer add(int version, String path) - { - if (fAnyAdded) - { - fBuilder.append(';'); - } - fBuilder.append(path); - fBuilder.append('@'); - fBuilder.append(version); - fAnyAdded = true; - return this; - } - - /** - * Add a version path expressed as a NodeRef. - */ - public VersionPathStuffer add(NodeRef nodeRef) - { - Pair versionPath = - AVMNodeConverter.ToAVMVersionPath(nodeRef); - add(versionPath.getFirst(), versionPath.getSecond()); - return this; - } - - /** - * Get the stuffed String version of the Version/Paths contained in this. - */ - public String toString() - { - return fBuilder.toString(); - } -} diff --git a/source/java/org/alfresco/repo/avm/util/VersionPathUnstuffer.java b/source/java/org/alfresco/repo/avm/util/VersionPathUnstuffer.java deleted file mode 100644 index 1ee9cdc695..0000000000 --- a/source/java/org/alfresco/repo/avm/util/VersionPathUnstuffer.java +++ /dev/null @@ -1,77 +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 . - */ -package org.alfresco.repo.avm.util; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.Pair; - -/** - * Takes a String representation of a list of Version/Paths (created - * by VersionPathStuffer) and gives you back a list of Version/Paths - * @author britt - */ -public final class VersionPathUnstuffer -{ - /** - * The unpacked version paths. - */ - private List> fVersionPaths; - - /** - * Construct one and in the process unstuff the String. - */ - public VersionPathUnstuffer(String stuffed) - { - fVersionPaths = new ArrayList>(); - String[] versionPaths = stuffed.split(";"); - for (String path : versionPaths) - { - String [] pathVersion = path.split("@"); - Pair item = - new Pair(new Integer(pathVersion[1]), - pathVersion[0]); - fVersionPaths.add(item); - } - } - - /** - * Get the raw list of Version/Paths. - */ - public List> getVersionPaths() - { - return fVersionPaths; - } - - /** - * Get the Version/Paths as NodeRefs. - */ - public List getNodeRefs() - { - List result = new ArrayList(); - for (Pair item : fVersionPaths) - { - result.add(AVMNodeConverter.ToNodeRef(item.getFirst(), item.getSecond())); - } - return result; - } -} diff --git a/source/java/org/alfresco/repo/clt/AVMCopyIn.java b/source/java/org/alfresco/repo/clt/AVMCopyIn.java deleted file mode 100644 index 23525c09b9..0000000000 --- a/source/java/org/alfresco/repo/clt/AVMCopyIn.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.clt; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; - -/** - * Like cp from a local filesystem to AVM. - * @author britt - */ -public class AVMCopyIn extends CltBase -{ - private static Object [] flagDefs = { "-r", 0, "-v", 0 }; - - private static String USAGE = "usage: [-r] [-v] sourcepath nodepath"; - - private boolean fVerbose; - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List) - */ - @Override - protected void run(Map> flags, List args) - { - if (flags.containsKey("-v")) - { - fVerbose = true; - } - else - { - fVerbose = false; - } - if (flags.containsKey("-r")) - { - recursiveCopy(args.get(0), args.get(1)); - return; - } - File file = new File(args.get(0)); - if (!file.isFile()) - { - System.err.println(args.get(0) + " not found, or not a file."); - fContext.close(); - System.exit(1); - } - AVMNodeDescriptor desc = fAVMRemote.lookup(-1, args.get(1)); - if (desc == null) - { - try - { - String [] pathBase = splitPath(args.get(1)); - if (pathBase.length == 1) - { - System.err.println(args.get(1) + " is a root path."); - fContext.close(); - System.exit(1); - } - if (fVerbose) - { - System.out.println(file.getName() + " -> " + pathBase[0]); - } - InputStream in = - new FileInputStream(file); - OutputStream out = fAVMRemote.createFile(pathBase[0], pathBase[1]); - - copyStream(in, out); - } - catch (IOException e) - { - e.printStackTrace(); - fContext.close(); - System.exit(1); - } - } - else - { - if (!desc.isDirectory()) - { - System.err.println("Target must be a directory."); - fContext.close(); - System.exit(1); - } - try - { - if (fVerbose) - { - System.out.println(file.getName() + " -> " + args.get(1)); - } - InputStream in = - new FileInputStream(file); - OutputStream out = - fAVMRemote.createFile(args.get(1), file.getName()); - copyStream(in, out); - } - catch (IOException e) - { - e.printStackTrace(); - fContext.close(); - System.exit(1); - } - } - } - - private void recursiveCopy(String sourcePath, String dest) - { - File file = new File(sourcePath); - if (fVerbose) - { - System.out.println(sourcePath + " -> " + dest); - } - if (file.isDirectory()) - { - fAVMRemote.createDirectory(dest, file.getName()); - String newDest = dest + '/' + file.getName(); - String [] names = file.list(); - for (String name : names) - { - recursiveCopy(sourcePath + File.separatorChar + name, - newDest); - } - } - else - { - try - { - InputStream in = - new FileInputStream(file); - OutputStream out = fAVMRemote.createFile(dest, file.getName()); - copyStream(in, out); - } - catch (IOException e) - { - e.printStackTrace(); - fContext.close(); - System.exit(1); - } - } - } - - public static void main(String[] args) - { - AVMCopyIn me = new AVMCopyIn(); - me.exec(args, flagDefs, 2, USAGE); - } -} diff --git a/source/java/org/alfresco/repo/clt/AVMCopyOut.java b/source/java/org/alfresco/repo/clt/AVMCopyOut.java deleted file mode 100644 index c3b99977a5..0000000000 --- a/source/java/org/alfresco/repo/clt/AVMCopyOut.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.clt; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.util.Pair; - -/** - * Copy out a file or a directory recursively from the repository - * to a local filesystem. - * @author britt - */ -public class AVMCopyOut extends CltBase -{ - private static Object [] flagDefs = { "-r", 0, "-v", 0 }; - - private static String USAGE = "usage: AVMCopyOut [-r] [-v] nodepath@version fspath"; - - private boolean fVerbose; - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List) - */ - @Override - protected void run(Map> flags, List args) - { - if (flags.containsKey("-v")) - { - fVerbose = true; - } - else - { - fVerbose = false; - } - Pair versionPath = splitPathVersion(args.get(0)); - String path = versionPath.getFirst(); - int version = versionPath.getSecond(); - AVMNodeDescriptor desc = fAVMRemote.lookup(version, path); - if (flags.containsKey("-r")) - { - recursiveCopy(desc, args.get(1)); - return; - } - if (desc == null) - { - System.err.println(path + " does not exist."); - fContext.close(); - System.exit(1); - } - if (!desc.isFile()) - { - System.err.println(path + " is not a file."); - fContext.close(); - System.exit(1); - } - File dest = new File(args.get(1)); - if (dest.exists()) - { - if (!dest.isDirectory()) - { - System.err.println("Destination must be a directory."); - fContext.close(); - System.exit(1); - } - try - { - InputStream in = fAVMRemote.getFileInputStream(version, path); - String [] parentBase = splitPath(path); - OutputStream out = new FileOutputStream(args.get(1) + File.separator + parentBase[1]); - copyStream(in, out); - } - catch (IOException e) - { - e.printStackTrace(); - fContext.close(); - System.exit(1); - } - } - else - { - try - { - InputStream in = fAVMRemote.getFileInputStream(version, path); - OutputStream out = new FileOutputStream(args.get(1)); - copyStream(in, out); - } - catch (IOException e) - { - e.printStackTrace(); - fContext.close(); - System.exit(1); - } - } - } - - private void recursiveCopy(AVMNodeDescriptor src, String dst) - { - String newDst = dst + File.separator + src.getName(); - if (fVerbose) - { - System.out.println(src.getPath() + " -> " + dst); - } - if (src.isDirectory()) - { - File destFile = new File(newDst); - destFile.mkdir(); - Map listing = fAVMRemote.getDirectoryListing(src); - for (AVMNodeDescriptor child : listing.values()) - { - recursiveCopy(child, newDst); - } - return; - } - try - { - InputStream in = fAVMRemote.getFileInputStream(src); - OutputStream out = new FileOutputStream(newDst); - copyStream(in, out); - } - catch (IOException e) - { - e.printStackTrace(); - fContext.close(); - System.exit(1); - } - } - - public static void main(String[] args) - { - AVMCopyOut me = new AVMCopyOut(); - me.exec(args, flagDefs, 2, USAGE); - } -} diff --git a/source/java/org/alfresco/repo/clt/AVMLs.java b/source/java/org/alfresco/repo/clt/AVMLs.java deleted file mode 100644 index 06797fe0ea..0000000000 --- a/source/java/org/alfresco/repo/clt/AVMLs.java +++ /dev/null @@ -1,93 +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 . - */ -package org.alfresco.repo.clt; - -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.util.Pair; - -/** - * Get a listing of a node. - * @author britt - */ -public class AVMLs extends CltBase -{ - private static Object [] flagDefs = { "-R", 0 }; - - private static String USAGE = "usage: AVMLs [-R] nodepath"; - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List) - */ - @Override - protected void run(Map> flags, List args) - { - Pair pathVersion = splitPathVersion(args.get(0)); - AVMNodeDescriptor desc = fAVMRemote.lookup(pathVersion.getSecond(), - pathVersion.getFirst()); - if (flags.containsKey("-R")) - { - recursiveList(desc, 0); - } - else - { - list(desc); - } - } - - private void list(AVMNodeDescriptor desc) - { - if (desc.isFile()) - { - System.out.println(desc.getName() + '\t' + desc); - return; - } - Map listing = fAVMRemote.getDirectoryListing(desc); - for (Map.Entry entry : listing.entrySet()) - { - System.out.println(entry.getKey() + '\t' + entry.getValue()); - } - } - - private void recursiveList(AVMNodeDescriptor desc, int indent) - { - for (int i = 0; i < indent; i++) - { - System.out.print(' '); - } - System.out.println(desc.getName() + '\t' + desc); - if (desc.isDirectory()) - { - indent += 2; - Map listing = fAVMRemote.getDirectoryListing(desc); - for (Map.Entry entry : listing.entrySet()) - { - recursiveList(entry.getValue(), indent); - } - } - } - - public static void main(String[] args) - { - AVMLs me = new AVMLs(); - me.exec(args, flagDefs, 1, USAGE); - } -} diff --git a/source/java/org/alfresco/repo/clt/AVMLsStores.java b/source/java/org/alfresco/repo/clt/AVMLsStores.java deleted file mode 100644 index 85b0f54be9..0000000000 --- a/source/java/org/alfresco/repo/clt/AVMLsStores.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.clt; - -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.avm.AVMStoreDescriptor; - -/** - * List all avm stores in the repository. - * @author britt - */ -public class AVMLsStores extends CltBase -{ - private static Object[] flagDefs = { }; - - private static String USAGE = "usage: AVMLsStores"; - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List) - */ - @Override - protected void run(Map> flags, List args) - { - List stores = fAVMRemote.getStores(); - for (AVMStoreDescriptor store : stores) - { - System.out.println(store); - } - } - - public static void main(String[] args) - { - AVMLsStores me = new AVMLsStores(); - me.exec(args, flagDefs, 0, USAGE); - } -} diff --git a/source/java/org/alfresco/repo/clt/AVMLsVersions.java b/source/java/org/alfresco/repo/clt/AVMLsVersions.java deleted file mode 100644 index 6fc717af88..0000000000 --- a/source/java/org/alfresco/repo/clt/AVMLsVersions.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.clt; - -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.avm.VersionDescriptor; - -/** - * List all versions of a given store. - * @author britt - */ -public class AVMLsVersions extends CltBase -{ - private static Object [] flagDefs = { }; - - private static String USAGE = "usage: AVMLsVersion storename"; - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List) - */ - @Override - protected void run(Map> flags, List args) - { - List versions = fAVMRemote.getStoreVersions(args.get(0)); - for (VersionDescriptor version : versions) - { - System.out.println(version); - } - } - - public static void main(String[] args) - { - AVMLsVersions me = new AVMLsVersions(); - me.exec(args, flagDefs, 1, USAGE); - } -} diff --git a/source/java/org/alfresco/repo/clt/AVMMkDir.java b/source/java/org/alfresco/repo/clt/AVMMkDir.java deleted file mode 100644 index a8504d5bfa..0000000000 --- a/source/java/org/alfresco/repo/clt/AVMMkDir.java +++ /dev/null @@ -1,83 +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 . - */ -package org.alfresco.repo.clt; - -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; - -/** - * Make a directory. - * @author britt - */ -public class AVMMkDir extends CltBase -{ - private static Object [] flagDefs = { "-p", 0 }; - - private static String USAGE = "usage: AVMMkDir [-p] nodepath"; - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List) - */ - @Override - protected void run(Map> flags, List args) - { - if (flags.containsKey("-p")) - { - mkdirp(args.get(0)); - return; - } - String [] parentBase = splitPath(args.get(0)); - if (parentBase.length == 1) - { - System.err.println(args.get(0) + " is a root path."); - fContext.close(); - System.exit(1); - } - fAVMRemote.createDirectory(parentBase[0], parentBase[1]); - } - - private void mkdirp(String path) - { - AVMNodeDescriptor desc = fAVMRemote.lookup(-1, path); - if (desc != null) - { - return; - } - String [] parentBase = splitPath(path); - if (parentBase.length == 1) - { - System.err.println(path + " does not exist."); - fContext.close(); - System.exit(1); - } - mkdirp(parentBase[0]); - fAVMRemote.createDirectory(parentBase[0], parentBase[1]); - } - - /** - * @param args - */ - public static void main(String[] args) - { - AVMMkDir me = new AVMMkDir(); - me.exec(args, flagDefs, 1, USAGE); - } -} diff --git a/source/java/org/alfresco/repo/clt/AVMMkLayeredDir.java b/source/java/org/alfresco/repo/clt/AVMMkLayeredDir.java deleted file mode 100644 index 476211a131..0000000000 --- a/source/java/org/alfresco/repo/clt/AVMMkLayeredDir.java +++ /dev/null @@ -1,55 +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 . - */ -package org.alfresco.repo.clt; - -import java.util.List; -import java.util.Map; - -/** - * @author britt - * - */ -public class AVMMkLayeredDir extends CltBase -{ - private static Object [] flagDefs = { }; - - private static String USAGE = "usage: AVMMkLayeredDir nodepath targetnodepath"; - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List) - */ - @Override - protected void run(Map> flags, List args) - { - String [] pathBase = splitPath(args.get(0)); - if (pathBase.length == 1) - { - System.err.println("Cannot make a layered root directory."); - fContext.close(); - System.exit(1); - } - fAVMRemote.createLayeredDirectory(args.get(1), pathBase[0], pathBase[1]); - } - - public static void main(String [] args) - { - AVMMkLayeredDir me = new AVMMkLayeredDir(); - me.exec(args, flagDefs, 2, USAGE); - } -} diff --git a/source/java/org/alfresco/repo/clt/AVMMkStore.java b/source/java/org/alfresco/repo/clt/AVMMkStore.java deleted file mode 100644 index f0dfa34865..0000000000 --- a/source/java/org/alfresco/repo/clt/AVMMkStore.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.clt; - -import java.util.List; -import java.util.Map; - -/** - * Create an AVM store. - * @author britt - */ -public class AVMMkStore extends CltBase -{ - private static Object [] flagDefs = { }; - - private static String USAGE = "usage: AVMMkStore storename"; - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List) - */ - @Override - protected void run(Map> flags, List args) - { - fAVMRemote.createStore(args.get(0)); - } - - /** - * @param args - */ - public static void main(String[] args) - { - AVMMkStore me = new AVMMkStore(); - me.exec(args, flagDefs, 1, USAGE); - } -} diff --git a/source/java/org/alfresco/repo/clt/AVMRm.java b/source/java/org/alfresco/repo/clt/AVMRm.java deleted file mode 100644 index b606fc1755..0000000000 --- a/source/java/org/alfresco/repo/clt/AVMRm.java +++ /dev/null @@ -1,55 +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 . - */ -package org.alfresco.repo.clt; - -import java.util.List; -import java.util.Map; - -/** - * Remove an AVM Node. - * @author britt - */ -public class AVMRm extends CltBase -{ - private static Object [] flagDefs = { }; - - private static String USAGE = "usage: AVMRm nodepath"; - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List) - */ - @Override - protected void run(Map> flags, List args) - { - String [] pathBase = splitPath(args.get(0)); - if (pathBase.length == 1) - { - System.err.println("One cannot remove a root node."); - fContext.close(); - System.exit(1); - } - fAVMRemote.removeNode(pathBase[0], pathBase[1]); - } - - public static void main(String[] args) - { - AVMRm me = new AVMRm(); - me.exec(args, flagDefs, 1, USAGE); - } -} diff --git a/source/java/org/alfresco/repo/clt/AVMSnapshot.java b/source/java/org/alfresco/repo/clt/AVMSnapshot.java deleted file mode 100644 index 809c6e5859..0000000000 --- a/source/java/org/alfresco/repo/clt/AVMSnapshot.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.clt; - -import java.util.List; -import java.util.Map; - -/** - * Snapshot a store. - * @author britt - */ -public class AVMSnapshot extends CltBase -{ - private static Object [] flagDefs = { }; - - private static String USAGE = "usage: AVMSnapshot storename label comment"; - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List) - */ - @Override - protected void run(Map> flags, List args) - { - fAVMRemote.createSnapshot(args.get(0), args.get(1), args.get(2)); - } - - /** - * @param args - */ - public static void main(String[] args) - { - AVMSnapshot me = new AVMSnapshot(); - me.exec(args, flagDefs, 3, USAGE); - } -} diff --git a/source/java/org/alfresco/repo/clt/CltBase.java b/source/java/org/alfresco/repo/clt/CltBase.java deleted file mode 100644 index a725b1ceb5..0000000000 --- a/source/java/org/alfresco/repo/clt/CltBase.java +++ /dev/null @@ -1,241 +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 . - */ -package org.alfresco.repo.clt; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.repo.remote.ClientTicketHolder; -import org.alfresco.service.cmr.avmsync.AVMSyncService; -import org.alfresco.service.cmr.remote.AVMRemote; -import org.alfresco.service.cmr.remote.RepoRemote; -import org.alfresco.service.cmr.security.AuthenticationService; -import org.alfresco.util.Pair; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -/** - * This is the base class for AVM clts. - * @author britt - */ -public abstract class CltBase -{ - /** - * The instance of the remote interface. - */ - protected AVMRemote fAVMRemote; - - /** - * The instance of the remote sync service interface. - */ - protected AVMSyncService fAVMSyncService; - - /** - * The instance of the remote repo interface. - */ - protected RepoRemote fRepoRemote; - - /** - * The ApplicationContext. - */ - protected ConfigurableApplicationContext fContext; - - /** - * The Authentication Service. - */ - protected AuthenticationService fAuthenticationService; - - /** - * The usage string. - */ - private String fUsage; - - /** - * Construct a new one. This takes care of instantiating - * the application context and grabs references to the - * services. - * @param args The program arguments. - */ - protected CltBase() - { - fContext = new ClassPathXmlApplicationContext("clt-context.xml"); - fAVMRemote = (AVMRemote)fContext.getBean("avmRemote"); - fAVMSyncService = (AVMSyncService)fContext.getBean("avmSyncService"); - fRepoRemote = (RepoRemote)fContext.getBean("repoRemote"); - fAuthenticationService = (AuthenticationService)fContext.getBean("authenticationService"); - fAuthenticationService.authenticate(System.getenv("ALFUSER"), System.getenv("ALFPASSWORD").toCharArray()); - String ticket = fAuthenticationService.getCurrentTicket(); - ((ClientTicketHolder)fContext.getBean("clientTicketHolder")).setTicket(ticket); - } - - /** - * All clts go through this call. This parses the arguments, exits if - * there are any errors and then passes the broken flags and arguments - * to the run method of the derived clt. - * @param args The raw command line arguments. - * @param flagDefs The definition of what flags to accept and their - * arities. - * @param minArgs The minimum number of actual arguments expected. - * @param usageMessage The message that should be printed if there is a - * syntax error. - */ - public void exec(String [] args, - Object [] flagDefs, - int minArgs, - String usageMessage) - { - fUsage = usageMessage; - Map flagArgs = new HashMap(); - Map> flagValues = new HashMap>(); - List actualArgs = new ArrayList(); - // Convert the flag definitions into a convenient form. - for (int i = 0; i < flagDefs.length / 2; i++) - { - flagArgs.put((String)flagDefs[i * 2], (Integer)flagDefs[i * 2 + 1]); - } - // Walk through the raw command line arguments. - int pos = 0; - while (pos < args.length) - { - if (args[pos].equals("-h")) - { - usage(); - } - // If the argument is one of the accepted flags then it's - // a flag. - if (flagArgs.containsKey(args[pos])) - { - String flag = args[pos]; - pos++; - int count = flagArgs.get(flag); - // Check for too few arguments - if (args.length - pos < count) - { - usage(); - } - // Stuff the parsed flag away. - List flArgs = new ArrayList(); - for (int i = 0; i < count; i++) - { - flArgs.add(args[pos + i]); - } - flagValues.put(flag, flArgs); - pos += count; - continue; - } - // Otherwise its just a plain old arg. - actualArgs.add(args[pos]); - pos++; - } - // Check for too few arguments. - if (actualArgs.size() < minArgs) - { - usage(); - } - // Do the work. - run(flagValues, actualArgs); - // Cleanup. - fContext.close(); - } - - /** - * Handle syntax error by exiting. - */ - protected void usage() - { - System.err.println(fUsage); - fContext.close(); - System.exit(1); - } - - /** - * Utility to split an AVM path into a parent path and a - * base name. - * @param path The path to split. - * @return An array of 1 or 2 Strings representing the parent path - * and the base name, or just the path if the path given is a root path. - */ - protected String[] splitPath(String path) - { - if (path.endsWith(":/")) - { - String [] ret = { path }; - return ret; - } - int lastSlash = path.lastIndexOf("/"); - if (lastSlash == -1) - { - System.err.println("Malformed path: " + path); - fContext.close(); - System.exit(1); - } - String name = path.substring(lastSlash + 1); - String parent = path.substring(0, lastSlash); - if (parent.endsWith(":")) - { - parent = parent + "/"; - } - while (parent.endsWith("/") && !parent.endsWith(":/")) - { - parent = parent.substring(0, parent.length() - 1); - } - String [] ret = { parent, name }; - return ret; - } - - protected void copyStream(InputStream in, OutputStream out) - { - try - { - byte [] buff = new byte[8192]; - int read = 0; - while ((read = in.read(buff)) != -1) - { - out.write(buff, 0, read); - } - in.close(); - out.close(); - } - catch (IOException e) - { - e.printStackTrace(); - fContext.close(); - System.exit(1); - } - } - - protected Pair splitPathVersion(String pathVersion) - { - int index = pathVersion.lastIndexOf('@'); - if (index == -1) - { - usage(); - } - String path = pathVersion.substring(0, index); - int version = Integer.parseInt(pathVersion.substring(index + 1)); - return new Pair(path, version); - } - - protected abstract void run(Map> flags, List args); -} diff --git a/source/java/org/alfresco/repo/clt/RepoCopyIn.java b/source/java/org/alfresco/repo/clt/RepoCopyIn.java deleted file mode 100644 index 0fdc6592a8..0000000000 --- a/source/java/org/alfresco/repo/clt/RepoCopyIn.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.clt; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.Pair; - -/** - * Simplified cp from a local filesystem to the repo. - * @author britt - */ -public class RepoCopyIn extends CltBase -{ - private static Object [] flagDefs = { "-r", 0, "-v", 0 }; - - private static String USAGE = "usage: RepoCopyIn fspath repopath"; - - private boolean fVerbose; - - /* (non-Javadoc) - * @see org.alfresco.repo.clt.CltBase#run(java.util.Map, java.util.List) - */ - @Override - protected void run(Map> flags, List args) - { - if (flags.containsKey("-v")) - { - fVerbose = true; - } - else - { - fVerbose = false; - } - NodeRef root = fRepoRemote.getRoot(); - String path = args.get(1); - while (path.startsWith("/")) - { - path = path.substring(1); - } - Pair dst = fRepoRemote.lookup(root, path); - if (flags.containsKey("-r")) - { - if (dst == null) - { - System.err.println(args.get(1) + " does not exist."); - fContext.close(); - System.exit(1); - } - recursiveCopy(args.get(0), dst.getFirst()); - return; - } - File file = new File(args.get(0)); - if (!file.isFile()) - { - System.err.println(args.get(0) + " not found, or not a file."); - fContext.close(); - System.exit(1); - } - if (dst == null) - { - try - { - if (fVerbose) - { - System.out.println(file.getName() + " -> " + args.get(1)); - } - InputStream in = - new FileInputStream(file); - OutputStream out = fRepoRemote.createFile(root, path); - copyStream(in, out); - } - catch (IOException e) - { - e.printStackTrace(); - fContext.close(); - System.exit(1); - } - } - else - { - if (!dst.getSecond()) - { - System.err.println("Target must be a directory."); - fContext.close(); - System.exit(1); - } - try - { - if (fVerbose) - { - System.out.println(file.getName() + " -> " + args.get(1)); - } - InputStream in = - new FileInputStream(file); - OutputStream out = - fAVMRemote.createFile(args.get(1), file.getName()); - copyStream(in, out); - } - catch (IOException e) - { - e.printStackTrace(); - fContext.close(); - System.exit(1); - } - } - } - - private void recursiveCopy(String sourcePath, NodeRef dest) - { - File file = new File(sourcePath); - if (fVerbose) - { - System.out.println(sourcePath + " -> " + dest); - } - if (file.isDirectory()) - { - NodeRef dir = fRepoRemote.createDirectory(dest, file.getName()); - String [] names = file.list(); - for (String name : names) - { - recursiveCopy(sourcePath + File.separatorChar + name, - dir); - } - } - else - { - try - { - InputStream in = - new FileInputStream(file); - OutputStream out = fRepoRemote.createFile(dest, file.getName()); - copyStream(in, out); - } - catch (IOException e) - { - e.printStackTrace(); - fContext.close(); - System.exit(1); - } - } - } - - public static void main(String[] args) - { - RepoCopyIn me = new RepoCopyIn(); - me.exec(args, flagDefs, 2, USAGE); - } -} diff --git a/source/java/org/alfresco/repo/clt/RepoCopyOut.java b/source/java/org/alfresco/repo/clt/RepoCopyOut.java deleted file mode 100644 index fb88dea078..0000000000 --- a/source/java/org/alfresco/repo/clt/RepoCopyOut.java +++ /dev/null @@ -1,165 +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 . - */ -package org.alfresco.repo.clt; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.Pair; - -/** - * Like cp from Repo to a local filesystem. - * @author britt - */ -public class RepoCopyOut extends CltBase -{ - private static Object [] flagDefs = { "-r", 0, "-v", 0 }; - - private static String USAGE = "usage: RepoCopyOut [-r] [-v] repopath fspath"; - - private boolean fVerbose; - - /* (non-Javadoc) - * @see org.alfresco.repo.clt.CltBase#run(java.util.Map, java.util.List) - */ - @Override - protected void run(Map> flags, List args) - { - if (flags.containsKey("-v")) - { - fVerbose = true; - } - else - { - fVerbose = false; - } - String [] pathBase = splitPath(args.get(0)); - if (pathBase.length != 2) - { - System.err.println("Cannot copy out root."); - fContext.close(); - System.exit(1); - } - String srcPath = args.get(0); - while (srcPath.startsWith("/")) - { - srcPath = srcPath.substring(1); - } - NodeRef root = fRepoRemote.getRoot(); - Pair src = fRepoRemote.lookup(root, srcPath); - if (src == null) - { - System.err.println(srcPath + "Not Found."); - fContext.close(); - System.exit(1); - } - if (flags.containsKey("-r")) - { - recursiveCopy(src, pathBase[1], args.get(1)); - return; - } - if (src.getSecond()) - { - System.err.println(srcPath + " is not a file."); - fContext.close(); - System.exit(1); - } - File dest = new File(args.get(1)); - if (dest.exists()) - { - if (!dest.isDirectory()) - { - System.err.println("Destination must be a directory."); - fContext.close(); - System.exit(1); - } - try - { - InputStream in = fRepoRemote.readFile(src.getFirst()); - OutputStream out = new FileOutputStream(args.get(1) + File.separator + pathBase[1]); - copyStream(in, out); - } - catch (IOException e) - { - e.printStackTrace(); - fContext.close(); - System.exit(1); - } - } - else - { - try - { - InputStream in = fRepoRemote.readFile(src.getFirst()); - OutputStream out = new FileOutputStream(args.get(1)); - copyStream(in, out); - } - catch (IOException e) - { - e.printStackTrace(); - fContext.close(); - System.exit(1); - } - } - } - - private void recursiveCopy(Pair src, String name, String dst) - { - String newDst = dst + File.separator + name; - if (fVerbose) - { - System.out.println(name + " -> " + dst); - } - if (src.getSecond()) - { - File destFile = new File(newDst); - destFile.mkdir(); - Map> listing = fRepoRemote.getListing(src.getFirst()); - for (Map.Entry> entry : listing.entrySet()) - { - recursiveCopy(entry.getValue(), entry.getKey(), newDst); - } - return; - } - try - { - InputStream in = fRepoRemote.readFile(src.getFirst()); - OutputStream out = new FileOutputStream(newDst); - copyStream(in, out); - } - catch (IOException e) - { - e.printStackTrace(); - fContext.close(); - System.exit(1); - } - } - - public static void main(String[] args) - { - RepoCopyOut me = new RepoCopyOut(); - me.exec(args, flagDefs, 2, USAGE); - } -} diff --git a/source/java/org/alfresco/repo/clt/RepoLs.java b/source/java/org/alfresco/repo/clt/RepoLs.java deleted file mode 100644 index d6a2b0da32..0000000000 --- a/source/java/org/alfresco/repo/clt/RepoLs.java +++ /dev/null @@ -1,99 +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 . - */ -package org.alfresco.repo.clt; - -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.Pair; - -/** - * List the contents of a directory in a repo. - * @author britt - */ -public class RepoLs extends CltBase -{ - private static Object [] flagDefs = { "-R", 0 }; - - private static String USAGE = "usage: RepoLs path"; - - /* (non-Javadoc) - * @see org.alfresco.repo.clt.CltBase#run(java.util.Map, java.util.List) - */ - @Override - protected void run(Map> flags, List args) - { - NodeRef root = fRepoRemote.getRoot(); - NodeRef dir = null; - String path = args.get(0); - if (path.equals("/")) - { - dir = root; - } - else - { - while (path.startsWith("/")) - { - path = path.substring(1); - } - Pair info = fRepoRemote.lookup(root, path); - if (info == null) - { - System.err.println(path + " does not exist"); - fContext.close(); - System.exit(1); - } - dir = info.getFirst(); - } - if (flags.containsKey("-R")) - { - recursiveList(dir, 0); - return; - } - Map> listing = fRepoRemote.getListing(dir); - for (String name : listing.keySet()) - { - System.out.println(name + "\t" + listing.get(name)); - } - } - - private void recursiveList(NodeRef dir, int indent) - { - Map> listing = fRepoRemote.getListing(dir); - for (Map.Entry> entry : listing.entrySet()) - { - for (int i = 0; i < indent; i++) - { - System.out.print(' '); - } - System.out.println(entry.getKey() + '\t' + entry.getValue()); - if (entry.getValue().getSecond()) - { - recursiveList(entry.getValue().getFirst(), indent + 2); - } - } - } - - public static void main(String[] args) - { - RepoLs me = new RepoLs(); - me.exec(args, flagDefs, 1, USAGE); - } -} diff --git a/source/java/org/alfresco/repo/content/ContentServiceImpl.java b/source/java/org/alfresco/repo/content/ContentServiceImpl.java index 5f5793b30f..c80ce12151 100644 --- a/source/java/org/alfresco/repo/content/ContentServiceImpl.java +++ b/source/java/org/alfresco/repo/content/ContentServiceImpl.java @@ -29,7 +29,6 @@ import java.util.Set; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; -import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.content.ContentServicePolicies.OnContentPropertyUpdatePolicy; import org.alfresco.repo.content.ContentServicePolicies.OnContentReadPolicy; import org.alfresco.repo.content.ContentServicePolicies.OnContentUpdatePolicy; @@ -47,7 +46,6 @@ import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.InvalidTypeException; @@ -93,7 +91,6 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa private DictionaryService dictionaryService; private NodeService nodeService; - private AVMService avmService; private MimetypeService mimetypeService; private RetryingTransactionHelper transactionHelper; private ApplicationContext applicationContext; @@ -165,11 +162,6 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa this.policyComponent = policyComponent; } - public void setAvmService(AVMService service) - { - this.avmService = service; - } - public void setImageMagickContentTransformer(ContentTransformer imageMagickContentTransformer) { this.imageMagickContentTransformer = imageMagickContentTransformer; @@ -533,17 +525,7 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa // Register the new URL for rollback cleanup eagerContentStoreCleaner.registerNewContentUrl(writer.getContentUrl()); - // Special case for AVM repository. - Serializable contentValue = null; - if (nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) - { - Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - contentValue = avmService.getContentDataForWrite(avmVersionPath.getSecond()); - } - else - { - contentValue = nodeService.getProperty(nodeRef, propertyQName); - } + Serializable contentValue = nodeService.getProperty(nodeRef, propertyQName); // set extra data on the reader if the property is pre-existing if (contentValue != null && contentValue instanceof ContentData) @@ -974,18 +956,7 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa { // set the full content property ContentData contentData = writer.getContentData(); - // Bypass NodeService for avm stores. - if (nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) - { - nodeService.setProperty(nodeRef, ContentModel.PROP_CONTENT, contentData); - } - else - { - nodeService.setProperty( - nodeRef, - propertyQName, - contentData); - } + nodeService.setProperty(nodeRef, propertyQName, contentData); // done if (logger.isDebugEnabled()) { diff --git a/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleaner.java b/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleaner.java index ed995395f0..de25029c7b 100644 --- a/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleaner.java +++ b/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleaner.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.TreeMap; import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.domain.avm.AVMNodeDAO; import org.alfresco.repo.domain.contentdata.ContentDataDAO; import org.alfresco.repo.domain.contentdata.ContentDataDAO.ContentUrlHandler; import org.alfresco.repo.lock.JobLockService; @@ -117,7 +116,6 @@ public class ContentStoreCleaner private ContentDataDAO contentDataDAO; private DictionaryService dictionaryService; private ContentService contentService; - private AVMNodeDAO avmNodeDAO; private TransactionService transactionService; private int protectDays; private DeleteFailureAction deletionFailureAction; @@ -168,14 +166,6 @@ public class ContentStoreCleaner this.contentService = contentService; } - /** - * @param avmNodeDAO The AVM Node DAO to get urls with. - */ - public void setAvmNodeDAO(AVMNodeDAO avmNodeDAO) - { - this.avmNodeDAO = avmNodeDAO; - } - /** * @param transactionService the component to ensure proper transactional wrapping */ @@ -223,10 +213,6 @@ public class ContentStoreCleaner PropertyCheck.mandatory(this, "contentDataDAO", contentDataDAO); PropertyCheck.mandatory(this, "dictionaryService", dictionaryService); PropertyCheck.mandatory(this, "contentService", contentService); - - // Sparta: remove WCM/AVM - //PropertyCheck.mandatory(this, "avmNodeDAO", avmNodeDAO); - PropertyCheck.mandatory(this, "transactionService", transactionService); PropertyCheck.mandatory(this, "eagerContentStoreCleaner", eagerContentStoreCleaner); diff --git a/source/java/org/alfresco/repo/content/filestore/DeletionMetricsRunner.java b/source/java/org/alfresco/repo/content/filestore/DeletionMetricsRunner.java index 248db90e24..c281230780 100644 --- a/source/java/org/alfresco/repo/content/filestore/DeletionMetricsRunner.java +++ b/source/java/org/alfresco/repo/content/filestore/DeletionMetricsRunner.java @@ -32,7 +32,6 @@ import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.cleanup.ContentStoreCleaner; import org.alfresco.repo.content.cleanup.ContentStoreCleanerListener; import org.alfresco.repo.content.cleanup.EagerContentStoreCleaner; -import org.alfresco.repo.domain.avm.AVMNodeDAO; import org.alfresco.repo.domain.contentdata.ContentDataDAO; import org.alfresco.repo.lock.JobLockService; import org.alfresco.repo.security.authentication.AuthenticationUtil; @@ -78,7 +77,6 @@ public class DeletionMetricsRunner jobLockService = serviceRegistry.getJobLockService(); TransactionService transactionService = serviceRegistry.getTransactionService(); DictionaryService dictionaryService = serviceRegistry.getDictionaryService(); - AVMNodeDAO avmNodeDAO = (AVMNodeDAO) ctx.getBean("newAvmNodeDAO"); ContentDataDAO contentDataDAO = (ContentDataDAO) ctx.getBean("contentDataDAO"); // we need a store @@ -103,7 +101,6 @@ public class DeletionMetricsRunner cleaner.setTransactionService(transactionService); cleaner.setDictionaryService(dictionaryService); cleaner.setContentService(contentService); - cleaner.setAvmNodeDAO(avmNodeDAO); } diff --git a/source/java/org/alfresco/repo/copy/CrossRepositoryCopyServiceImpl.java b/source/java/org/alfresco/repo/copy/CrossRepositoryCopyServiceImpl.java deleted file mode 100644 index e8ac05b54e..0000000000 --- a/source/java/org/alfresco/repo/copy/CrossRepositoryCopyServiceImpl.java +++ /dev/null @@ -1,409 +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 . - */ -package org.alfresco.repo.copy; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.model.FileInfo; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.CopyService; -import org.alfresco.service.cmr.repository.CrossRepositoryCopyService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; - -/** - * Cross Repository Copying. - * - * @author britt - */ -public class CrossRepositoryCopyServiceImpl implements CrossRepositoryCopyService -{ - /** - * The NodeService reference. - */ - private NodeService fNodeService; - - /** - * The FileFolderService reference. - */ - private FileFolderService fFileFolderService; - - /** - * The regular CopyService reference. - */ - private CopyService fCopyService; - - /** - * The AVMService. - */ - private AVMService fAVMService; - - /** - * The ContentService. - */ - private ContentService fContentService; - - /** - * The DictionaryService. - */ - private DictionaryService fDictionaryService; - - /** - * A default constructor. - */ - public CrossRepositoryCopyServiceImpl() - { - } - - // Setters for Spring. - - public void setAvmService(AVMService service) - { - fAVMService = service; - } - - public void setContentService(ContentService service) - { - fContentService = service; - } - - public void setCopyService(CopyService service) - { - fCopyService = service; - } - - public void setDictionaryService(DictionaryService service) - { - fDictionaryService = service; - } - - public void setFileFolderService(FileFolderService service) - { - fFileFolderService = service; - } - - public void setNodeService(NodeService service) - { - fNodeService = service; - } - - /** - * This copies recursively src, which may be a container or a content type to dst, which must be a container. Copied - * nodes will have the copied from aspect applied to them. - * - * @param src - * The node to copy. - * @param dst - * The container to copy it into. - * @param name - * The name to give the copy. - */ - public void copy(NodeRef src, NodeRef dst, String name) - { - StoreRef srcStoreRef = src.getStoreRef(); - StoreRef dstStoreRef = dst.getStoreRef(); - if (srcStoreRef.getProtocol().equals(StoreRef.PROTOCOL_AVM)) - { - if (dstStoreRef.getProtocol().equals(StoreRef.PROTOCOL_AVM)) - { - copyAVMToAVM(src, dst, name); - } - else if (dstStoreRef.getProtocol().equals(StoreRef.PROTOCOL_WORKSPACE)) - { - copyAVMToRepo(src, dst, name); - } - } - else if (srcStoreRef.getProtocol().equals(StoreRef.PROTOCOL_WORKSPACE)) - { - if (dstStoreRef.getProtocol().equals(StoreRef.PROTOCOL_AVM)) - { - copyRepoToAVM(src, dst, name); - } - else if (dstStoreRef.getProtocol().equals(StoreRef.PROTOCOL_WORKSPACE)) - { - copyRepoToRepo(src, dst, name); - } - } - } - - /** - * Handle copying from AVM to AVM - * - * @param src - * Source node. - * @param dst - * Destination directory node. - * @param name - * Name to give copy. - */ - private void copyAVMToAVM(NodeRef src, NodeRef dst, String name) - { - Pair srcStorePath = AVMNodeConverter.ToAVMVersionPath(src); - Pair dstStorePath = AVMNodeConverter.ToAVMVersionPath(dst); - fAVMService.copy(srcStorePath.getFirst(), srcStorePath.getSecond(), dstStorePath.getSecond(), name); - } - - /** - * Handle copying from AVM to Repo. - * - * @param src - * Source node. - * @param dst - * Destination Container. - * @param name - * The name to give the copy. - */ - private void copyAVMToRepo(NodeRef src, NodeRef dst, String name) - { - Pair versionPath = AVMNodeConverter.ToAVMVersionPath(src); - AVMNodeDescriptor desc = fAVMService.lookup(versionPath.getFirst(), versionPath.getSecond()); - NodeRef existing = fFileFolderService.searchSimple(dst, name); - if (desc.isFile()) - { - if (existing != null && !fNodeService.getType(existing).equals(ContentModel.TYPE_CONTENT)) - { - fFileFolderService.delete(existing); - existing = null; - } - NodeRef childRef = null; - if (existing == null) - { - childRef = fFileFolderService.create(dst, name, ContentModel.TYPE_CONTENT).getNodeRef(); - } - else - { - childRef = existing; - } - InputStream in = fAVMService.getFileInputStream(desc); - ContentData cd = fAVMService.getContentDataForRead(versionPath.getFirst(), desc.getPath()); - ContentWriter writer = fContentService.getWriter(childRef, ContentModel.PROP_CONTENT, true); - writer.setEncoding(cd.getEncoding()); - writer.setMimetype(cd.getMimetype()); - OutputStream out = writer.getContentOutputStream(); - copyData(in, out); - copyPropsAndAspectsAVMToRepo(src, childRef); - } - else - { - if (existing != null && !fNodeService.getType(existing).equals(ContentModel.TYPE_FOLDER)) - { - fFileFolderService.delete(existing); - existing = null; - } - NodeRef childRef = null; - if (existing == null) - { - childRef = fFileFolderService.create(dst, name, ContentModel.TYPE_FOLDER).getNodeRef(); - } - else - { - childRef = existing; - } - copyPropsAndAspectsAVMToRepo(src, childRef); - Map listing = fAVMService.getDirectoryListing(desc); - for (Map.Entry entry : listing.entrySet()) - { - NodeRef srcChild = AVMNodeConverter.ToNodeRef(versionPath.getFirst(), entry.getValue().getPath()); - copyAVMToRepo(srcChild, childRef, entry.getKey()); - } - } - } - - /** - * Helper that copies aspects and properties. - * - * @param src - * The source AVM node. - * @param dst - * The destination Repo node. - */ - private void copyPropsAndAspectsAVMToRepo(NodeRef src, NodeRef dst) - { - Map props = fNodeService.getProperties(src); - fNodeService.setProperties(dst, props); - Set aspects = fNodeService.getAspects(src); - Map empty = new HashMap(); - for (QName aspect : aspects) - { - fNodeService.addAspect(dst, aspect, empty); - } -// 4.0: Derek Hulley: The cm:copiedFrom aspect is not that important and -// AVM doesn't support associations -// if (!fNodeService.hasAspect(dst, ContentModel.ASPECT_COPIEDFROM)) -// { -// empty.put(ContentModel.PROP_COPY_REFERENCE, src); -// fNodeService.addAspect(dst, ContentModel.ASPECT_COPIEDFROM, empty); -// } -// else -// { -// fNodeService.setProperty(dst, ContentModel.PROP_COPY_REFERENCE, src); -// } - } - - /** - * Handle copying from Repo to AVM. - * - * @param src - * The source node. - * @param dst - * The destingation directory. - * @param name - * The name to give the copy. - */ - private void copyRepoToAVM(NodeRef src, NodeRef dst, String name) - { - QName srcType = fNodeService.getType(src); - Pair versionPath = AVMNodeConverter.ToAVMVersionPath(dst); - String childPath = AVMNodeConverter.ExtendAVMPath(versionPath.getSecond(), name); - NodeRef childNodeRef = AVMNodeConverter.ToNodeRef(-1, childPath); - if (fDictionaryService.isSubClass(srcType, ContentModel.TYPE_CONTENT)) - { - ContentReader reader = fContentService.getReader(src, ContentModel.PROP_CONTENT); - InputStream in = reader.getContentInputStream(); - AVMNodeDescriptor desc = fAVMService.lookup(-1, childPath); - if (desc != null && !desc.isFile()) - { - fAVMService.removeNode(childPath); - desc = null; - } - if (desc == null) - { - try - { - fAVMService.createFile(versionPath.getSecond(), name).close(); - } - catch (IOException e) - { - throw new AlfrescoRuntimeException("I/O Error.", e); - } - } - ContentWriter writer = fAVMService.getContentWriter(childPath, true); - writer.setEncoding(reader.getEncoding()); - writer.setMimetype(reader.getMimetype()); - OutputStream out = writer.getContentOutputStream(); - copyData(in, out); - copyPropsAndAspectsRepoToAVM(src, childNodeRef, childPath); - return; - } - if (fDictionaryService.isSubClass(srcType, ContentModel.TYPE_FOLDER)) - { - AVMNodeDescriptor desc = fAVMService.lookup(-1, childPath); - if (desc != null && !desc.isDirectory()) - { - fAVMService.removeNode(childPath); - desc = null; - } - if (desc == null) - { - fAVMService.createDirectory(versionPath.getSecond(), name); - } - copyPropsAndAspectsRepoToAVM(src, childNodeRef, childPath); - List listing = fFileFolderService.list(src); - for (FileInfo info : listing) - { - copyRepoToAVM(info.getNodeRef(), childNodeRef, info.getName()); - } - return; - } - } - - /** - * Helper to copy properties and aspects. - * - * @param src - * The source node. - * @param dst - * The destination node. - * @param dstPath - * The destination AVM path. - */ - private void copyPropsAndAspectsRepoToAVM(NodeRef src, NodeRef dst, String dstPath) - { - Map props = fNodeService.getProperties(src); - fNodeService.setProperties(dst, props); - Set aspects = fNodeService.getAspects(src); - for (QName aspect : aspects) - { - fAVMService.addAspect(dstPath, aspect); - } -// 4.0: Derek Hulley: The cm:copiedFrom aspect is not that important and -// AVM doesn't support associations -// if (!fAVMService.hasAspect(-1, dstPath, ContentModel.ASPECT_COPIEDFROM)) -// { -// fAVMService.addAspect(dstPath, ContentModel.ASPECT_COPIEDFROM); -// } -// fNodeService.setProperty(dst, ContentModel.PROP_COPY_REFERENCE, src); - } - - /** - * Handle copying from Repo to Repo. - * - * @param src - * The source node. - * @param dst - * The destination container. - * @param name - * The name to give the copy. - */ - private void copyRepoToRepo(NodeRef src, NodeRef dst, String name) - { - ChildAssociationRef assocRef = fNodeService.getPrimaryParent(src); - fCopyService.copyAndRename(src, dst, ContentModel.ASSOC_CONTAINS, assocRef.getQName(), true); - } - - private void copyData(InputStream in, OutputStream out) - { - try - { - byte[] buff = new byte[8192]; - int read = 0; - while ((read = in.read(buff)) != -1) - { - out.write(buff, 0, read); - } - in.close(); - out.close(); - } - catch (IOException e) - { - throw new AlfrescoRuntimeException("I/O Error.", e); - } - } -} diff --git a/source/java/org/alfresco/repo/deploy/AbstractDeploymentReceiverTransportAdapter.java b/source/java/org/alfresco/repo/deploy/AbstractDeploymentReceiverTransportAdapter.java deleted file mode 100644 index a50de6042f..0000000000 --- a/source/java/org/alfresco/repo/deploy/AbstractDeploymentReceiverTransportAdapter.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.deploy; - -import java.util.List; - -import org.alfresco.deployment.DeploymentTransportOutputFilter; - -/** - * Abstract Transport Adapter. - * - */ -public abstract class AbstractDeploymentReceiverTransportAdapter { - - List transformers; - - /** - * Get the content transformers for this transport - if the transport does not support - * content transformation then simply return null; - * @return the content transformers or null if there are no transformers. - */ - public ListgetTransformers() { - return transformers; - } - /** - * Set the content transformers for this transport - if the transport does not support - * content transformation then simply set null or do not call this method. - */ - public void setTransformers( List transformers) { - this.transformers = transformers; - } - -} diff --git a/source/java/org/alfresco/repo/deploy/DeploymentClientOutputStream.java b/source/java/org/alfresco/repo/deploy/DeploymentClientOutputStream.java deleted file mode 100644 index e95335d87e..0000000000 --- a/source/java/org/alfresco/repo/deploy/DeploymentClientOutputStream.java +++ /dev/null @@ -1,125 +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 . - */ - -package org.alfresco.repo.deploy; - -import java.io.IOException; -import java.io.OutputStream; - -import org.alfresco.deployment.DeploymentReceiverTransport; - -/** - * OutputStream used by client side to talk to - * the deployment receiver. - * @author britt - */ -public class DeploymentClientOutputStream extends OutputStream -{ - private DeploymentReceiverTransport fTransport; - - private String fTicket; - - private String fOutputToken; - - private boolean open = true; - - /** - * Make one up. - * @param transport - * @param ticket - * @param outputToken - */ - public DeploymentClientOutputStream(DeploymentReceiverTransport transport, - String ticket, - String outputToken) - { - fTransport = transport; - fTicket = ticket; - fOutputToken = outputToken; - } - - /* (non-Javadoc) - * @see java.io.OutputStream#write(int) - */ - @Override - public void write(int b) throws IOException - { - byte[] buff = new byte[1]; - buff[0] = (byte)b; - write(buff); - } - - /* (non-Javadoc) - * @see java.io.OutputStream#close() - */ - @Override - public void close() throws IOException - { - if(open) - { - fTransport.finishSend(fTicket, fOutputToken); - } - open = false; - } - - /* (non-Javadoc) - * @see java.io.OutputStream#flush() - */ - @Override - public void flush() throws IOException - { - // NO OP - } - - /* (non-Javadoc) - * @see java.io.OutputStream#write(byte[], int, int) - */ - @Override - public void write(byte[] b, int off, int len) throws IOException - { - fTransport.write(fTicket, fOutputToken, b, off, len); - } - - /* (non-Javadoc) - * @see java.io.OutputStream#write(byte[]) - */ - @Override - public void write(byte[] b) throws IOException - { - write(b, 0, b.length); - } - - /** - * Get the deployment ticket. - * @return - */ - public String getTicket() - { - return fTicket; - } - - /** - * Get the output token. - * @return - */ - public String getOutputToken() - { - return fOutputToken; - } -} diff --git a/source/java/org/alfresco/repo/deploy/DeploymentDestination.java b/source/java/org/alfresco/repo/deploy/DeploymentDestination.java deleted file mode 100644 index 4b5ae81991..0000000000 --- a/source/java/org/alfresco/repo/deploy/DeploymentDestination.java +++ /dev/null @@ -1,71 +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 . - */ -package org.alfresco.repo.deploy; - -/** - * Class to hold Deployment destination information. - * Used as a lock to serialize deployments to the same - * destination. - * @author britt - */ -public class DeploymentDestination -{ - private String fHost; - - private int fPort; - - DeploymentDestination(String host, int port) - { - fHost = host; - fPort = port; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (!(obj instanceof DeploymentDestination)) - { - return false; - } - DeploymentDestination other = (DeploymentDestination)obj; - return fHost.equals(other.fHost) && fPort == other.fPort; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() - { - return fHost.hashCode() + fPort; - } - - public String toString() - { - return fHost; - } -} - diff --git a/source/java/org/alfresco/repo/deploy/DeploymentReceiverAuthenticatorAuthenticationService.java b/source/java/org/alfresco/repo/deploy/DeploymentReceiverAuthenticatorAuthenticationService.java deleted file mode 100644 index dd65191636..0000000000 --- a/source/java/org/alfresco/repo/deploy/DeploymentReceiverAuthenticatorAuthenticationService.java +++ /dev/null @@ -1,66 +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 . - */ -package org.alfresco.repo.deploy; - -import org.alfresco.deployment.impl.server.DeploymentReceiverAuthenticator; -import org.alfresco.repo.security.authentication.AuthenticationException; -import org.alfresco.service.cmr.security.AuthenticationService; - - -/** - * This authenticator uses the Authentication Service to authenticate against the repository. - * - */ -public class DeploymentReceiverAuthenticatorAuthenticationService implements DeploymentReceiverAuthenticator -{ - private AuthenticationService authenticationService; - - public void init() - { - - } - - /** - * Are the user and password valid for this deployment receiver? - * @param user - * @param password - * @return true, yes - go ahead. - */ - public boolean logon(String user, char[] password) - { - try - { - authenticationService.authenticate(user, password); - return true; - } - catch (AuthenticationException e) - { - return false; - } - } - - public void setAuthenticationService(AuthenticationService authenticationService) { - this.authenticationService = authenticationService; - } - - public AuthenticationService getAuthenticationService() { - return authenticationService; - } - -} diff --git a/source/java/org/alfresco/repo/deploy/DeploymentReceiverServiceClient.java b/source/java/org/alfresco/repo/deploy/DeploymentReceiverServiceClient.java deleted file mode 100644 index 43088e9d41..0000000000 --- a/source/java/org/alfresco/repo/deploy/DeploymentReceiverServiceClient.java +++ /dev/null @@ -1,144 +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 . - */ - -package org.alfresco.repo.deploy; - -import java.io.OutputStream; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.io.Serializable; - -import org.alfresco.deployment.DeploymentReceiverService; -import org.alfresco.deployment.DeploymentReceiverTransport; -import org.alfresco.deployment.DeploymentToken; -import org.alfresco.deployment.FileDescriptor; - -/** - * Client side implementation of DeploymentReceiverService which decorates a - * DeploymentReceiverTransport instance. - * - * This class adds code to the send and finishSend methods. - * - * @author britt - */ -public class DeploymentReceiverServiceClient implements - DeploymentReceiverService -{ - /** - * The underlying transport. - */ - private DeploymentReceiverTransport fTransport; - - public DeploymentReceiverServiceClient() - { - } - - public void setDeploymentReceiverTransport(DeploymentReceiverTransport transport) - { - fTransport = transport; - } - - /* (non-Javadoc) - * @see org.alfresco.deployment.DeploymentReceiverService#abort(java.lang.String) - */ - public void abort(String ticket) - { - fTransport.abort(ticket); - } - - /* (non-Javadoc) - * @see org.alfresco.deployment.DeploymentReceiverService#begin(java.lang.String, java.lang.String, java.lang.String) - */ - public DeploymentToken begin(String target, String storeName, int version, String user, char[] password) - { - return fTransport.begin(target, storeName, version, user, password); - } - - /* (non-Javadoc) - * @see org.alfresco.deployment.DeploymentReceiverService#commit(java.lang.String) - */ - public void prepare(String ticket) - { - fTransport.prepare(ticket); - } - - /* (non-Javadoc) - * @see org.alfresco.deployment.DeploymentReceiverService#commit(java.lang.String) - */ - public void commit(String ticket) - { - fTransport.commit(ticket); - } - - /* (non-Javadoc) - * @see org.alfresco.deployment.DeploymentReceiverService#delete(java.lang.String, java.lang.String) - */ - public void delete(String ticket, String path) - { - fTransport.delete(ticket, path); - } - - /* (non-Javadoc) - * @see org.alfresco.deployment.DeploymentReceiverService#finishSend(java.lang.String, java.io.OutputStream) - */ - public void finishSend(String ticket, OutputStream out) - { - DeploymentClientOutputStream dcOut = (DeploymentClientOutputStream)out; - fTransport.finishSend(dcOut.getTicket(), dcOut.getOutputToken()); - } - - /* (non-Javadoc) - * @see org.alfresco.deployment.DeploymentReceiverService#getListing(java.lang.String, java.lang.String) - */ - public List getListing(String ticket, String path) - { - return fTransport.getListing(ticket, path); - } - - /* (non-Javadoc) - * @see org.alfresco.deployment.DeploymentReceiverService#mkdir(java.lang.String, java.lang.String, java.lang.String) - */ - public void createDirectory(String ticket, String path, String guid, Setaspects, Map properties) - { - fTransport.createDirectory(ticket, path, guid, aspects, properties); - } - - /* (non-Javadoc) - * @see org.alfresco.deployment.DeploymentReceiverService#send(java.lang.String, java.lang.String, java.lang.String) - */ - public OutputStream send(String ticket, boolean create, String path, String guid, String encoding, String mimeType, Setaspects, Map props) - { - String outputToken = fTransport.getSendToken(ticket, create, path, guid, encoding, mimeType, aspects, props); - return new DeploymentClientOutputStream(fTransport, ticket, outputToken); - } - - /* (non-Javadoc) - * @see org.alfresco.deployment.DeploymentReceiverService#shutDown(java.lang.String, java.lang.String) - */ - public void shutDown(String user, char[] password) - { - fTransport.shutDown(user, password); - } - - public void updateDirectory(String ticket, String path, String guid, Setaspects, Map props) - { - fTransport.updateDirectory(ticket, path, guid, aspects, props); - } -} diff --git a/source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapter.java b/source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapter.java deleted file mode 100644 index 17cff7431f..0000000000 --- a/source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapter.java +++ /dev/null @@ -1,63 +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 . - */ -package org.alfresco.repo.deploy; - -import java.util.List; - -import org.alfresco.deployment.DeploymentReceiverTransport; -import org.alfresco.deployment.DeploymentTransportOutputFilter; -/** - * - * DeploymentReceiverTransportAdapter are used to adapt the interface used by the FSR Client to the - * interface used by the underlying transport implementation. - * - * The DeploymentReceiverTransport objects returned will typically be proxy classes to a remote service. - * - * @see org.alfresco.deployment.impl.client.DeploymentReceiverTransportAdapterRMI - * @see org.alfresco.deployment.impl.client.DeploymentReceiverTransportAdapterSpringHTTP - * @see org.alfresco.deployment.impl.client.DeploymentReceiverTransportAdapterHessian - * - * @author mrogers - * - */ -public interface DeploymentReceiverTransportAdapter -{ - - /** - * getObject is a factory method to get a DeploymentReceiverTransport object, which will typically - * be a proxy to a remote service. - * - * It is up to the adapters themselves to decide whether hostName, port or URL takes precedence. - * - * @param adapterName the name of this adapter - * @param hostName the name of the host to connect to - * @param port the port to connect to - * @param version the version of the website - * @param the path of the website to be deployed - * @return a DeploymentRecieverTransport - */ - public DeploymentReceiverTransport getTransport(String hostName, int port, int version, String srcPath); - - /** - * Get the content transformers for this transport - if the transport does not support - * content transformation then simply return null; - * @return the content transformers or null if there are no transformers. - */ - public ListgetTransformers(); -} diff --git a/source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapterHessian.java b/source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapterHessian.java deleted file mode 100644 index 756dd0e046..0000000000 --- a/source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapterHessian.java +++ /dev/null @@ -1,65 +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 . - */ -package org.alfresco.repo.deploy; - -import java.text.MessageFormat; - -import org.alfresco.deployment.DeploymentReceiverTransport; -import org.springframework.remoting.caucho.HessianProxyFactoryBean; - -/** - * This class adapts the Hessian protocol to DeploymentReceiverTransport - * - * @author mrogers - */ -public class DeploymentReceiverTransportAdapterHessian extends AbstractDeploymentReceiverTransportAdapter implements DeploymentReceiverTransportAdapter -{ - /** - * The pattern to use when constructing the URL from hostname and port - * - * eg http://localhost:8080/ADSR/deployment - */ - private String urlPattern = "http://{0}:{1}/ADSR/deployment"; - - public DeploymentReceiverTransport getTransport(String host, - int port, int version, String srcPath) - { - MessageFormat f = new MessageFormat(getUrlPattern()); - Object[] objs = { host, Integer.toString(port) }; - String URL = f.format(objs); - - // Code to use Hessian transport provided via Spring - HessianProxyFactoryBean factory = new HessianProxyFactoryBean(); - factory.setServiceInterface(DeploymentReceiverTransport.class); - factory.setServiceUrl(URL); - factory.afterPropertiesSet(); - DeploymentReceiverTransport transport = (DeploymentReceiverTransport) factory.getObject(); - - return transport; - - } - - public void setUrlPattern(String urlPattern) { - this.urlPattern = urlPattern; - } - - public String getUrlPattern() { - return urlPattern; - } -} diff --git a/source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapterRMI.java b/source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapterRMI.java deleted file mode 100644 index ac5ff9e991..0000000000 --- a/source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapterRMI.java +++ /dev/null @@ -1,47 +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 . - */ -package org.alfresco.repo.deploy; - -import org.alfresco.deployment.DeploymentReceiverTransport; -import org.springframework.remoting.rmi.RmiProxyFactoryBean; - -/** - * Transport adapter to connect to the FSR using RMI protocol. - * - * @author mrogers - * - */ -public class DeploymentReceiverTransportAdapterRMI extends AbstractDeploymentReceiverTransportAdapter implements DeploymentReceiverTransportAdapter { - - public DeploymentReceiverTransport getTransport(String hostName, - int port, int version, String srcPath) - { - - // Code to use RMI transport - RmiProxyFactoryBean factory = new RmiProxyFactoryBean(); - factory.setRefreshStubOnConnectFailure(true); - factory.setServiceInterface(DeploymentReceiverTransport.class); - factory.setServiceUrl("rmi://" + hostName + ":" + port + "/deployment"); - factory.afterPropertiesSet(); - DeploymentReceiverTransport transport = (DeploymentReceiverTransport)factory.getObject(); - - return transport; - } - -} diff --git a/source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapterSpringHTTP.java b/source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapterSpringHTTP.java deleted file mode 100644 index 544203cce1..0000000000 --- a/source/java/org/alfresco/repo/deploy/DeploymentReceiverTransportAdapterSpringHTTP.java +++ /dev/null @@ -1,66 +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 . - */ -package org.alfresco.repo.deploy; - -import java.text.MessageFormat; - -import org.alfresco.deployment.DeploymentReceiverTransport; -import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean; - -/** - * Transport adapter to connect to the FSR using Spring over HTTP protocol. - * - * @author mrogers - * - */ -public class DeploymentReceiverTransportAdapterSpringHTTP extends AbstractDeploymentReceiverTransportAdapter implements DeploymentReceiverTransportAdapter { - /** - * The pattern to use when constructing the URL from hostname and port - * {0} substitues for hostname {1} substitues for port - * Default format results in the following URL http://localhost:8080/ADSR/deployment - */ - private String urlPattern = "http://{0}:{1}/ADSR/deployment"; - - public DeploymentReceiverTransport getTransport(String host, - int port, int version, String srcPath) - { - - MessageFormat f = new MessageFormat(getUrlPattern()); - Object[] objs = { host, Integer.toString(port) }; - String URL = f.format(objs); - - // Code to use HTTP spring transport - HttpInvokerProxyFactoryBean factory = new HttpInvokerProxyFactoryBean(); - factory.setServiceInterface(DeploymentReceiverTransport.class); - factory.setServiceUrl(URL); - factory.afterPropertiesSet(); - DeploymentReceiverTransport transport = (DeploymentReceiverTransport) factory.getObject(); - - return transport; - } - - public void setUrlPattern(String urlPattern) { - this.urlPattern = urlPattern; - } - - public String getUrlPattern() { - return urlPattern; - } - -} diff --git a/source/java/org/alfresco/repo/deploy/DeploymentServiceImpl.java b/source/java/org/alfresco/repo/deploy/DeploymentServiceImpl.java deleted file mode 100644 index 7c5daf15a0..0000000000 --- a/source/java/org/alfresco/repo/deploy/DeploymentServiceImpl.java +++ /dev/null @@ -1,2276 +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 . - */ - -package org.alfresco.repo.deploy; - -import java.io.BufferedOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Serializable; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedMap; -import java.util.TreeSet; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; - -import org.alfresco.deployment.DeploymentReceiverService; -import org.alfresco.deployment.DeploymentReceiverTransport; -import org.alfresco.deployment.DeploymentToken; -import org.alfresco.deployment.DeploymentTransportOutputFilter; -import org.alfresco.deployment.FileDescriptor; -import org.alfresco.deployment.FileType; -import org.alfresco.model.WCMAppModel; -import org.alfresco.repo.action.ActionServiceRemote; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.repo.avm.AVMNodeService; -import org.alfresco.repo.avm.util.SimplePath; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.lock.JobLockService; -import org.alfresco.repo.lock.JobLockService.JobLockRefreshCallback; -import org.alfresco.repo.remote.AVMRemoteImpl; -import org.alfresco.repo.remote.AVMSyncServiceRemote; -import org.alfresco.repo.remote.ClientTicketHolder; -import org.alfresco.repo.remote.ClientTicketHolderThread; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.action.ActionService; -import org.alfresco.service.cmr.action.ActionServiceTransport; -import org.alfresco.service.cmr.avm.AVMException; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMNotFoundException; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.avm.AVMStoreDescriptor; -import org.alfresco.service.cmr.avm.AVMWrongTypeException; -import org.alfresco.service.cmr.avm.deploy.DeploymentCallback; -import org.alfresco.service.cmr.avm.deploy.DeploymentEvent; -import org.alfresco.service.cmr.avm.deploy.DeploymentService; -import org.alfresco.service.cmr.avmsync.AVMDifference; -import org.alfresco.service.cmr.avmsync.AVMSyncService; -import org.alfresco.service.cmr.remote.AVMRemote; -import org.alfresco.service.cmr.remote.AVMRemoteTransport; -import org.alfresco.service.cmr.remote.AVMSyncServiceTransport; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.Path; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.security.AuthenticationService; -import org.alfresco.service.namespace.NamespacePrefixResolver; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.NameMatcher; -import org.alfresco.util.Pair; -import org.alfresco.util.PropertyCheck; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.remoting.rmi.RmiProxyFactoryBean; - -/** - * Implementation of DeploymentService. - * @author britt - */ -public class DeploymentServiceImpl implements DeploymentService -{ - private static Log fgLogger = LogFactory.getLog(DeploymentServiceImpl.class); - - private NodeService nodeService; - private NamespacePrefixResolver namespacePrefixResolver; - private SearchService searchService; - - /** - * The local AVMService Instance. - */ - private AVMService fAVMService; - - private AVMNodeService fAVMNodeService; - - /** - * The local Transaction Service Instance - */ - TransactionService trxService; - - /** - * The jobLockService - */ - private JobLockService jobLockService; - - /** - * The Ticket holder. - */ - private ClientTicketHolder fTicketHolder; - - /** - * number of concurrent sending threads - */ - private int numberOfSendingThreads = 4; - - /** - * Hold the deployment lock for 3600 seconds (1 hour) - *

- * This is how long we will wait for a business process to complete. - * And needs to be fairly long to allow transmission of of big files - * over high latency networks. - */ - private long targetLockTimeToLive = 3600000; - - /** - * Refresh the lock every minute or so - *

- * This is how long we keep the lock for before nudging it. So if - * this node in the cluster is shut down during deployment then - * another node can take over. - */ - private long targetLockRefreshTime = 10000; - - /** - * Retry for target lock every 1 second - */ - private long targetLockRetryWait = 1000; - - /** - * Retry 10000 times before giving up, basically we - * never want to give up. - */ - private int targetLockRetryCount = 10001; - - /** - * The size of the output buffers - */ - private int OUTPUT_BUFFER_SIZE = 20000; - - private int outputBufferSize = OUTPUT_BUFFER_SIZE; - - public void init() - { - PropertyCheck.mandatory(this, "jobLockService", jobLockService); - PropertyCheck.mandatory(this, "transactionService", trxService); - PropertyCheck.mandatory(this, "avmService", fAVMService); - PropertyCheck.mandatory(this, "avmNodeService", fAVMNodeService); - } - - /** - * Default constructor. - */ - public DeploymentServiceImpl() - { - fTicketHolder = new ClientTicketHolderThread(); - } - - /** - * Setter. - * @param service The instance to set. - */ - public void setAvmService(AVMService service) - { - fAVMService = service; - } - - /** - * Setter. - * @param trxService The instance to set. - */ - public void setTransactionService(TransactionService trxService) - { - this.trxService = trxService; - } - - /** - * Setter. - * @param nodeService The instance to set. - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Setter. - * @param namespacePrefixResolver The instance to set. - */ - public void setNamespacePrefixResolver(NamespacePrefixResolver namespacePrefixResolver) - { - this.namespacePrefixResolver = namespacePrefixResolver; - } - - /** - * Setter. - * @param searchService The instance to set. - */ - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - /* - * Deploy differences to an ASR - * (non-Javadoc) - * @see org.alfresco.service.cmr.avm.deploy.DeploymentService#deployDifference(int, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, boolean, boolean) - */ - public void deployDifference(int version, - String srcPath, - String hostName, - int port, - String userName, - String password, - String dstPath, - final NameMatcher matcher, - boolean createDst, - final boolean dontDelete, - final boolean dontDo, - final List callbacks) - { - final String storeName = srcPath.substring(0, srcPath.indexOf(":")); - - /** - * Lock the cluster for the remote target - */ - String lockStr = hostName + "." + "asr." + storeName; - QName lockQName = QName.createQName("{http://www.alfresco.org/deploymentService/1.0}" + lockStr); - - Lock lock = new Lock(lockQName); - lock.makeLock(); - try - { - /** - * Got the lock - now do a deployment - */ - if (fgLogger.isDebugEnabled()) - { - fgLogger.debug("Deploying to Remote Alfresco at " + hostName); - } - - - try - { - RetryingTransactionHelper trn = trxService.getRetryingTransactionHelper(); - - fgLogger.debug("Connecting to remote AVM at " + hostName + ":" +port); - final AVMRemote remote = getRemote(hostName, port, userName, password); - if (version < 0) - { - /** - * If version is -1, Create a local snapshot to deploy - */ - fgLogger.debug("creating snapshot of local version"); - - - RetryingTransactionCallback localSnapshot = new RetryingTransactionCallback() - { - public Integer execute() throws Throwable - { - int newVersion = fAVMService.createSnapshot(storeName, null, null).get(storeName); - return new Integer(newVersion); - } - }; - version = trn.doInTransaction(localSnapshot, false, true).intValue(); - fgLogger.debug("snapshot local created " + storeName + ", " + version); - } - - { - DeploymentEvent event = new DeploymentEvent(DeploymentEvent.Type.START, - new Pair(version, srcPath), - dstPath); - processEvent(event, callbacks); - } - - /* - * Create a snapshot on the destination server. - */ - boolean createdRoot = false; - String [] storePath = dstPath.split(":"); - int snapshot = -1; - - // Get the root of the deployment on the destination server. - AVMNodeDescriptor dstRoot = remote.lookup(-1, dstPath); - - if (!dontDo) - { - // Get the root of the deployment on the destination server. - - if (dstRoot == null) - { - if (createDst) - { - fgLogger.debug("Create destination parent folder:" + dstPath); - createDestination(remote, dstPath); - dstRoot = remote.lookup(-1, dstPath); - createdRoot = true; - } - else - { - throw new AVMNotFoundException("Node Not Found: " + dstRoot); - } - } - fgLogger.debug("create snapshot on remote"); - snapshot = remote.createSnapshot(storePath[0], "PreDeploy", "Pre Deployment Snapshot").get(storePath[0]); - fgLogger.debug("snapshot created on remote"); - } - - final int srcVersion = version; - final String srcFinalPath = srcPath; - RetryingTransactionCallback readRoot = new RetryingTransactionCallback() - { - public AVMNodeDescriptor execute() throws Throwable - { - return fAVMService.lookup(srcVersion, srcFinalPath); - } - }; - - final AVMNodeDescriptor srcRoot = trn.doInTransaction(readRoot, true, true); - - // Get the root of the deployment from this server. - // AVMNodeDescriptor srcRoot = fAVMService.lookup(version, srcPath); - - if (srcRoot == null) - { - throw new AVMNotFoundException("Directory Not Found: " + srcPath); - } - if (!srcRoot.isDirectory()) - { - throw new AVMWrongTypeException("Not a directory: " + srcPath); - } - - /** - * The destination directory exists - check is actually a directory - */ - if (!dstRoot.isDirectory()) - { - throw new AVMWrongTypeException("Not a Directory: " + dstPath); - } - - try - { - /** - * Recursivly copy - */ - fgLogger.debug("both src and dest exist, recursivly deploy"); - final AVMNodeDescriptor dstParentNode = dstRoot; - RetryingTransactionCallback copyContentsRecursivly = new RetryingTransactionCallback() - { - public Integer execute() throws Throwable - { - deployDirectoryPush(srcVersion, srcRoot, dstParentNode, remote, matcher, dontDelete, dontDo, callbacks); - return new Integer(0); - } - }; - - trn.setMaxRetries(1); - trn.doInTransaction(copyContentsRecursivly, false, true); - - fgLogger.debug("finished copying, snapshot remote"); - remote.createSnapshot(storePath[0], "Deployment", "Post Deployment Snapshot."); - - DeploymentEvent event = new DeploymentEvent(DeploymentEvent.Type.END, - new Pair(version, srcPath), - dstPath); - processEvent(event, callbacks); - return; - } - catch (AVMException e) - { - fgLogger.debug("error during remote copy and snapshot"); - try - { - if (snapshot != -1) - { - fgLogger.debug("Attempting to roll back "); - AVMSyncService syncService = getSyncService(hostName, port); - List diffs = syncService.compare(snapshot, dstPath, -1, dstPath, null); - syncService.update(diffs, null, false, false, true, true, "Aborted Deployment", "Aborted Deployment"); - } - } - catch (Exception ee) - { - throw new AVMException("Failed to rollback to version " + snapshot + " on " + hostName, ee); - } - throw new AVMException("Deployment to " + hostName + " failed.", e); - } - } - catch (Exception e) - { - DeploymentEvent event = new DeploymentEvent(DeploymentEvent.Type.FAILED, - new Pair(version, srcPath), - dstPath, e.getMessage()); - processEvent(event, callbacks); - - throw new AVMException("Deployment to " + hostName + " failed." + e.toString(), e); - } - finally - { - fgLogger.debug("ASR Finally block, Releasing ASR deployment ticket"); - fTicketHolder.setTicket(null); - } - } - finally - { - fgLogger.debug("about to release lock"); - lock.releaseLock(); - } - - } - - /** - * Deploy all the children of corresponding directories. (ASR version) - * @param src The source directory. - * @param dst The destination directory. - * @param remote The AVMRemote instance. - * @param dontDelete Flag for not deleting. - * @param dontDo Flag for dry run. - */ - private void deployDirectoryPush(int version, - AVMNodeDescriptor src, - AVMNodeDescriptor dst, - AVMRemote remote, - NameMatcher matcher, - boolean dontDelete, boolean dontDo, - List callbacks) - { - if (src.getGuid().equals(dst.getGuid())) - { - return; - } - if (!dontDo && !dontDelete) - { - copyMetadata(version, src, dst, remote); - } - // Get the listing for the source. - SortedMap srcList = fAVMService.getDirectoryListing(src); - // Get the listing for the destination. - SortedMap dstList = remote.getDirectoryListing(dst); - - // Strip out stale nodes. - for (Map.Entry entry : srcList.entrySet()) - { - String name = entry.getKey(); - AVMNodeDescriptor srcNode = entry.getValue(); - - if (isStale(srcNode)) - { - if (fgLogger.isDebugEnabled()) - { - fgLogger.debug("Stale child found: " + srcNode); - } - srcList.remove(name); - } - } - - for (Map.Entry entry : srcList.entrySet()) - { - String name = entry.getKey(); - AVMNodeDescriptor srcNode = entry.getValue(); - AVMNodeDescriptor dstNode = dstList.get(name); - if (!excluded(matcher, srcNode.getPath(), dstNode != null ? dstNode.getPath() : null)) - { - if(isStale(srcNode)) - { - fgLogger.debug("stale file not added" + srcNode); - continue; - } - - deploySinglePush(version, srcNode, dst, dstNode, remote, matcher, dontDelete, dontDo, callbacks); - } - } - // Delete nodes that are missing in the source. - if (dontDelete) - { - return; - } - for (String name : dstList.keySet()) - { - if (!srcList.containsKey(name)) - { - Pair source = - new Pair(version, AVMNodeConverter.ExtendAVMPath(src.getPath(), name)); - String destination = AVMNodeConverter.ExtendAVMPath(dst.getPath(), name); - if (!excluded(matcher, null, destination)) - { - DeploymentEvent event = - new DeploymentEvent(DeploymentEvent.Type.DELETED, - source, - destination); - processEvent(event, callbacks); - if (dontDo) - { - continue; - } - remote.removeNode(dst.getPath(), name); - } - } - } - } - - /** - * Push out a single node. - * @param src The source node. - * @param dstParent The destination parent. - * @param dst The destination node. May be null. - * @param remote The AVMRemote instance. - * @param dontDelete Flag for whether deletions should happen. - * @param dontDo Dry run flag. - */ - private void deploySinglePush(int version, - AVMNodeDescriptor src, AVMNodeDescriptor dstParent, - AVMNodeDescriptor dst, AVMRemote remote, - NameMatcher matcher, - boolean dontDelete, boolean dontDo, - List callbacks) - { - // Destination does not exist. - if (dst == null) - { - if (src.isDirectory()) - { - // Recursively copy a source directory. - Pair source = - new Pair(version, src.getPath()); - String destination = AVMNodeConverter.ExtendAVMPath(dstParent.getPath(), src.getName()); - DeploymentEvent event = new DeploymentEvent(DeploymentEvent.Type.CREATED, - source, - destination); - processEvent(event, callbacks); - if (dontDo) - { - return; - } - copyDirectory(version, src, dstParent, remote, matcher, callbacks); - return; - } - - // here when src is a file - Pair source = - new Pair(version, src.getPath()); - String destination = AVMNodeConverter.ExtendAVMPath(dstParent.getPath(), src.getName()); - DeploymentEvent event = new DeploymentEvent(DeploymentEvent.Type.CREATED, - source, - destination); - processEvent(event, callbacks); - if (dontDo) - { - return; - } - // Copy a source file. - OutputStream out = remote.createFile(dstParent.getPath(), src.getName()); - try - { - InputStream in = fAVMService.getFileInputStream(src); - copyStream(in, out); - } - finally - { - if(out != null) - { - // whatever happens close stream - try - { - out.close(); - } - catch (IOException e) - { - throw new AVMException("I/O Exception", e); - } - } - } - - copyMetadata(version, src, remote.lookup(-1, dstParent.getPath() + '/' + src.getName()), remote); - return; - } - - // Destination exists and is a directory. - if (src.isDirectory()) - { - // If the destination is also a directory, recursively deploy. - if (dst.isDirectory()) - { - deployDirectoryPush(version, src, dst, remote, matcher, dontDelete, dontDo, callbacks); - return; - } - Pair source = - new Pair(version, src.getPath()); - String destination = dst.getPath(); - DeploymentEvent event = new DeploymentEvent(DeploymentEvent.Type.CREATED, - source, destination); - processEvent(event, callbacks); - - if (dontDo) - { - return; - } - // MER WHY IS THIS HERE ? - fgLogger.debug("Remove and recopy node :" + dstParent.getPath() + '/' + src.getName()); - remote.removeNode(dstParent.getPath(), src.getName()); - copyDirectory(version, src, dstParent, remote, matcher, callbacks); - return; - } - // Source exists and is a file. - if (dst.isFile()) - { - // Destination is also a file. Overwrite if the GUIDS are different. - if (src.getGuid().equals(dst.getGuid())) - { - return; - } - Pair source = - new Pair(version, src.getPath()); - String destination = dst.getPath(); - DeploymentEvent event = new DeploymentEvent(DeploymentEvent.Type.UPDATED, - source, - destination); - processEvent(event, callbacks); - if (dontDo) - { - return; - } - - OutputStream out = remote.getFileOutputStream(dst.getPath()); - try - { - InputStream in = fAVMService.getFileInputStream(src); - copyStream(in, out); - } - finally - { - if(out != null) - { - // whatever happens close stream - try - { - out.close(); - } - catch (IOException e) - { - throw new AVMException("I/O Exception", e); - } - } - } - - copyMetadata(version, src, dst, remote); - return; - } - Pair source = - new Pair(version, src.getPath()); - String destination = AVMNodeConverter.ExtendAVMPath(dstParent.getPath(), src.getName()); - DeploymentEvent event = new DeploymentEvent(DeploymentEvent.Type.UPDATED, - source, - destination); - processEvent(event, callbacks); - if (dontDo) - { - return; - } - // Destination is a directory and the source is a file. - // Delete the destination directory and copy the file over. - remote.removeNode(dstParent.getPath(), dst.getName()); - - OutputStream out = remote.createFile(dstParent.getPath(), src.getName()); - try - { - InputStream in = fAVMService.getFileInputStream(src); - copyStream(in, out); - } - finally - { - if(out != null) - { - // whatever happens close stream - try - { - out.close(); - } - catch (IOException e) - { - throw new AVMException("I/O Exception", e); - } - } - } - copyMetadata(version, src, remote.lookup(-1, dstParent.getPath() + '/' + dst.getName()), remote); - } - - /** - * Recursively copy a directory. - * @param src - * @param parent - * @param remote - */ - private void copyDirectory(int version, AVMNodeDescriptor src, AVMNodeDescriptor parent, - AVMRemote remote, NameMatcher matcher, Listcallbacks) - { - // Create the destination directory. - remote.createDirectory(parent.getPath(), src.getName()); - AVMNodeDescriptor newParent = remote.lookup(-1, parent.getPath() + '/' + src.getName()); - copyMetadata(version, src, newParent, remote); - SortedMap list = - fAVMService.getDirectoryListing(src); - // For each child in the source directory. - for (AVMNodeDescriptor child : list.values()) - { - if (!excluded(matcher, child.getPath(), null)) - { - /** - * Temporary work around for staleness. - */ - if (isStale(child)) - { - if (fgLogger.isDebugEnabled()) - { - fgLogger.debug("Stale child found: " + child); - } - continue; - } - - // If it's a file, copy it over and move on. - if (child.isFile()) - { - DeploymentEvent event = - new DeploymentEvent(DeploymentEvent.Type.CREATED, - new Pair(version, src.getPath() + '/' + child.getName()), - newParent.getPath() + '/' + child.getName()); - processEvent(event, callbacks); - - OutputStream out = remote.createFile(newParent.getPath(), child.getName()); - try - { - InputStream in = fAVMService.getFileInputStream(child); - copyStream(in, out); - } - finally - { - if(out != null) - { - // whatever happens close stream - try - { - out.close(); - } - catch (IOException e) - { - throw new AVMException("I/O Exception", e); - } - } - } - copyMetadata(version, child, remote.lookup(-1, newParent.getPath() + '/' + child.getName()), remote); - } - else - { - // is a directory - DeploymentEvent event = - new DeploymentEvent(DeploymentEvent.Type.CREATED, - new Pair(version, src.getPath() + '/' + child.getName() ), - newParent.getPath() + '/' + child.getName()); - processEvent(event, callbacks); - // Otherwise copy the child directory recursively. - copyDirectory(version, child, newParent, remote, matcher, callbacks); - } - } - } - } - - /** - * Utility for copying from one stream to another. - * - * in is closed. - * - * out is not closed. - * - * @param in The input stream. - * @param out The output stream. - */ - private void copyStream(InputStream in, OutputStream out) - { - byte[] buff = new byte[8192]; - int read = 0; - try - { - while ((read = in.read(buff)) != -1) - { - out.write(buff, 0, read); - } - in.close(); - //out.flush(); - //out.close(); - } - catch (IOException e) - { - throw new AVMException("I/O Exception", e); - } - } - - private void copyMetadata(int version, AVMNodeDescriptor src, AVMNodeDescriptor dst, AVMRemote remote) - { - Map props = fAVMService.getNodeProperties(version, src.getPath()); - remote.setNodeProperties(dst.getPath(), props); - Set aspects = fAVMService.getAspects(version, src.getPath()); - for (QName aspect : aspects) - { - if (remote.hasAspect(-1, dst.getPath(), aspect)) - { - continue; - } - remote.addAspect(dst.getPath(), aspect); - } - remote.setGuid(dst.getPath(), src.getGuid()); - if (src.isFile()) - { - ContentData contData = fAVMService.getContentDataForRead(version, src.getPath()); - remote.setEncoding(dst.getPath(), contData.getEncoding()); - remote.setMimeType(dst.getPath(), contData.getMimetype()); - } - } - - /** - * Utility to get an AVMRemote from a remote Alfresco Server. - * @param hostName - * @param port - * @param userName - * @param password - * @return - */ - private AVMRemote getRemote(String hostName, int port, String userName, String password) - { - try - { - RmiProxyFactoryBean authFactory = new RmiProxyFactoryBean(); - authFactory.setRefreshStubOnConnectFailure(true); - authFactory.setServiceInterface(AuthenticationService.class); - authFactory.setServiceUrl("rmi://" + hostName + ":" + port + "/authentication"); - authFactory.afterPropertiesSet(); - AuthenticationService authService = (AuthenticationService)authFactory.getObject(); - authService.authenticate(userName, password.toCharArray()); - String ticket = authService.getCurrentTicket(); - fTicketHolder.setTicket(ticket); - RmiProxyFactoryBean remoteFactory = new RmiProxyFactoryBean(); - remoteFactory.setRefreshStubOnConnectFailure(true); - remoteFactory.setServiceInterface(AVMRemoteTransport.class); - remoteFactory.setServiceUrl("rmi://" + hostName + ":" + port + "/avm"); - remoteFactory.afterPropertiesSet(); - AVMRemoteTransport transport = (AVMRemoteTransport)remoteFactory.getObject(); - AVMRemoteImpl remote = new AVMRemoteImpl(); - remote.setAvmRemoteTransport(transport); - remote.setClientTicketHolder(fTicketHolder); - return remote; - } - catch (Exception e) - { - throw new AVMException("Could not Initialize Remote Connection to " + hostName, e); - } - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avm.deploy.DeploymentService#getRemoteActionService(java.lang.String, int, java.lang.String, java.lang.String) - */ - public ActionService getRemoteActionService(String hostName, int port, String userName, String password) - { - try - { - RmiProxyFactoryBean authFactory = new RmiProxyFactoryBean(); - authFactory.setRefreshStubOnConnectFailure(true); - authFactory.setServiceInterface(AuthenticationService.class); - authFactory.setServiceUrl("rmi://" + hostName + ":" + port + "/authentication"); - authFactory.afterPropertiesSet(); - AuthenticationService authService = (AuthenticationService)authFactory.getObject(); - authService.authenticate(userName, password.toCharArray()); - String ticket = authService.getCurrentTicket(); - fTicketHolder.setTicket(ticket); - RmiProxyFactoryBean remoteFactory = new RmiProxyFactoryBean(); - remoteFactory.setRefreshStubOnConnectFailure(true); - remoteFactory.setServiceInterface(ActionServiceTransport.class); - remoteFactory.setServiceUrl("rmi://" + hostName + ":" + port + "/action"); - remoteFactory.afterPropertiesSet(); - ActionServiceTransport transport = (ActionServiceTransport)remoteFactory.getObject(); - ActionServiceRemote remote = new ActionServiceRemote(); - remote.setActionServiceTransport(transport); - remote.setClientTicketHolder(fTicketHolder); - return remote; - } - catch (Exception e) - { - throw new AVMException("Could not Initialize Remote Connection to " + hostName, e); - } - } - - /** - * Utility method to get the payload transformers for a named transport - * - * The transport adapters are sprung into the deploymentReceiverTransportAdapters property - * - * @return the transformers - */ - private List getTransformers(String transportName) - { - - DeploymentReceiverTransportAdapter adapter = deploymentReceiverTransportAdapters.get(transportName); - - if(adapter == null) { - // Adapter does not exist - fgLogger.error("Deployment Receiver Transport adapter does not exist for transport. Name: " + transportName); - throw new AVMException("Deployment Receiver Transport adapter does not exist for transport. Name: " + transportName); - } - - List transformers = adapter.getTransformers(); - return transformers; - } - - - - /** - * Utility method to get a connection to a remote file system receiver (FSR) - * - * The transport adapters are sprung into the deploymentReceiverTransportAdapters property - * @param transportName the name of the adapter for the transport - * @param hostName the hostname or IP address to connect to - * @param port the port number - * @param version the version of the website to deploy - * @param srcPath the path of the website - * - * @return an implementation of the service - */ - private DeploymentReceiverService getDeploymentReceiverService(String transportName, String hostName, int port, int version, String srcPath) - { - - DeploymentReceiverTransportAdapter adapter = deploymentReceiverTransportAdapters.get(transportName); - - if(adapter == null) { - // Adapter does not exist - fgLogger.error("Deployment Receiver Transport adapter does not exist for transport. Name: " + transportName); - throw new AVMException("Deployment Receiver Transport adapter does not exist for transport. Name: " + transportName); - } - try - { - DeploymentReceiverTransport transport = adapter.getTransport(hostName, port, version, srcPath); - - // Now decorate the transport with the service client - DeploymentReceiverServiceClient service = new DeploymentReceiverServiceClient(); - service.setDeploymentReceiverTransport(transport); - return service; - } - catch (Exception e) - { - throw new AVMException("Could not connect to remote deployment receiver, transportName:" + transportName + ", hostName:" + hostName + ", port: " + port, e); - } - } - - /** - * Utility to get the sync service for rolling back after a failed deployment. - * @param hostName The target machine. - * @param port The port. - * @return An AVMSyncService instance. - */ - private AVMSyncService getSyncService(String hostName, int port) - { - try - { - RmiProxyFactoryBean syncFactory = new RmiProxyFactoryBean(); - syncFactory.setRefreshStubOnConnectFailure(true); - syncFactory.setServiceInterface(AVMSyncServiceTransport.class); - syncFactory.setServiceUrl("rmi://" + hostName + ":" + port + "/avmsync"); - syncFactory.afterPropertiesSet(); - AVMSyncServiceTransport syncServiceTransport = (AVMSyncServiceTransport)syncFactory.getObject(); - AVMSyncServiceRemote remote = new AVMSyncServiceRemote(); - remote.setAvmSyncServiceTransport(syncServiceTransport); - remote.setClientTicketHolder(fTicketHolder); - return remote; - } - catch (Exception e) - { - throw new AVMException("Could not roll back failed deployment to " + hostName, e); - } - } - - /** - * Helper function to create a non existent destination. - * @param remote The AVMRemote instance. - * @param dstPath The destination path to create. - */ - private void createDestination(AVMRemote remote, String dstPath) - { - String[] storePath = dstPath.split(":"); - String storeName = storePath[0]; - String path = storePath[1]; - AVMStoreDescriptor storeDesc = remote.getStore(storeName); - if (storeDesc == null) - { - remote.createStore(storeName); - } - SimplePath simpPath = new SimplePath(path); - if (simpPath.size() == 0) - { - return; - } - String prevPath = storeName + ":/"; - for (int i = 0; i < simpPath.size(); i++) - { - String currPath = AVMNodeConverter.ExtendAVMPath(prevPath, simpPath.get(i)); - AVMNodeDescriptor desc = remote.lookup(-1, currPath); - if (desc == null) - { - remote.createDirectory(prevPath, simpPath.get(i)); - } - prevPath = currPath; - } - } - - private SetgetAspects(AVMService avmService, AVMNodeDescriptor src) - { - Setaspects = avmService.getAspects(src); - SetstringAspects = new HashSet(); - for (QName aspect : aspects) - { - stringAspects.add(aspect.toString()); - } - return stringAspects; - } - - private Map getProperties(AVMNodeDescriptor src, int version) - { - /** - * Get the AVM properties - which do not have any of the "syntetic" Node Service Values. - */ - Map properties = fAVMService.getNodeProperties(src); - NodeRef nodeRef = AVMNodeConverter.ToNodeRef(version, src.getPath()); - - /** - * Get the properties in Node Service format - */ - Map nodeProps = fAVMNodeService.getProperties(nodeRef); - - Map retVal = new HashMap(); - for(QName key : properties.keySet()) - { - Serializable value = nodeProps.get(key); - retVal.put(key.toString(), value); - } - return retVal; - } - - /** - * Deploy differences to a File System Receiver, FSR - * - * @param version snapshot version to deploy. If 0 then a new snapshot is created. - * @param srcPath - * @param adapterName - * @param hostName - * @param port - * @param userName - * @param password - * @param target - * @param matcher - * @param createDst Not implemented - * @param dontDelete Not implemented - * @param dontDo Not implemented - * @param callbacks Event callbacks when a deployment Starts, Ends, Adds, Deletes etc. - * - * @throws AVMException - * - * @see org.alfresco.service.cmr.avm.deploy.DeploymentService#deployDifferenceFS(int, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, boolean, boolean) - */ - public void deployDifferenceFS(int version, - final String srcPath, - String adapterName, - String hostName, - int port, - String userName, - String password, - String target, - final NameMatcher matcher, - boolean createDst, - boolean dontDelete, - boolean dontDo, - List callbacks) - { - - fgLogger.debug("deployDifferenceFS start"); - /** - * Lock cluster for the remote target - */ - String lockStr = "deploy." + hostName + "." + port + "." + target; - QName lockQName = QName.createQName("{http://www.alfresco.org/deploymentService/1.0}" + lockStr); - final Lock lock = new Lock(lockQName); - lock.makeLock(); - try - { - /** - * Cluster Lock held here - */ - if (fgLogger.isDebugEnabled()) - { - Object[] objs = {version, srcPath, adapterName, hostName, port, target}; - MessageFormat f = new MessageFormat("Deployment Lock Held: version {0}, srcPath {1}, adapterName {2}, hostName {3}, port {4}, target {5}"); - fgLogger.debug(f.format(objs)); - } - - DeploymentReceiverService service = null; - Listtransformers = null; - String ticket = null; - - String currentEffectiveUser = AuthenticationUtil.getRunAsUser(); - - try - { - // Kick off the event queue that will process deployment call-backs - final LinkedBlockingQueue eventQueue = new LinkedBlockingQueue(); - EventQueueWorker eventQueueWorker = new EventQueueWorker(currentEffectiveUser, eventQueue, callbacks); - eventQueueWorker.setName(eventQueueWorker.getClass().getName()); - eventQueueWorker.setPriority(Thread.currentThread().getPriority()); - eventQueueWorker.start(); - - try - { - final String storeName = srcPath.substring(0, srcPath.indexOf(':')); - try { - - if (version < 0) - { - RetryingTransactionHelper trn = trxService.getRetryingTransactionHelper(); - - RetryingTransactionCallback localSnapshot = new RetryingTransactionCallback() - { - public Integer execute() throws Throwable - { - int newVersion = fAVMService.createSnapshot(storeName, null, null).get(storeName); - return new Integer(newVersion); - } - }; - version = trn.doInTransaction(localSnapshot, false, true).intValue(); - fgLogger.debug("snapshot local created " + storeName + ", " + version); - } - - transformers = getTransformers(adapterName); - service = getDeploymentReceiverService(adapterName, hostName, port, version, srcPath); - } - catch (Exception e) - { - // unable to get service - eventQueue.add(new DeploymentEvent(DeploymentEvent.Type.FAILED, - new Pair(version, srcPath), - target, e.getMessage())); - throw e; - } - - eventQueue.add(new DeploymentEvent(DeploymentEvent.Type.START, - new Pair(version, srcPath), - target)); - - // Go parallel to reduce the problems of high network latency - - final LinkedBlockingQueue sendQueue = new LinkedBlockingQueue(); - final List errors = Collections.synchronizedList(new ArrayList()); - - SendQueueWorker[] workers = new SendQueueWorker[numberOfSendingThreads]; - for(int i = 0; i < numberOfSendingThreads; i++) - { - workers[i] = new SendQueueWorker(currentEffectiveUser, service, fAVMService, trxService, errors, eventQueue, sendQueue, transformers); - workers[i].setName(workers[i].getClass().getName()); - workers[i].setPriority(Thread.currentThread().getPriority()); - } - - for(SendQueueWorker sender : workers) - { - sender.start(); - } - - try - { - fgLogger.debug("calling begin"); - DeploymentToken token = service.begin(target, storeName, version, userName, password.toCharArray()); - ticket = token.getTicket(); - - lock.checkLock(); - - // run this in its own txn - final DeploymentReceiverService fservice = service; - final String fTicket = ticket; - final int fVersion = version; - RetryingTransactionCallback pushFSR = new RetryingTransactionCallback() - { - public Integer execute() throws Throwable - { - deployDirectoryPushFSR(fservice, fTicket, fVersion, srcPath, "/", matcher, eventQueue, sendQueue, errors, lock); - return 0; - } - }; - - RetryingTransactionHelper trn = trxService.getRetryingTransactionHelper(); - trn.doInTransaction(pushFSR, false, true); - - } - catch (Exception e) - { - errors.add(e); - } - catch (Throwable t) - { - errors.add(new AVMException("Unexpected Throwable", t)); - } - finally - { - // clean up senders thread pool - fgLogger.debug("closing deployment workers"); - for(SendQueueWorker sender : workers) - { - sender.stopMeWhenIdle(); - } - for(SendQueueWorker sender : workers) - { - sender.join(); - } - fgLogger.debug("deployment workers closed"); - - if (errors.size() <= 0 && ticket != null) - { - try - { - fgLogger.debug("no errors - prepare and commit"); - lock.checkLock(); - - service.prepare(ticket); - lock.checkLock(); - - service.commit(ticket); - // no point checking the lock here - we have committed. - } - catch (Exception e) - { - errors.add(e); - } - } - - if(errors.size() > 0) - { - fgLogger.debug("errors on deployment workers"); - Exception firstError = errors.get(0); - - eventQueue.add(new DeploymentEvent(DeploymentEvent.Type.FAILED, - new Pair(version, srcPath), - target, firstError.getMessage())); - - if (ticket != null) - { - try - { - service.abort(ticket); - } - catch (Exception ae) - { - // nothing we can do here - fgLogger.error("Unable to abort deployment. Error in exception handler", ae); - } - } - // yes there were errors, throw the first exception that was saved - MessageFormat f = new MessageFormat("Error during deployment srcPath: {0}, version:{1}, adapterName:{2}, hostName:{3}, port:{4}, error:{5}"); - Object[] objs = { srcPath, version, adapterName, hostName, port, firstError }; - - throw new AVMException(f.format(objs), firstError); - } - } // end of finally block - - // Success if we get here - eventQueue.add(new DeploymentEvent(DeploymentEvent.Type.END, - new Pair(version, srcPath), - target)); - - fgLogger.debug("deployment completed successfully"); - } - finally - { - // Now stutdown the event queue - fgLogger.debug("closing event queue"); - eventQueueWorker.stopMeWhenIdle(); - eventQueueWorker.join(); - fgLogger.debug("event queue closed"); - } - } - catch (Exception e) - { - // yes there were errors - MessageFormat f = new MessageFormat("Deployment exception, unable to deploy : srcPath:{0}, target:{1}, version:{2}, adapterName:{3}, hostName:{4}, port:{5}, error:{6}"); - Object[] objs = { srcPath, target, version, adapterName, hostName, port, e }; - throw new AVMException(f.format(objs), e); - } - } - finally - { - fgLogger.debug("At end of method - about to release lock"); - lock.releaseLock(); - } - } // End of deploy difference FS - - - private class ComparatorFileDescriptorCaseSensitive implements Comparator - { - public int compare(FileDescriptor o1, FileDescriptor o2) - { - return o1.getName().compareTo(o2.getName()); - } - } - - private class ComparatorAVMNodeDescriptorCaseSensitive implements Comparator - { - public int compare(AVMNodeDescriptor o1, AVMNodeDescriptor o2) - { - return o1.getName().compareTo(o2.getName()); - } - } - - private ComparatorFileDescriptorCaseSensitive FILE_DESCRIPTOR_CASE_SENSITIVE = new ComparatorFileDescriptorCaseSensitive(); - private ComparatorAVMNodeDescriptorCaseSensitive AVM_DESCRIPTOR_CASE_SENSITIVE = new ComparatorAVMNodeDescriptorCaseSensitive(); - - /** - * deployDirectoryPush (FSR only) - * - * Compares the source and destination listings and updates report with update events required to make - * dest similar to src. - * - * @param service - * @param ticket - * @param report - * @param callbacks - * @param version - * @param srcPath - * @param dstPath - * @param matcher - */ - private void deployDirectoryPushFSR(DeploymentReceiverService service, - String ticket, - int version, - String srcPath, - String dstPath, - NameMatcher matcher, - BlockingQueue eventQueue, - BlockingQueue sendQueue, - List errors, - Lock lock) - { - Map rawSrcListing = fAVMService.getDirectoryListing(version, srcPath); - List rawDstListing = service.getListing(ticket, dstPath); - - // Need to change from case insensitive order to case sensitive order - TreeSet dstListing = new TreeSet(FILE_DESCRIPTOR_CASE_SENSITIVE); - dstListing.addAll(rawDstListing); - - TreeSet srcListing = new TreeSet(AVM_DESCRIPTOR_CASE_SENSITIVE); - srcListing.addAll(rawSrcListing.values()); - - Iterator dstIter = dstListing.iterator(); - Iterator srcIter = srcListing.iterator(); - - lock.checkLock(); - - // Here with two sorted directory listings - AVMNodeDescriptor src = null; - FileDescriptor dst = null; - - // Step through both directory listings - while ((srcIter.hasNext() || dstIter.hasNext() || src != null || dst != null) && errors.size() <= 0) - { - if (src == null) - { - if (srcIter.hasNext()) - { - src = srcIter.next(); - - /** - * Temporary check for stale assets - * - * Correct fix would be to remove stale files from the snapshot. - * Code becomes obsolete once stale files are not part of the snapshot. - */ - if (isStale(src)) - { - if (fgLogger.isDebugEnabled()) - { - fgLogger.debug("Stale child found: " + src); - } - src = null; - continue; - } - } - } - if (dst == null) - { - if (dstIter.hasNext()) - { - dst = dstIter.next(); - } - } - if (fgLogger.isDebugEnabled()) - { - fgLogger.debug("comparing src:" + src + " dst:"+ dst); - } - - lock.checkLock(); - - // This means no entry on src so delete what is on dst. - if (src == null) - { - String newDstPath = extendPath(dstPath, dst.getName()); - if (!excluded(matcher, null, newDstPath)) - { - sendQueue.add(new DeploymentWork(new DeploymentEvent(DeploymentEvent.Type.DELETED, - new Pair(version, extendPath(srcPath, dst.getName())), - newDstPath), ticket)); - } - dst = null; - continue; - } - // Nothing on the destination so copy over. - if (dst == null) - { - if (!excluded(matcher, src.getPath(), null)) - { - createOnFSR(service, ticket, version, src, dstPath, matcher, sendQueue); - } - src = null; - continue; - } - - // Here with src and dst containing something - int diff = src.getName().compareTo(dst.getName()); - if (diff < 0) - { - // src is less than dst - must be new content in src - if (!excluded(matcher, src.getPath(), null)) - { - createOnFSR(service, ticket, version, src, dstPath, matcher, sendQueue); - } - src = null; - continue; - } - if (diff == 0) - { - /** - * src and dst have same file name and GUID - nothing to do - */ - if (src.getGuid().equals(dst.getGUID())) - { - src = null; - dst = null; - continue; - } - - /** - * src and dst are different and src is a file - */ - if (src.isFile()) - { - // this is an update to a file - String extendedPath = extendPath(dstPath, dst.getName()); - if (!excluded(matcher, src.getPath(), extendedPath)) - { - // Work in progress - sendQueue.add(new DeploymentWork( - new DeploymentEvent(DeploymentEvent.Type.UPDATED, - new Pair(version, src.getPath()), - extendedPath), ticket, src, version)); - } - src = null; - dst = null; - continue; - } - - /** - * src and dst are different and src is a directory - */ - if (dst.getType() == FileType.DIR) - { - String extendedPath = extendPath(dstPath, dst.getName()); - - SetstringAspects = getAspects(fAVMService, src); - Map stringProperties = getProperties(src, version); - - /** - * Update the directory before any children - */ - service.updateDirectory(ticket, extendedPath, src.getGuid(), stringAspects, stringProperties); - - if (!excluded(matcher, src.getPath(), extendedPath)) - { - deployDirectoryPushFSR(service, ticket, version, src.getPath(), extendedPath, matcher, eventQueue, sendQueue, errors, lock); - } - - src = null; - dst = null; - continue; - } - if (!excluded(matcher, src.getPath(), null)) - { - createOnFSR(service, ticket, version, src, dstPath, matcher, sendQueue); - } - src = null; - dst = null; - continue; - } - - /** - * diff > 0 - * Destination is missing in source, delete it. - */ - String newDstPath = extendPath(dstPath, dst.getName()); - - sendQueue.add(new DeploymentWork(new DeploymentEvent(DeploymentEvent.Type.DELETED, - new Pair(version, extendPath(srcPath, dst.getName())), - newDstPath), ticket)); - - // - - dst = null; - } - } - - /** - * Copy a file or directory to an empty destination on an FSR - * @param service - * @param ticket - * @param report - * @param callback - * @param version - * @param src - * @param parentPath - */ - private void createOnFSR(DeploymentReceiverService service, - String ticket, - int version, - AVMNodeDescriptor src, - String parentPath, - NameMatcher matcher, - BlockingQueue sendQueue) - { - String dstPath = extendPath(parentPath, src.getName()); - - // Need to queue the request to copy file or dir to remote. - sendQueue.add(new DeploymentWork( - new DeploymentEvent(DeploymentEvent.Type.CREATED, - new Pair(version, src.getPath()), - dstPath), ticket, src, version)); - - if (src.isFile()) - { - return; - } - - // here if src is a directory. - - // Need to create directories in controlling thread since it needs to be created - // BEFORE any children are written - SetstringAspects = getAspects(fAVMService, src); - Map stringProperties = getProperties(src, version); - - service.createDirectory(ticket, dstPath, src.getGuid(), stringAspects, stringProperties); - - // now copy the children over - Map listing = fAVMService.getDirectoryListing(src); - for (AVMNodeDescriptor child : listing.values()) - { - if (!excluded(matcher, child.getPath(), null)) - { - if (isStale(child)) - { - if (fgLogger.isDebugEnabled()) - { - fgLogger.debug("Stale child found: " + child); - } - continue; - } - createOnFSR(service, ticket, version, child, dstPath, matcher, sendQueue); - } - } - } - - private void processEvent(DeploymentEvent event, List callbacks) - { - if (fgLogger.isDebugEnabled()) - { - fgLogger.debug(event); - } - if (callbacks != null) - { - for (DeploymentCallback callback : callbacks) - { - callback.eventOccurred(event); - } - } - } - - /** - * Extend a path. - * @param path - * @param name - * @return - */ - private String extendPath(String path, String name) - { - if (path.endsWith("/")) - { - return path + name; - } - return path + '/' + name; - } - - /** - * Returns true if either srcPath or dstPath are matched by matcher. - * @param matcher - * @param srcPath - * @param dstPath - * @return - */ - private boolean excluded(NameMatcher matcher, String srcPath, String dstPath) - { - return matcher != null && ((srcPath != null && matcher.matches(srcPath)) || (dstPath != null && matcher.matches(dstPath))); - } - - private Map deploymentReceiverTransportAdapters; - /** - * The deployment transport adapters provide the factories used to connect to a remote file system receiver. - */ - public void setDeploymentReceiverTransportAdapters(Map adapters) { - this.deploymentReceiverTransportAdapters=adapters; - } - - public Map getDeploymentReceiverTransportAdapters() { - return this.deploymentReceiverTransportAdapters; - } - - public Set getAdapterNames() - { - if(deploymentReceiverTransportAdapters != null) { - return(deploymentReceiverTransportAdapters.keySet()); - } - else - { - Set ret = new HashSet(1); - ret.add("default"); - return ret; - } - } - - public List findLiveDeploymentServers(NodeRef webProjectRef) - { - return findDeploymentServers(webProjectRef, true, false); - } - - public List findTestDeploymentServers(NodeRef webProjectRef, boolean availableOnly) - { - return findDeploymentServers(webProjectRef, false, availableOnly); - } - - private List findDeploymentServers(NodeRef webProjectRef, boolean live, boolean availableOnly) - { - - Path projectPath = nodeService.getPath(webProjectRef); - String stringPath = projectPath.toPrefixString(namespacePrefixResolver); - String serverType; - - if (live) - { - serverType = WCMAppModel.CONSTRAINT_LIVESERVER; - } - else - { - serverType = WCMAppModel.CONSTRAINT_TESTSERVER; - } - - - StringBuilder query = new StringBuilder("PATH:\""); - - query.append(stringPath); - query.append("/*\" "); - query.append(" AND @"); - query.append(NamespaceService.WCMAPP_MODEL_PREFIX); - query.append("\\:"); - query.append(WCMAppModel.PROP_DEPLOYSERVERTYPE.getLocalName()); - query.append(":\""); - query.append(serverType); - query.append("\""); - - // if required filter the test servers - if (live == false && availableOnly) - { - query.append(" AND ISNULL:\""); - query.append(WCMAppModel.PROP_DEPLOYSERVERALLOCATEDTO.toString()); - query.append("\""); - } - - if (fgLogger.isDebugEnabled()) - fgLogger.debug("Finding deployment servers using query: " + query.toString()); - - // execute the query - ResultSet results = null; - List servers = new ArrayList(); - try - { - results = searchService.query(webProjectRef.getStoreRef(), - SearchService.LANGUAGE_LUCENE, query.toString()); - - if (fgLogger.isDebugEnabled()) - fgLogger.debug("Found " + results.length() + " deployment servers"); - - for (NodeRef server : results.getNodeRefs()) - { - servers.add(server); - } - } - finally - { - if (results != null) - { - results.close(); - } - } - - return servers; - } - - public void setNumberOfSendingThreads(int numberOfSendingThreads) { - this.numberOfSendingThreads = numberOfSendingThreads; - } - - public int getNumberOfSendingThreads() { - return numberOfSendingThreads; - } - - public void setJobLockService(JobLockService jobLockService) { - this.jobLockService = jobLockService; - } - - public JobLockService getJobLockService() { - return jobLockService; - } - - public void setTargetLockTimeToLive(long targetLockTimeToLive) { - this.targetLockTimeToLive = targetLockTimeToLive; - } - - public long getTargetLockTimeToLive() { - return targetLockTimeToLive; - } - - public void setTargetLockRetryWait(long targetLockRetryWait) { - this.targetLockRetryWait = targetLockRetryWait; - } - - public long getTargetLockRetryWait() { - return targetLockRetryWait; - } - - public void setTargetLockRetryCount(int targetLockRetryCount) { - this.targetLockRetryCount = targetLockRetryCount; - } - - public int getTargetLockRetryCount() { - return targetLockRetryCount; - } - - public void setAvmNodeService(AVMNodeService fAVMNodeService) { - this.fAVMNodeService = fAVMNodeService; - } - - public AVMNodeService getAvmNodeService() { - return fAVMNodeService; - } - - public void setOutputBufferSize(int outputBufferSize) { - this.outputBufferSize = outputBufferSize; - } - - public int getOutputBufferSize() { - return outputBufferSize; - } - - /** - * This thread processes the event queue to do the callbacks - * @author mrogers - * - */ - private class EventQueueWorker extends Thread - { - private BlockingQueue eventQueue; - private List callbacks; - private String userName; - - private boolean stopMe = false; - - EventQueueWorker(String userName, BlockingQueue eventQueue, List callbacks) - { - this.eventQueue = eventQueue; - this.callbacks = callbacks; - this.userName = userName; - } - - public void run() - { - AuthenticationUtil.setFullyAuthenticatedUser(userName); - - while (true) - { - DeploymentEvent event = null; - try { - event = eventQueue.poll(3, TimeUnit.SECONDS); - } catch (InterruptedException e1) { - fgLogger.debug("Interrupted ", e1); - } - - if(event == null) - { - if(stopMe) - { - fgLogger.debug("Event Queue Closing Normally"); - break; - } - continue; - } - - if (fgLogger.isDebugEnabled()) - { - fgLogger.debug(event); - } - if (callbacks != null) - { - for (DeploymentCallback callback : callbacks) - { - callback.eventOccurred(event); - } - } - } - } - - public void stopMeWhenIdle() - { - stopMe = true; - } - - - - } - - /** - * Inner Class to Decorate the jobLockService to - * add control over the refreshLock behaviour. - * - * Deployment service calls (On deployment main thread) - * makeLock and releaseLock around the deployment. - * periodically calls checkLock as it does its work. - * checkLock can throw an exception if the business process has timed out. - * - * isActive and lockReleased called by Job Lock Thread - */ - private class Lock implements JobLockRefreshCallback - { - /** - * The name of the lock - unique for each target - */ - QName lockQName; - - /** - * The unique token for this lock instance. - */ - String lockToken; - - /** - * Is the lock active ? - */ - boolean active = false; - - /** - * When did we last check whether the lock is active - */ - Date lastActive = new Date(); - - public Lock(QName lockQName) - { - this.lockQName = lockQName; - } - - /** - * Make the lock - called on main deployment thread - * - * @throws LockAquisitionException - */ - public void makeLock() - { - if(fgLogger.isDebugEnabled()) - { - fgLogger.debug("target lock refresh time :" + getTargetLockRefreshTime() + "targetLockRetryWait:" + targetLockRetryWait + "targetLockRetryCount:" + targetLockRetryCount); - } - lockToken = jobLockService.getLock(lockQName, targetLockRefreshTime, targetLockRetryWait, targetLockRetryCount); - - synchronized(this) - { - active = true; - } - if (fgLogger.isDebugEnabled()) - { - fgLogger.debug("lock taken:" + lockQName); - } - - // We may have taken so long to begin that we have already timed out ! - checkLock(); - - fgLogger.debug("register lock callback, target lock refresh time :" + getTargetLockRefreshTime()); - jobLockService.refreshLock(lockToken, lockQName, getTargetLockRefreshTime(), this); - fgLogger.debug("callback registered"); - } - - /** - * Refresh the lock - called as the business process progresses. - * - * Called on main deployment thread. - * @throws AVMException (Lock timeout) - */ - public void checkLock() - { - // Do I need to sync this? - - if(active) - { - Date now = new Date(); - - if(now.getTime() > lastActive.getTime() + targetLockTimeToLive) - { - // lock time to live has expired. - MessageFormat f = new MessageFormat("Deployment Lock timeout, lock time to live exceeded, timeout:{0}mS time since last activity:{1}mS"); - Object[] objs = {new Long(targetLockTimeToLive), new Long(now.getTime() - lastActive.getTime()) }; - throw new AVMException(f.format(objs)); - } - - // Update lastActive to 1S boundary - if(now.getTime() > lastActive.getTime() + 1000) - { - lastActive = new Date(); - fgLogger.debug("lastActive:" + lastActive); - } - } - else - { - // lock not active. Has been switched off by Job Lock Service. - MessageFormat f = new MessageFormat("Lock timeout, lock not active"); - Object[] objs = { }; - throw new AVMException(f.format(objs)); - } - } - - /** - * Release the lock - * - * Called on main deployment thread - */ - public void releaseLock() - { - if(fgLogger.isDebugEnabled()) - { - fgLogger.debug("deployment service about to releaseLock : " + lockQName); - } - if(active) - { - jobLockService.releaseLock(lockToken, lockQName); - } - fgLogger.debug("setting active = false" + lockQName); - - // may need to sync this - synchronized(this) - { - active = false; - } - } - - /** - * Job Lock Callback - * - * Callback from the job lock service. Is the deployment active? - */ - @Override - public boolean isActive() - { - Date now = new Date(); - - synchronized(this) - { - if(now.getTime() > lastActive.getTime() + targetLockTimeToLive) - { - active = false; - } - - // may need to sync active flag - if(fgLogger.isDebugEnabled()) - { - fgLogger.debug("deployment service callback active: " + active); - } - - return active; - } - } - - /** - * Job Lock Callback. - */ - @Override - public void lockReleased() - { - fgLogger.debug("deployment service: lock released callback"); - synchronized(this) - { - active = false; - } - } - - } - - - - /** - * This thread processes the send queue - * @author mrogers - * - */ - private class SendQueueWorker extends Thread - { - private BlockingQueue eventQueue; - private BlockingQueue sendQueue; - private DeploymentReceiverService service; - private String userName; - private AVMService avmService; - private TransactionService trxService; - List errors; - List transformers; - - private boolean stopMe = false; - - SendQueueWorker(String userName, - DeploymentReceiverService service, - AVMService avmService, - TransactionService trxService, - List errors, - BlockingQueue eventQueue, - BlockingQueue sendQueue, - List transformers - ) - { - this.eventQueue = eventQueue; - this.sendQueue = sendQueue; - this.service = service; - this.avmService = avmService; - this.trxService = trxService; - this.errors = errors; - this.transformers = transformers; - this.userName = userName; - } - - public void run() - { - AuthenticationUtil.setFullyAuthenticatedUser(userName); - - while (errors.size() <= 0) - { - DeploymentWork work = null; - try { - work = sendQueue.poll(3, TimeUnit.SECONDS); - } catch (InterruptedException e1) { - fgLogger.debug("Interrupted ", e1); - continue; - } - - if(work == null) - { - if(stopMe) - { - fgLogger.debug("Send Queue Worker Closing Normally"); - eventQueue = null; - sendQueue = null; - service = null; - errors = null; - break; - } - } - - if(work != null) - { - DeploymentEvent event = work.getEvent(); - String ticket = work.getTicket(); - try - { - if(event.getType().equals(DeploymentEvent.Type.DELETED)) - { - service.delete(ticket, event.getDestination()); - } - else if (event.getType().equals(DeploymentEvent.Type.CREATED)) - { - AVMNodeDescriptor src = work.getSrc(); - if(src.isFile()) - { - copyFileToFSR(src, true, work.getVersion(), event.getDestination(), ticket); - } - else - { - // Do nothing. mkdir done on main thread. - //makeDirectoryOnFSR(src, event.getDestination(), ticket); - } - } - else if (event.getType().equals(DeploymentEvent.Type.UPDATED)) - { - copyFileToFSR(work.getSrc(), false, work.getVersion(), event.getDestination(), ticket); - } - // success, now put the event onto the event queue - eventQueue.add(event); - } - catch (Exception e) - { - errors.add(e); - } - } - } - fgLogger.debug("Send Queue Worker finished"); - } - - public void stopMeWhenIdle() - { - stopMe = true; - } - - - /** - * Create or update a single file on a remote FSR. - * @param ticket - * @param src which file to copy - * @param dstPath where to copy the file - */ - private void copyFileToFSR( - final AVMNodeDescriptor src, - final boolean create, - final int version, - final String dstPath, - final String ticket) - { - try - { - // Perform copy within 'read only' transaction - RetryingTransactionHelper trx = trxService.getRetryingTransactionHelper(); - trx.setMaxRetries(1); - trx.doInTransaction(new RetryingTransactionCallback() - { - public Boolean execute() throws Exception - { - ContentData data = avmService.getContentDataForRead(src); - InputStream in = avmService.getFileInputStream(src); - String encoding = data.getEncoding(); - String mimeType = data.getMimetype(); - - SetstringAspects = getAspects(avmService, src); - Map stringProperties = getProperties(src, version); - OutputStream out = service.send(ticket, create, dstPath, src.getGuid(), encoding, mimeType, stringAspects, stringProperties); - - try - { - // Buffer the output, we don't want to send lots of small packets - out = new BufferedOutputStream(out, outputBufferSize); - - // Call content transformers here to transform from local to network format - if(transformers != null && transformers.size() > 0) { - // yes we have pay-load transformers - for(DeploymentTransportOutputFilter transformer : transformers) - { - out = transformer.addFilter(out, src.getPath(), encoding, mimeType); - } - } - - copyStream(in, out); - } - finally - { - // whatever happens close the output stream - if(out != null) - { - out.close(); - out = null; - } - } - return true; - } - }, true); - } - catch (Exception e) - { - fgLogger.debug("Failed to copy dstPath:" + dstPath , e); - - // throw first exception - this is the root of the problem. - throw new AVMException("Failed to copy filename:" + dstPath, e); - } - } - } - - private boolean isStale(AVMNodeDescriptor avmRef) - { - // note: currently specific to WCM use-cases, eg. ETHREEOH-2758 - if ((avmRef.isLayeredDirectory() && avmRef.isPrimary()) || avmRef.isLayeredFile()) - { - AVMNodeDescriptor srcNode = avmRef; - - while ((srcNode.isLayeredDirectory() && srcNode.isPrimary()) || srcNode.isLayeredFile()) - { - AVMNodeDescriptor targetNode = fAVMService.lookup(srcNode.getIndirectionVersion(), srcNode.getIndirection()); - if (targetNode == null) - { - if (srcNode.isLayeredFile() || - (srcNode.isLayeredDirectory() && - (! srcNode.getOpacity()) && - fAVMService.getDirectoryListingDirect(srcNode, false).isEmpty())) - { - // The target node is missing - return true; - } - else - { - // unbacked layered dir - however opaque or not directly empty - return false; - } - } - srcNode = targetNode; - } - } - return false; - } - - - public void setTargetLockRefreshTime(long targetLockRefreshTime) - { - this.targetLockRefreshTime = targetLockRefreshTime; - } - - /** - * How long to keep a lock before refreshing it? - *

- * Short time-out, typically a minute. - * @return the time in mS for how long to keep the lock. - */ - public long getTargetLockRefreshTime() - { - return targetLockRefreshTime; - } -} diff --git a/source/java/org/alfresco/repo/deploy/DeploymentWork.java b/source/java/org/alfresco/repo/deploy/DeploymentWork.java deleted file mode 100644 index 779f5c109f..0000000000 --- a/source/java/org/alfresco/repo/deploy/DeploymentWork.java +++ /dev/null @@ -1,68 +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 . - */ -package org.alfresco.repo.deploy; - -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.deploy.DeploymentEvent; - -class DeploymentWork -{ - private DeploymentEvent event; - private AVMNodeDescriptor src; - private String ticket; - private int version; - - public DeploymentWork(DeploymentEvent event, String ticket) - { - this.event = event; - this.ticket = ticket; - } - - public DeploymentWork(DeploymentEvent event, String ticket, AVMNodeDescriptor src, int version) - { - this.event = event; - this.ticket = ticket; - this.setSrc(src); - this.version = version; - } - - public DeploymentEvent getEvent() - { - return event; - } - - public String getTicket() - { - return this.ticket; - } - - public void setSrc(AVMNodeDescriptor src) { - this.src = src; - } - - public AVMNodeDescriptor getSrc() { - return src; - } - - public int getVersion() - { - return version; - } - -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMAspectEntity.java b/source/java/org/alfresco/repo/domain/avm/AVMAspectEntity.java deleted file mode 100644 index 226d89501d..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMAspectEntity.java +++ /dev/null @@ -1,64 +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 . - */ -package org.alfresco.repo.domain.avm; - - -/** - * Entity bean for avm_aspects table - * - * @author janv - * @since 3.2 - */ - -public class AVMAspectEntity -{ - private Long nodeId; - private Long qnameId; - - public AVMAspectEntity() - { - // default constructor - } - - public AVMAspectEntity(Long nodeId, Long qnameId) - { - this.nodeId = nodeId; - this.qnameId = qnameId; - } - - public Long getNodeId() - { - return nodeId; - } - - public void setNodeId(Long nodeId) - { - this.nodeId = nodeId; - } - - public Long getQnameId() - { - return qnameId; - } - - public void setQnameId(Long qnameId) - { - this.qnameId = qnameId; - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMChildEntryEntity.java b/source/java/org/alfresco/repo/domain/avm/AVMChildEntryEntity.java deleted file mode 100644 index 971fa93465..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMChildEntryEntity.java +++ /dev/null @@ -1,133 +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 . - */ -package org.alfresco.repo.domain.avm; - -import java.io.Serializable; - -import org.alfresco.util.EqualsHelper; - -/** - * Entity bean for avm_child_entries table - * - * @author janv - * @since 3.2 - */ -public class AVMChildEntryEntity implements Serializable -{ - private static final long serialVersionUID = 1L; - private Long parentNodeId; - private String name; - private String lowerName; // Derived from name for case insensitive lookups - private Long childNodeId; - - public AVMChildEntryEntity() - { - // default constructor - } - - public AVMChildEntryEntity(long parentNodeId, String name, long childNodeId) - { - this.parentNodeId = parentNodeId; - this.name = name; - this.lowerName = name == null ? null : name.toLowerCase(); - this.childNodeId = childNodeId; - } - - public AVMChildEntryEntity(long parentNodeId, String name) - { - this.parentNodeId = parentNodeId; - this.name = name; - this.lowerName = name == null ? null : name.toLowerCase(); - } - - public AVMChildEntryEntity(long parentNodeId, long childNodeId) - { - this.parentNodeId = parentNodeId; - this.childNodeId = childNodeId; - } - - public Long getParentNodeId() - { - return parentNodeId; - } - - public void setParentNodeId(Long parentNodeId) - { - this.parentNodeId = parentNodeId; - } - - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - this.lowerName = name == null ? null : name.toLowerCase(); - } - - public String getLowerName() - { - return lowerName; - } - - public void setLowerName(String lowerName) - { - this.lowerName = lowerName; - } - - public Long getChildId() - { - return childNodeId; - } - - public void setChildNodeId(Long childNodeId) - { - this.childNodeId = childNodeId; - } - - @Override - public int hashCode() - { - return ((parentNodeId == null ? 0 : parentNodeId.hashCode()) + - (name == null ? 0 : name.hashCode()) + - (childNodeId == null ? 0 : childNodeId.hashCode())); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - else if (obj instanceof AVMChildEntryEntity) - { - AVMChildEntryEntity that = (AVMChildEntryEntity) obj; - return (EqualsHelper.nullSafeEquals(this.parentNodeId, that.parentNodeId) && - EqualsHelper.nullSafeEquals(this.name, that.name) && - EqualsHelper.nullSafeEquals(this.childNodeId, that.childNodeId)); - } - else - { - return false; - } - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMHistoryLinkEntity.java b/source/java/org/alfresco/repo/domain/avm/AVMHistoryLinkEntity.java deleted file mode 100644 index 6f393c9fef..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMHistoryLinkEntity.java +++ /dev/null @@ -1,66 +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 . - */ -package org.alfresco.repo.domain.avm; - -import java.io.Serializable; - - -/** - * Entity bean for avm_history_links table - * - * @author janv - * @since 3.2 - */ -public class AVMHistoryLinkEntity implements Serializable -{ - private static final long serialVersionUID = 1578072747215533879L; - - private Long ancestorNodeId; - private Long descendentNodeId; - - public AVMHistoryLinkEntity() - { - // default constructor - } - public AVMHistoryLinkEntity(Long ancestorNodeId, Long descendentNodeId) - { - this.ancestorNodeId = ancestorNodeId; - this.descendentNodeId = descendentNodeId; - } - - public Long getDescendentNodeId() - { - return descendentNodeId; - } - - public void setDescendentNodeId(Long descendentNodeId) - { - this.descendentNodeId = descendentNodeId; - } - - public Long getAncestorNodeId() - { - return ancestorNodeId; - } - - public void setAncestorNodeId(Long ancestorNodeId) - { - this.ancestorNodeId = ancestorNodeId; - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMLockDAO.java b/source/java/org/alfresco/repo/domain/avm/AVMLockDAO.java deleted file mode 100644 index 0a49346f46..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMLockDAO.java +++ /dev/null @@ -1,46 +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 . - */ -package org.alfresco.repo.domain.avm; - -import java.util.Map; - -/** - * DAO service to remove AVM locks. - * - * Added here for now, since this is currently an WCM-specific use-case to optimise lock removal - * based on matching path (bypassing the Attribute Service -> PropVal DAO). See also AbstractPropertyValueDAOImpl. - * Affected table is currently: - * - * alf_prop_unique_ctx - * - * @author janv - * @since 3.4 - */ -public interface AVMLockDAO -{ - /** - * Remove all locks for a specific AVM store that start with a given directory path - * that also optionally match a map of lock data entries. - * - * @param avmStore the name of the AVM store - * @param dirPath optional - start with given directory path or null to match all - * @param lockDataToMatch optional - lock data to match (note: all entries must match) or null/empty to match all - */ - public void removeLocks(String avmStore, String dirPath, final Map lockDataToMatch); -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMMergeLinkEntity.java b/source/java/org/alfresco/repo/domain/avm/AVMMergeLinkEntity.java deleted file mode 100644 index c895a718d8..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMMergeLinkEntity.java +++ /dev/null @@ -1,63 +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 . - */ -package org.alfresco.repo.domain.avm; - - -/** - * Entity bean for avm_merge_links table - * - * @author janv - * @since 3.2 - */ -public class AVMMergeLinkEntity -{ - private Long mergeFromNodeId; - private Long mergeToNodeId; - - public AVMMergeLinkEntity() - { - // default constructor - } - - public AVMMergeLinkEntity(Long mergeFromNodeId, Long mergeToNodeId) - { - this.mergeFromNodeId = mergeFromNodeId; - this.mergeToNodeId = mergeToNodeId; - } - - public Long getMergeFromNodeId() - { - return mergeFromNodeId; - } - - public void setMergeFromNodeId(Long mergeFromNodeId) - { - this.mergeFromNodeId = mergeFromNodeId; - } - - public Long getMergeToNodeId() - { - return mergeToNodeId; - } - - public void setMergeToNodeId(Long mergeToNodeId) - { - this.mergeToNodeId = mergeToNodeId; - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMNodeAspectEntity.java b/source/java/org/alfresco/repo/domain/avm/AVMNodeAspectEntity.java deleted file mode 100644 index 0bb78ee35f..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMNodeAspectEntity.java +++ /dev/null @@ -1,66 +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 . - */ -package org.alfresco.repo.domain.avm; - - -/** - * Entity bean for avm_aspects table - * - * @author janv - * @since 3.2 - */ - -public class AVMNodeAspectEntity -{ - public static final Long CONST_LONG_ZERO = new Long(0L); - - private Long nodeId; - private Long qnameId; - - public AVMNodeAspectEntity() - { - // default constructor - } - - public AVMNodeAspectEntity(Long nodeId, Long qnameId) - { - this.nodeId = nodeId; - this.qnameId = qnameId; - } - - public Long getNodeId() - { - return nodeId; - } - - public void setNodeId(Long nodeId) - { - this.nodeId = nodeId; - } - - public Long getQnameId() - { - return qnameId; - } - - public void setQnameId(Long qnameId) - { - this.qnameId = qnameId; - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMNodeChildEntryEntity.java b/source/java/org/alfresco/repo/domain/avm/AVMNodeChildEntryEntity.java deleted file mode 100644 index 8f3fcab8c8..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMNodeChildEntryEntity.java +++ /dev/null @@ -1,80 +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 . - */ -package org.alfresco.repo.domain.avm; - - -/** - * Entity bean for avm_child_entries table - * - * @author janv - * @since 3.2 - */ - -public class AVMNodeChildEntryEntity -{ - public static final Long CONST_LONG_ZERO = new Long(0L); - - private Long parentNodeId; - private String name; - private Long childNodeId; - - public AVMNodeChildEntryEntity() - { - // default constructor - } - - /* - public AVMNodeChildEntryEntity(Long parentNodeId, String name, Long childNodeId) - { - this.parentNodeId = parentNodeId; - this.name = name; - this.childNodeId = childNodeId; - } - */ - - public Long getParentNodeId() - { - return parentNodeId; - } - - public void setParentNodeId(Long parentNodeId) - { - this.parentNodeId = parentNodeId; - } - - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - } - - public Long getChildId() - { - return childNodeId; - } - - public void setChildNodeId(Long childNodeId) - { - this.childNodeId = childNodeId; - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMNodeDAO.java b/source/java/org/alfresco/repo/domain/avm/AVMNodeDAO.java deleted file mode 100644 index beded68321..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMNodeDAO.java +++ /dev/null @@ -1,133 +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 . - */ -package org.alfresco.repo.domain.avm; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.service.namespace.QName; -import org.springframework.dao.ConcurrencyFailureException; - -/** - * DAO services for - * avm_nodes, - * avm_aspects, - * avm_node_properties - * tables - * - * @author janv - * @since 3.2 - */ -public interface AVMNodeDAO -{ - // - // AVM Nodes - // - - public AVMNodeEntity createNode(AVMNodeEntity nodeEntity); - - public AVMNodeEntity getNode(long nodeId); - - public void updateNode(AVMNodeEntity nodeEntity); - - public void updateNodeModTimeAndGuid(AVMNodeEntity nodeEntity); - - public void updateNodeModTimeAndContentData(AVMNodeEntity nodeEntity); - - public List getNodesNewInStore(long storeId); - - public List getLayeredNodesNewInStore(long storeId); - - public List getLayeredNodesNewInStoreIDs(long storeId); - - public List getNodeOrphans(int maxSize); - - public void updateNodesClearNewInStore(long storeId); - - public void deleteNode(long nodeId); - - public List getAllLayeredDirectories(); - - public List getAllLayeredFiles(); - - public void clearNodeEntityCache(); - - /** - * Get all content urls in the AVM Repository. - * @param contentUrlHandler the handler that will be called with the URLs - */ - public void getContentUrls(ContentUrlHandler handler); - - /** - * A callback handler for iterating over the content URLs - */ - public interface ContentUrlHandler - { - void handle(String contentUrl); - } - - - // - // AVM Node Aspects - // - - /** - * Add aspect to given Node - * - * @param nodeId the unique ID of the node entity - * @param qname the qname - * @throws ConcurrencyFailureException if the aspect already exists - */ - public void createAspect(long nodeId, QName qname); - - /** - * Get set of aspects for given Node - * - * @param nodeId the unique ID of the node entity - * @return the set of qnames (never null) - * @throws AlfrescoRuntimeException if the ID provided is invalid - */ - public Set getAspects(long nodeId); - - /** - * Remove aspect from given Node - * - * @param nodeId the unique ID of the node entity - * @param qnameId the qname - * @throws ConcurrencyFailureException if the aspect does not exist - */ - public void deleteAspect(long nodeId, QName qname); - - public void deleteAspects(long nodeId); - - // - // AVM Node Properties - // - - public void createOrUpdateNodeProperty(long nodeId, QName qname, PropertyValue value); - - public Map getNodeProperties(long nodeId); - - public void deleteNodeProperty(long nodeId, QName qname); - - public void deleteNodeProperties(long nodeId); -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMNodeEntity.java b/source/java/org/alfresco/repo/domain/avm/AVMNodeEntity.java deleted file mode 100644 index 3498390199..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMNodeEntity.java +++ /dev/null @@ -1,419 +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 . - */ -package org.alfresco.repo.domain.avm; - -import java.io.Serializable; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.avm.AVMNodeType; -import org.alfresco.util.EqualsHelper; - -/** - * Entity bean for avm_nodes table. - *

- * - * @author janv - * @since 3.2 - */ -public class AVMNodeEntity implements Serializable -{ - private static final long serialVersionUID = 1L; - private Long id; - private Long version; - private Integer type; - private String classType; - private Long storeNewId; - private Long aclId; - private Long layerId; - private String guid; - private boolean isRoot; - private Integer deletedType; - private String indirection; - private Integer indirectionVersion; - private boolean primaryIndirection; - private boolean opacity; - private String contentUrl; - private String mimetype; - private String encoding; - private Long length; - - // basic attributes - private String owner; - private String creator; - private Long createdDate; - private String modifier; - private Long modifiedDate; - private Long accessDate; - - private Long vers; // for concurrency control - - - public Long getId() - { - return id; - } - - public void setId(Long id) - { - this.id = id; - } - - public String getClassType() - { - return classType; - } - - public void setClassType(String classType) - { - this.classType = classType; - - this.type = null; - if (classType != null) - { - if (classType.equals("plainfile")) - { - type = AVMNodeType.PLAIN_FILE; - } - else if (classType.equals("plaindirectory")) - { - type = AVMNodeType.PLAIN_DIRECTORY; - } - else if (classType.equals("layeredfile")) - { - type = AVMNodeType.LAYERED_FILE; - } - else if (classType.equals("layereddirectory")) - { - type = AVMNodeType.LAYERED_DIRECTORY; - } - else if (classType.equals("deletednode")) - { - type = AVMNodeType.DELETED_NODE; - } - else - { - // belts-and-braces - throw new AlfrescoRuntimeException("Unexpected node class_type: "+classType); - } - } - } - - public int getType() - { - return type; - } - - public void setType(Integer type) - { - this.type = type; - - this.classType = null; - if (type != null) - { - switch (type) - { - case AVMNodeType.PLAIN_FILE : - classType = "plainfile"; - break; - case AVMNodeType.PLAIN_DIRECTORY : - classType = "plaindirectory"; - break; - case AVMNodeType.LAYERED_FILE : - classType = "layeredfile"; - break; - case AVMNodeType.LAYERED_DIRECTORY : - classType = "layereddirectory"; - break; - case AVMNodeType.DELETED_NODE : - classType = "deletednode"; - break; - default: - // belts-and-braces - throw new AlfrescoRuntimeException("Unexpected node type: "+type); - } - } - } - - public Long getVersion() - { - return version; - } - - public void setVersion(Long version) - { - this.version = version; - } - - public Long getStoreNewId() - { - return storeNewId; - } - - public void setStoreNewId(Long storeNewId) - { - this.storeNewId = storeNewId; - } - - public Long getAclId() - { - return aclId; - } - - public void setAclId(Long aclId) - { - this.aclId = aclId; - } - - public Long getLayerId() - { - return layerId; - } - - public void setLayerId(Long layerId) - { - this.layerId = layerId; - } - - public String getGuid() - { - return guid; - } - - public void setGuid(String guid) - { - this.guid = guid; - } - - public boolean isRoot() - { - return isRoot; - } - - public void setRoot(Boolean isRoot) - { - this.isRoot = (isRoot == null ? false : isRoot); - } - - public Integer getDeletedType() - { - return deletedType; - } - - public void setDeletedType(Integer deletedType) - { - this.deletedType = deletedType; - } - - public String getIndirection() - { - return indirection; - } - - public void setIndirection(String indirection) - { - this.indirection = indirection; - } - - public Integer getIndirectionVersion() - { - return indirectionVersion; - } - - public void setIndirectionVersion(Integer indirectionVersion) - { - this.indirectionVersion = indirectionVersion; - } - - public boolean isPrimaryIndirection() - { - return primaryIndirection; - } - - public void setPrimaryIndirection(Boolean primaryIndirection) - { - this.primaryIndirection = (primaryIndirection == null ? false : primaryIndirection); - } - - public boolean getOpacity() - { - return opacity; - } - - public void setOpacity(Boolean opacity) - { - this.opacity = (opacity == null ? false : opacity); - } - - public String getContentUrl() - { - return contentUrl; - } - - public void setContentUrl(String contentUrl) - { - this.contentUrl = contentUrl; - } - - public String getMimetype() - { - return mimetype; - } - - public void setMimetype(String mimetype) - { - this.mimetype = mimetype; - } - - public String getEncoding() - { - return encoding; - } - - public void setEncoding(String encoding) - { - this.encoding = encoding; - } - - public Long getLength() - { - return length; - } - - public void setLength(Long length) - { - this.length = length; - } - - public String getOwner() - { - return owner; - } - - public void setOwner(String owner) - { - this.owner = owner; - } - - public String getCreator() - { - return creator; - } - - public void setCreator(String creator) - { - this.creator = creator; - } - - public Long getCreatedDate() - { - return createdDate; - } - - public void setCreatedDate(Long createdDate) - { - this.createdDate = createdDate; - } - - public String getModifier() - { - return modifier; - } - - public void setModifier(String modifier) - { - this.modifier = modifier; - } - - public Long getModifiedDate() - { - return modifiedDate; - } - - public void setModifiedDate(Long modifiedDate) - { - this.modifiedDate = modifiedDate; - } - - public Long getAccessDate() - { - return accessDate; - } - - public void setAccessDate(Long accessDate) - { - this.accessDate = accessDate; - } - - public Long getVers() - { - return vers; - } - - public void setVers(Long vers) - { - this.vers = vers; - } - - public void incrementVers() - { - if (this.vers >= Long.MAX_VALUE) - { - this.vers = 0L; - } - else - { - this.vers++; - } - } - - @Override - public int hashCode() - { - return (id == null ? 0 : id.hashCode()); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - else if (obj instanceof AVMNodeEntity) - { - AVMNodeEntity that = (AVMNodeEntity) obj; - return EqualsHelper.nullSafeEquals(this.id, that.id); - } - else - { - return false; - } - } - - @Override - public String toString() - { - StringBuilder sb = new StringBuilder(512); - sb.append("AVMNodeEntity") - .append("[ ID=").append(id) - .append(", nextVersion=").append(version) - .append("]"); - return sb.toString(); - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMNodeLinksDAO.java b/source/java/org/alfresco/repo/domain/avm/AVMNodeLinksDAO.java deleted file mode 100644 index be21fcdab9..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMNodeLinksDAO.java +++ /dev/null @@ -1,109 +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 . - */ -package org.alfresco.repo.domain.avm; - -import java.util.List; - -/** - * DAO services for - * avm_child_entries, - * avm_history_links, - * avm_merge_links - * tables - * - * @author janv - * @since 3.2 - */ -public interface AVMNodeLinksDAO -{ - // - // Node Entries (parent/child) - // - - /** - * Get an entry by name and parent - */ - public void createChildEntry(long parentNodeId, String name, long childNodeId); - - /** - * Get all the children of a given parent (with optional child name pattern) - */ - public List getChildEntriesByParent(long parentNodeId, String childNamePattern); - - /** - * Get all the ChildEntries corresponding to the given child - */ - public List getChildEntriesByChild(long childNodeId); - - /** - * Get an entry by name and parent - */ - public AVMChildEntryEntity getChildEntry(long parentNodeId, String name); - - /** - * Get all the children of a given parent - * - * NOTE: pattern can use * or % (TBC) - */ - //public List findChildEntriesByParent(String parentNodeId, String childNamePattern); - - /** - * Get the entry for a given child in a given parent - */ - public AVMChildEntryEntity getChildEntry(long parentNodeId, long childNodeId); - - /** - * Specific rename 'case' only - */ - public void updateChildEntry(AVMChildEntryEntity childEntryEntity); - - /** - * Delete one - */ - public void deleteChildEntry(AVMChildEntryEntity childEntryEntity); - - /** - * Delete all children of the given parent - */ - public void deleteChildEntriesByParent(long parentNodeId); - - // - // MergeLink Entries - // - - public void createMergeLink(long mergeFromNodeId, long mergeToNodeId); - - public void deleteMergeLink(long mergeFromNodeId, long mergeToNodeId); - - public AVMMergeLinkEntity getMergeLinkByTo(long mergeToNodeId); - - public List getMergeLinksByFrom(long mergeFromNodeId); - - // - // HistoryLink Entries - // - - public void createHistoryLink(long ancestorNodeId, long descendentNodeId); - - public void deleteHistoryLink(long ancestorNodeId, long descendentNodeId); - - public AVMHistoryLinkEntity getHistoryLinkByDescendent(long descendentNodeId); - - public List getHistoryLinksByAncestor(long ancestorNodeId); -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMNodePropertyEntity.java b/source/java/org/alfresco/repo/domain/avm/AVMNodePropertyEntity.java deleted file mode 100644 index e973c27fe0..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMNodePropertyEntity.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.domain.avm; - -import org.alfresco.repo.domain.PropertyValue; - -/** - * Entity bean for avm_node_properties table. - *

- * - * @author janv - * @since 3.2 - */ -public class AVMNodePropertyEntity extends PropertyValue -{ - private static final long serialVersionUID = 1867663274306415601L; - - private Long nodeId; - private Long qnameId; - - public AVMNodePropertyEntity() - { - } - - public AVMNodePropertyEntity(long nodeId, Long qnameId, PropertyValue value) - { - setNodeId(nodeId); - setQnameId(qnameId); - - this.setActualType(value.getActualType()); - this.setBooleanValue(value.getBooleanValue()); - this.setDoubleValue(value.getDoubleValue()); - this.setFloatValue(value.getFloatValue()); - this.setLongValue(value.getLongValue()); - this.setMultiValued(value.isMultiValued()); - this.setPersistedType(value.getPersistedType()); - this.setSerializableValue(value.getSerializableValue()); - this.setStringValue(value.getStringValue()); - } - - public Long getNodeId() - { - return nodeId; - } - public void setNodeId(Long nodeId) - { - this.nodeId = nodeId; - } - public Long getQnameId() - { - return qnameId; - } - public void setQnameId(Long qnameId) - { - this.qnameId = qnameId; - } - - @Override - public int hashCode() - { - return super.hashCode(); - } - - @Override - public boolean equals(Object obj) - { - return super.equals(obj); - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMStoreDAO.java b/source/java/org/alfresco/repo/domain/avm/AVMStoreDAO.java deleted file mode 100644 index 62d064eb00..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMStoreDAO.java +++ /dev/null @@ -1,120 +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 . - */ -package org.alfresco.repo.domain.avm; - -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.service.namespace.QName; -import org.springframework.dao.ConcurrencyFailureException; - -/** - * DAO services for - * avm_stores, - * avm_store_properties - * tables - * - * @author janv - * @since 3.2 - */ -public interface AVMStoreDAO -{ - // - // AVM Stores - // - - /** - * Get an existing AVM store by Store ID - * - * @param id the unique ID of the store entity - * @return the store (never null) - * @throws AlfrescoRuntimeException if the ID provided is invalid - */ - public AVMStoreEntity getStore(long id); - - /** - * Get an existing AVM store by Root Node ID - * - * @param rootNodeId the unique ID of the root node entity - * @return the store (never null) - * @throws AlfrescoRuntimeException if the ID provided is invalid - */ - public AVMStoreEntity getStoreByRoot(long rootNodeId); - - /** - * Get an existing AVM store by name - * - * @param name the name to query for - * @return the store or null if it doesn't exist - */ - public AVMStoreEntity getStore(String name); - - /** - * Get all AVM stores - * - * @return list of stores or empty if no stores (never null) - */ - public List getAllStores(); - - /** - * Create a new AVM store - * - * @param name the name - * @return the store (never null) - * @throws ConcurrencyFailureException if the name already exists - */ - public AVMStoreEntity createStore(String name); - - /** - * Update an existing AVM store - * - * @param storeEntity the store - */ - public void updateStore(AVMStoreEntity storeEntity); - - /** - * Delete an existing AVM store - * - * @param storeEntity the store - * @throws ConcurrencyFailureException if the store does not exist - */ - public void deleteStore(long storeId); - - public void clearStoreEntityCache(); - - // - // AVM Store Properties - // - - public void createOrUpdateStoreProperty(long storeId, QName qname, PropertyValue value); - - public PropertyValue getStoreProperty(long storeId, QName qname); - - public Map getStoreProperties(long storeId); - - public Map> getStorePropertiesByKeyPattern(String uri, String localName); - - public Map getStorePropertiesByStoreAndKeyPattern(long storeId, String uri, String localName); - - public void deleteStoreProperty(long storeId, QName qname); - - public void deleteStoreProperties(long storeId); -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMStoreEntity.java b/source/java/org/alfresco/repo/domain/avm/AVMStoreEntity.java deleted file mode 100644 index b8897f72cc..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMStoreEntity.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.domain.avm; - -import org.alfresco.util.EqualsHelper; - -/** - * Entity bean for avm_stores table. - *

- * - * @author janv - * @since 3.2 - */ -public class AVMStoreEntity -{ - private Long id; - private Long nextVersion; - private String name; - private Long aclId; - private Long rootNodeId; - private Long vers; // for concurrency control - - - public Long getId() - { - return id; - } - - public void setId(Long id) - { - this.id = id; - } - - public Long getVersion() - { - return nextVersion; - } - - public void setVersion(Long version) - { - this.nextVersion = version; - } - - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - } - - public Long getRootNodeId() - { - return rootNodeId; - } - - public void setRootNodeId(Long rootNodeId) - { - this.rootNodeId = rootNodeId; - } - - public Long getAclId() - { - return aclId; - } - - public void setAclId(Long aclId) - { - this.aclId = aclId; - } - - public Long getVers() - { - return vers; - } - - public void setVers(Long vers) - { - this.vers = vers; - } - - public void incrementVers() - { - if (this.vers >= Long.MAX_VALUE) - { - this.vers = 0L; - } - else - { - this.vers++; - } - } - - @Override - public int hashCode() - { - return (name == null ? 0 : name.hashCode()); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - else if (obj instanceof AVMStoreEntity) - { - AVMStoreEntity that = (AVMStoreEntity) obj; - return EqualsHelper.nullSafeEquals(this.name, that.name); - } - else - { - return false; - } - } - - @Override - public String toString() - { - StringBuilder sb = new StringBuilder(512); - sb.append("AVMStoreEntity") - .append("[ ID=").append(id) - .append(", name=").append(name) - .append(", nextVersion=").append(nextVersion) - .append(", rootNodeId=").append(rootNodeId) - .append(", aclId=").append(aclId) - .append("]"); - return sb.toString(); - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMStorePropertyEntity.java b/source/java/org/alfresco/repo/domain/avm/AVMStorePropertyEntity.java deleted file mode 100644 index ddaa9d6252..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMStorePropertyEntity.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.domain.avm; - -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.util.EqualsHelper; - -/** - * Entity bean for avm_store_properties table. - *

- * - * @author janv - * @since 3.2 - */ -public class AVMStorePropertyEntity extends PropertyValue -{ - private static final long serialVersionUID = -3125922581571555965L; - - private Long id; - private Long avmStoreId; - private Long qnameId; - - public AVMStorePropertyEntity() - { - // default constructor - } - - public AVMStorePropertyEntity(long storeId, Long qnameId, PropertyValue value) - { - setAvmStoreId(storeId); - setQnameId(qnameId); - - this.setActualType(value.getActualType()); - this.setBooleanValue(value.getBooleanValue()); - this.setDoubleValue(value.getDoubleValue()); - this.setFloatValue(value.getFloatValue()); - this.setLongValue(value.getLongValue()); - this.setMultiValued(value.isMultiValued()); - this.setPersistedType(value.getPersistedType()); - this.setSerializableValue(value.getSerializableValue()); - this.setStringValue(value.getStringValue()); - } - - public Long getId() - { - return id; - } - public void setId(Long id) - { - this.id = id; - } - public Long getAvmStoreId() - { - return avmStoreId; - } - public void setAvmStoreId(Long avmStoreId) - { - this.avmStoreId = avmStoreId; - } - public Long getQnameId() - { - return qnameId; - } - public void setQnameId(Long qnameId) - { - this.qnameId = qnameId; - } - - @Override - public int hashCode() - { - return ((avmStoreId == null ? 0 : avmStoreId.hashCode()) + - (qnameId == null ? 0 : qnameId.hashCode())); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - else if (obj instanceof AVMStorePropertyEntity) - { - AVMStorePropertyEntity that = (AVMStorePropertyEntity) obj; - return (EqualsHelper.nullSafeEquals(this.avmStoreId, that.avmStoreId) && - EqualsHelper.nullSafeEquals(this.qnameId, that.qnameId)); - } - else - { - return false; - } - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMVersionLayeredNodeEntryEntity.java b/source/java/org/alfresco/repo/domain/avm/AVMVersionLayeredNodeEntryEntity.java deleted file mode 100644 index c520044f27..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMVersionLayeredNodeEntryEntity.java +++ /dev/null @@ -1,64 +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 . - */ -package org.alfresco.repo.domain.avm; - -import java.io.Serializable; - -/** - * Entity bean for avm_version_layered_node_entry table - * - * @author janv - * @since 3.2 - */ -public class AVMVersionLayeredNodeEntryEntity -{ - private Long versionRootId; - private String md5sum; - private String path; - - public Long getVersionRootId() - { - return versionRootId; - } - - public void setVersionRootId(Long versionRootId) - { - this.versionRootId = versionRootId; - } - - public String getMd5sum() - { - return md5sum; - } - - public void setMd5sum(String md5sum) - { - this.md5sum = md5sum; - } - - public String getPath() - { - return path; - } - - public void setPath(String path) - { - this.path = path; - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMVersionRootDAO.java b/source/java/org/alfresco/repo/domain/avm/AVMVersionRootDAO.java deleted file mode 100644 index 9a103cde61..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMVersionRootDAO.java +++ /dev/null @@ -1,128 +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 . - */ -package org.alfresco.repo.domain.avm; - -import java.util.Date; -import java.util.List; - -import org.springframework.dao.ConcurrencyFailureException; - -/** - * DAO services for avm_version_roots table - * - * @author janv - * @since 3.2 - */ -public interface AVMVersionRootDAO -{ - /** - * Create a new AVM version root - * - */ - public AVMVersionRootEntity createVersionRoot(long storeId, long rootNodeId, int version, String creator, String tag, String description); - - /** - * Update an AVM version root (tag and description only) - * - * @param vrEntity - */ - public void updateVersionRoot(AVMVersionRootEntity vrEntity); - - /** - * Delete an existing AVM version root - * - * @param vrEntity the version root entity - * @throws ConcurrencyFailureException if the ID does not exist - */ - public void deleteVersionRoot(long versionRootId); - - /** - * Get all the version roots in a given store - * - * @param store The store. - * @return A List of VersionRoots. In id order. - */ - public List getAllInStore(long storeId); - - /** - * 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 AVMVersionRootEntity getByVersionID(long storeId, int version); - - /** - * Get one from its root. - * @param root The root to match. - * @return The version root or null. - */ - public AVMVersionRootEntity getByRoot(long rootNodeId); - - /** - * 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 getByDates(long storeId, Date from, Date to); - - /** - * Get the highest numbered version in a store. - * @param store The store. - * @return The highest numbered version. - */ - public AVMVersionRootEntity getMaxVersion(long storeId); - - /** - * Get the highest numbered id from all the versions in a store. - * @param store The store. - * @return The highest numbered id. - */ - public Long getMaxVersionID(long storeId); - - public AVMVersionLayeredNodeEntryEntity createVersionLayeredNodeEntry(long versionRootId, String md5sum, String path); - - public void deleteVersionLayeredNodeEntries(long versionRootId); - - public List getVersionLayeredNodeEntries(long versionRootId); - - /** - * @param id - * @param version - * @return - */ - public List getByVersionsTo(long id, int version); - - /** - * @param id - * @param version - * @return - */ - public List getByVersionsFrom(long id, int version); - - /** - * @param id - * @param startVersion - * @param endVersion - * @return - */ - public List getByVersionsBetween(long id, int startVersion, int endVersion); -} diff --git a/source/java/org/alfresco/repo/domain/avm/AVMVersionRootEntity.java b/source/java/org/alfresco/repo/domain/avm/AVMVersionRootEntity.java deleted file mode 100644 index 850dfafefd..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AVMVersionRootEntity.java +++ /dev/null @@ -1,164 +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 . - */ -package org.alfresco.repo.domain.avm; - -import java.io.Serializable; - -import org.alfresco.util.EqualsHelper; - -/** - * Entity bean for avm_version_roots table - * - * @author janv - * @since 3.2 - */ -public class AVMVersionRootEntity implements Serializable -{ - private static final long serialVersionUID = -3373271203895368258L; - - private Long id; - private Integer version; - private Long storeId; - private Long rootNodeId; - private Long createdDate; - private String creator; - private String tag; - private String description; - - public Long getId() - { - return id; - } - - public void setId(Long id) - { - this.id = id; - } - - public Integer getVersion() - { - return version; - } - - public void setVersion(Integer version) - { - this.version = version; - } - - public Long getRootNodeId() - { - return rootNodeId; - } - - public void setRootNodeId(Long rootNodeId) - { - this.rootNodeId = rootNodeId; - } - - public Long getStoreId() - { - return storeId; - } - - public void setStoreId(Long storeId) - { - this.storeId = storeId; - } - - public Long getCreatedDate() - { - return createdDate; - } - - public void setCreatedDate(Long createdDate) - { - this.createdDate = createdDate; - } - - public String getCreator() - { - return creator; - } - - public void setCreator(String creator) - { - this.creator = creator; - } - - public String getTag() - { - return tag; - } - - public void setTag(String tag) - { - this.tag = tag; - } - - public String getDescription() - { - return description; - } - - public void setDescription(String description) - { - this.description = description; - } - - @Override - public int hashCode() - { - return (id == null ? 0 : id.hashCode()); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - else if (obj instanceof AVMVersionRootEntity) - { - AVMVersionRootEntity that = (AVMVersionRootEntity) obj; - return (EqualsHelper.nullSafeEquals(this.id, that.id)); - } - else - { - return false; - } - } - - @Override - public String toString() - { - StringBuilder sb = new StringBuilder(512); - sb.append("AVMVersionRootEntity") - .append("[ ID=").append(id) - .append(", version=").append(version) - .append(", storeId=").append(storeId) - .append(", rootNodeId=").append(rootNodeId) - .append(", createdDate=").append(createdDate) - .append(", creator=").append(creator) - .append(", tag=").append(tag) - .append(", description=").append(description) - .append("]"); - return sb.toString(); - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/AbstractAVMLockDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/AbstractAVMLockDAOImpl.java deleted file mode 100644 index a71797aab7..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AbstractAVMLockDAOImpl.java +++ /dev/null @@ -1,108 +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 . - */ -package org.alfresco.repo.domain.avm; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.avm.locking.AVMLockingServiceImpl; -import org.alfresco.repo.domain.propval.PropertyValueDAO; -import org.alfresco.util.Pair; -import org.alfresco.wcm.util.WCMUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - - -/** - * Abstract implementation for AVMLock DAO. - * - * @author janv - * @since 3.4 - */ -public abstract class AbstractAVMLockDAOImpl implements AVMLockDAO -{ - protected final Log logger = LogFactory.getLog(this.getClass()); - - private PropertyValueDAO propertyValueDAO; - - public void setPropertyValueDAO(PropertyValueDAO propertyValueDAO) - { - this.propertyValueDAO = propertyValueDAO; - } - - /** - * Default constructor. - */ - public AbstractAVMLockDAOImpl() - { - } - - /** - * {@inheritDoc} - */ - public void removeLocks(String avmStore, String dirPathToMatch, final Map lockDataToMatch) - { - Long avmLocksValueId = null; - Pair valuePair = propertyValueDAO.getPropertyValue(AVMLockingServiceImpl.KEY_AVM_LOCKS); - if (valuePair == null) - { - // No such value, so no need to delete - return; - } - avmLocksValueId = valuePair.getFirst(); - - Long avmStoreNameId = null; - valuePair = propertyValueDAO.getPropertyValue(avmStore); - if (valuePair == null) - { - // No such value, so no need to delete - return; - } - avmStoreNameId = valuePair.getFirst(); - - String lockDataStoreKey = null; - String lockDataStoreValue = null; - - if ((lockDataToMatch != null) && (lockDataToMatch.size() > 0)) - { - lockDataStoreKey = WCMUtil.LOCK_KEY_STORE_NAME; - - if ((lockDataToMatch.size() != 1) || (! lockDataToMatch.containsKey(lockDataStoreKey))) - { - throw new AlfrescoRuntimeException("Expected lockData to contain either no entries or only one entry with key: "+lockDataStoreKey); - } - - lockDataStoreValue = lockDataToMatch.get(lockDataStoreKey); - } - - int deleted = deletePropertyUniqueContexts(avmLocksValueId, avmStoreNameId, dirPathToMatch, lockDataStoreKey, lockDataStoreValue); - - // Done - if (logger.isDebugEnabled()) - { - logger.debug( - "Deleted " + deleted + " unique property contexts: \n" + - " dirPathToMatch: " + dirPathToMatch + "\n" + - " lockDataToMatch: " + lockDataToMatch); - } - } - - protected abstract int deletePropertyUniqueContexts(Long avmLocksValueId, Long avmStoreNameId, String dirPathToMatch, String lockDataStoreKey, String lockDataStoreValue); -} diff --git a/source/java/org/alfresco/repo/domain/avm/AbstractAVMNodeDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/AbstractAVMNodeDAOImpl.java deleted file mode 100644 index 9bd2dbcf75..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AbstractAVMNodeDAOImpl.java +++ /dev/null @@ -1,698 +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 . - */ -package org.alfresco.repo.domain.avm; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.repo.cache.NullCache; -import org.alfresco.repo.cache.SimpleCache; -import org.alfresco.repo.cache.lookup.EntityLookupCache; -import org.alfresco.repo.cache.lookup.EntityLookupCache.EntityLookupCallbackDAO; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.domain.qname.QNameDAO; -import org.alfresco.service.namespace.QName; -import org.springframework.dao.ConcurrencyFailureException; -import org.alfresco.util.Pair; -import org.springframework.extensions.surf.util.ParameterCheck; - -/** - * Abstract implementation for AVMNode DAO. - *

- * This provides basic services such as caching but defers to the underlying implementation - * for CRUD operations. - * - * @author janv - * @since 3.2 - */ -public abstract class AbstractAVMNodeDAOImpl implements AVMNodeDAO -{ - private static final String CACHE_REGION_AVM_NODE = "AVMNode"; - private static final String CACHE_REGION_AVM_NODE_PROP = "AVMNodeProp"; - - private final AVMNodeEntityCallbackDAO avmNodeEntityDaoCallback; - private final AVMNodePropertyEntityCallbackDAO avmNodePropEntityDaoCallback; - - private QNameDAO qnameDAO; - - /** - * Cache for the AVM node entity:
- * KEY: ID (node)
- * VALUE: AVMNodeEntity
- * VALUE KEY: None
- */ - private EntityLookupCache avmNodeCache; - - /** - * Cache for the AVM node property entity:
- * KEY: Pair of IDs (node, qname)
- * VALUE: AVMNodePropertyEntity
- * VALUE KEY: None
- */ - private EntityLookupCache, AVMNodePropertyEntity, Serializable> avmNodePropCache; - - /** - * Set the cache to use for avm_aspects lookups (optional). - * - * @param avmNodeAspectsCache - */ - private SimpleCache avmNodeAspectsCache; - - /** - * Set the cache to use for avm_nodes lookups (optional). - * - * @param avmNodeCache the cache of IDs to AVMNodeEntities - */ - public void setAvmNodeCache(SimpleCache avmNodeCache) - { - this.avmNodeCache = new EntityLookupCache( - avmNodeCache, - CACHE_REGION_AVM_NODE, - avmNodeEntityDaoCallback); - } - - /** - * Set the cache to use for avm_node_properties lookups (optional). - * - * @param avmNodePropCache the cache of IDs to AVMNodePropertyEntities - */ - public void setAvmNodePropertyCache(SimpleCache avmNodePropCache) - { - this.avmNodePropCache = new EntityLookupCache, AVMNodePropertyEntity, Serializable>( - avmNodePropCache, - CACHE_REGION_AVM_NODE_PROP, - avmNodePropEntityDaoCallback); - } - - /** - * Set the cache to use for avm_aspects lookups (optional). - * - * @param avmNodeAspectsCache - */ - public void setAvmNodeAspectsCache(SimpleCache avmNodeAspectsCache) - { - this.avmNodeAspectsCache = avmNodeAspectsCache; - } - - public void setQnameDAO(QNameDAO qnameDAO) - { - this.qnameDAO = qnameDAO; - } - - - /** - * Default constructor. - *

- * This sets up the DAO accessors to bypass any caching to handle the case where the caches are not - * supplied in the setters. - */ - @SuppressWarnings("unchecked") - public AbstractAVMNodeDAOImpl() - { - this.avmNodeEntityDaoCallback = new AVMNodeEntityCallbackDAO(); - this.avmNodeCache = new EntityLookupCache(avmNodeEntityDaoCallback); - - this.avmNodePropEntityDaoCallback = new AVMNodePropertyEntityCallbackDAO(); - this.avmNodePropCache = new EntityLookupCache, AVMNodePropertyEntity, Serializable>(avmNodePropEntityDaoCallback); - - this.avmNodeAspectsCache = (SimpleCache)new NullCache(); - } - - public AVMNodeEntity createNode(AVMNodeEntity nodeEntity) - { - ParameterCheck.mandatory("nodeEntity", nodeEntity); - - nodeEntity.setVers(0L); - - Pair entityPair = avmNodeCache.getOrCreateByValue(nodeEntity); - return entityPair.getSecond(); - } - - /** - * {@inheritDoc} - */ - public AVMNodeEntity getNode(long nodeId) - { - Pair entityPair = avmNodeCache.getByKey(nodeId); - if (entityPair == null) - { - // cache-only operation: belts-and-braces - avmNodeCache.removeByKey(nodeId); - - throw new ConcurrencyFailureException("getNode: "+nodeId); - } - return entityPair.getSecond(); - } - - /** - * {@inheritDoc} - */ - public void clearNodeEntityCache() - { - avmNodeCache.clear(); - } - - /** - * {@inheritDoc} - */ - public void updateNode(AVMNodeEntity nodeEntity) - { - ParameterCheck.mandatory("nodeEntity", nodeEntity); - ParameterCheck.mandatory("nodeEntity.getId()", nodeEntity.getId()); - ParameterCheck.mandatory("nodeEntity.getVers()", nodeEntity.getVers()); - - int updated = avmNodeCache.updateValue(nodeEntity.getId(), nodeEntity); - if (updated < 1) - { - throw new ConcurrencyFailureException("AVMNode with ID (" + nodeEntity.getId() + ") no longer exists or has been updated concurrently"); - } - } - - /** - * {@inheritDoc} - * @deprecated - */ - public void updateNodeModTimeAndGuid(AVMNodeEntity nodeEntity) - { - ParameterCheck.mandatory("nodeEntity", nodeEntity); - ParameterCheck.mandatory("nodeEntity.getId()", nodeEntity.getId()); - ParameterCheck.mandatory("nodeEntity.getGuid()", nodeEntity.getGuid()); - ParameterCheck.mandatory("nodeEntity.getModifiedDate()", nodeEntity.getModifiedDate()); - ParameterCheck.mandatory("nodeEntity.getVers()", nodeEntity.getVers()); - - int updated = updateNodeEntityModTimeAndGuid(nodeEntity); - if (updated < 1) - { - throw new ConcurrencyFailureException("AVMNode with ID (" + nodeEntity.getId() + ") no longer exists or has been updated concurrently"); - } - - // update cache - avmNodeCache.removeByKey(nodeEntity.getId()); - avmNodeCache.getByKey(nodeEntity.getId()); - } - - /** - * {@inheritDoc} - * @deprecated - */ - public void updateNodeModTimeAndContentData(AVMNodeEntity nodeEntity) - { - ParameterCheck.mandatory("nodeEntity", nodeEntity); - ParameterCheck.mandatory("nodeEntity.getId()", nodeEntity.getId()); - ParameterCheck.mandatory("nodeEntity.getModifiedDate()", nodeEntity.getModifiedDate()); - ParameterCheck.mandatory("nodeEntity.getVers()", nodeEntity.getVers()); - - int updated = updateNodeEntityModTimeAndContentData(nodeEntity); - if (updated < 1) - { - throw new ConcurrencyFailureException("AVMNode with ID (" + nodeEntity.getId() + ") no longer exists or has been updated concurrently"); - } - - // update cache - avmNodeCache.removeByKey(nodeEntity.getId()); - avmNodeCache.getByKey(nodeEntity.getId()); - } - - /** - * {@inheritDoc} - */ - public List getNodesNewInStore(long storeId) - { - return getNodeEntitiesNewInStore(storeId); - } - - /** - * {@inheritDoc} - */ - public List getLayeredNodesNewInStore(long storeId) - { - return getLayeredNodeEntitiesNewInStore(storeId); - } - - /** - * {@inheritDoc} - */ - public List getLayeredNodesNewInStoreIDs(long storeId) - { - return getLayeredNodeEntityIdsNewInStore(storeId); - } - - /** - * {@inheritDoc} - */ - public List getNodeOrphans(int maxSize) - { - return getNodeEntityOrphans(maxSize); - } - - /** - * {@inheritDoc} - */ - public void updateNodesClearNewInStore(long storeId) - { - updateNodeEntitiesClearNewInStore(storeId); - } - - /** - * {@inheritDoc} - */ - public void deleteNode(long nodeId) - { - Pair entityPair = avmNodeCache.getByKey(nodeId); - if (entityPair == null) - { - return; - } - - int deleted = avmNodeCache.deleteByKey(nodeId); - if (deleted < 1) - { - throw new ConcurrencyFailureException("AVMNode with ID " + nodeId + " no longer exists"); - } - } - - /** - * {@inheritDoc} - */ - public List getAllLayeredDirectories() - { - return getAllLayeredDirectoryNodeEntities(); - } - - /** - * {@inheritDoc} - */ - public List getAllLayeredFiles() - { - return getAllLayeredFileNodeEntities(); - } - - /** - * {@inheritDoc} - */ - public void getContentUrls(ContentUrlHandler handler) - { - getPlainFileContentUrls(handler); - } - - /** - * Callback for avm_nodes DAO - */ - private class AVMNodeEntityCallbackDAO implements EntityLookupCallbackDAO - { - private final Pair convertEntityToPair(AVMNodeEntity nodeEntity) - { - if (nodeEntity == null) - { - return null; - } - else - { - return new Pair(nodeEntity.getId(), nodeEntity); - } - } - - public Serializable getValueKey(AVMNodeEntity value) - { - return null; - } - - public Pair createValue(AVMNodeEntity value) - { - AVMNodeEntity entity = createNodeEntity(value); - return convertEntityToPair(entity); - } - - public Pair findByKey(Long key) - { - AVMNodeEntity entity = getNodeEntity(key); - return convertEntityToPair(entity); - } - - public Pair findByValue(AVMNodeEntity value) - { - if ((value != null) && (value.getId() != null)) - { - return findByKey(value.getId()); - } - return null; - } - - public int updateValue(Long key, AVMNodeEntity value) - { - return updateNodeEntity(value); - } - - public int deleteByKey(Long key) - { - return deleteNodeEntity(key); - } - - public int deleteByValue(AVMNodeEntity value) - { - // TODO - throw new UnsupportedOperationException("deleteByValue(AVMNodeEntity)"); - } - } - - protected abstract AVMNodeEntity createNodeEntity(AVMNodeEntity nodeEntity); - protected abstract AVMNodeEntity getNodeEntity(long nodeId); - protected abstract int updateNodeEntity(AVMNodeEntity nodeEntity); - protected abstract int updateNodeEntityModTimeAndGuid(AVMNodeEntity nodeEntity); - protected abstract int updateNodeEntityModTimeAndContentData(AVMNodeEntity nodeEntity); - protected abstract int deleteNodeEntity(long nodeId); - protected abstract void updateNodeEntitiesClearNewInStore(long storeId); - protected abstract List getNodeEntitiesNewInStore(long storeId); - protected abstract List getLayeredNodeEntitiesNewInStore(long storeId); - protected abstract List getLayeredNodeEntityIdsNewInStore(long storeId); - protected abstract List getNodeEntityOrphans(int maxSize); - protected abstract List getAllLayeredDirectoryNodeEntities(); - protected abstract List getAllLayeredFileNodeEntities(); - protected abstract void getPlainFileContentUrls(ContentUrlHandler handler); - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public Set getAspects(long nodeId) - { - Set aspects = (Set)avmNodeAspectsCache.get(nodeId); - if (aspects != null) - { - return aspects; - } - - Set aspectQNames = null; - - // Get it from the DB - List aspectIds = getAspectEntities(nodeId); - if (aspectIds != null) - { - // Convert to QNames - aspectQNames = qnameDAO.convertIdsToQNames(new HashSet(aspectIds)); - } - else - { - aspectQNames = new HashSet(0); - } - - // Cache it - avmNodeAspectsCache.put(nodeId, aspectQNames); - - return aspectQNames; - } - - /** - * {@inheritDoc} - */ - public void createAspect(long nodeId, QName qname) - { - Set aspects = getAspects(nodeId); - if (aspects.contains(qname)) - { - return; - } - - // Get the persistent ID for the QName - Pair qnamePair = qnameDAO.getOrCreateQName(qname); - if (qnamePair != null) - { - Long qnameId = qnamePair.getFirst(); - createAspectEntity(nodeId, qnameId); - - // Cache it - aspects.add(qname); - avmNodeAspectsCache.put(new Long(nodeId), aspects); - } - } - - /** - * {@inheritDoc} - */ - public void deleteAspect(long nodeId, QName qname) - { - Set aspects = getAspects(nodeId); - if (! aspects.contains(qname)) - { - return; - } - - // Get the persistent ID for the QName - Pair qnamePair = qnameDAO.getQName(qname); - if (qnamePair != null) - { - Long qnameId = qnamePair.getFirst(); - - int deleted = deleteAspectEntity(nodeId, qnameId); - if (deleted < 1) - { - throw new ConcurrencyFailureException("AVMNodeAspect (" + nodeId + ", " + qnameId + ") no longer exists"); - } - - // Remove from cache - aspects.remove(qname); - avmNodeAspectsCache.put(new Long(nodeId), aspects); - } - } - - /** - * {@inheritDoc} - */ - public void deleteAspects(long nodeId) - { - Set naEntities = getAspects(nodeId); - if (naEntities.size() == 0) - { - return; - } - - int deleted = deleteAspectEntities(nodeId); - if (deleted < 1) - { - throw new ConcurrencyFailureException("AVMNodeAspects for node ID " + nodeId + " no longer exist"); - } - - // Remove from cache - avmNodeAspectsCache.remove(nodeId); - } - - protected abstract List getAspectEntities(long nodeId); - protected abstract void createAspectEntity(long nodeId, long qnameId); - protected abstract int deleteAspectEntity(long nodeId, long qnameId); - protected abstract int deleteAspectEntities(long nodeId); - - /** - * {@inheritDoc} - */ - public void createOrUpdateNodeProperty(long nodeId, QName qname, PropertyValue value) - { - ParameterCheck.mandatory("qname", qname); - - // Get the persistent ID for the QName - Pair qnamePair = qnameDAO.getOrCreateQName(qname); - Long qnameId = qnamePair.getFirst(); - - AVMNodePropertyEntity propEntity = new AVMNodePropertyEntity(nodeId, qnameId, value); - - Pair key = new Pair(nodeId, propEntity.getQnameId()); - Pair, AVMNodePropertyEntity> entityPair = avmNodePropCache.getByKey(key); - - if (entityPair != null) - { - int updated = avmNodePropCache.updateValue(key, propEntity); - if (updated < 1) - { - throw new ConcurrencyFailureException("AVMNodePropertyEntity with key (" + propEntity.getNodeId() + ", " + propEntity.getQnameId() + ") no longer exists"); - } - } - else - { - avmNodePropCache.getOrCreateByValue(propEntity); - } - } - - /** - * {@inheritDoc} - */ - /* - public AVMNodePropertyEntity getNodeProperty(long nodeId, QName qname) - { - // Get the persistent ID for the QName - Pair qnamePair = qnameDAO.getQName(qname); - if (qnamePair != null) - { - Long qnameId = qnamePair.getFirst(); - - Pair key = new Pair(nodeId, qnameId); - Pair, AVMNodePropertyEntity> entityPair = avmNodePropCache.getByKey(key); - if (entityPair == null) - { - return null; - } - return entityPair.getSecond(); - } - } - */ - - /** - * {@inheritDoc} - */ - public Map getNodeProperties(long nodeId) - { - // TODO not via cache - List npEntities = getNodePropertyEntities(nodeId); - Map nProps = new HashMap(npEntities.size()); - - for (AVMNodePropertyEntity npEntity : npEntities) - { - Pair qnamePair = qnameDAO.getQName(npEntity.getQnameId()); - if (qnamePair != null) - { - nProps.put(qnamePair.getSecond(), npEntity); - } - } - - return nProps; - } - - /** - * {@inheritDoc} - */ - public void deleteNodeProperty(long nodeId, QName qname) - { - // Get the persistent ID for the QName - Pair qnamePair = qnameDAO.getQName(qname); - if (qnamePair != null) - { - Long qnameId = qnamePair.getFirst(); - - Pair key = new Pair(nodeId, qnameId); - Pair, AVMNodePropertyEntity> entityPair = avmNodePropCache.getByKey(key); - if (entityPair == null) - { - return; - } - - int deleted = avmNodePropCache.deleteByKey(key); - if (deleted < 1) - { - throw new ConcurrencyFailureException("AVMNodeProperty (" + nodeId + ", " + qnameId + ") no longer exists"); - } - } - } - - /** - * {@inheritDoc} - */ - public void deleteNodeProperties(long nodeId) - { - Map nProps = getNodeProperties(nodeId); - if (nProps.size() == 0) - { - return; - } - - for (QName propQName : nProps.keySet()) - { - deleteNodeProperty(nodeId, propQName); - } - - // TODO single delete + cache(s) - /* - int deleted = deleteNodePropertyEntities(nodeId); - if (deleted < 1) - { - throw new ConcurrencyFailureException("AVMNodeProperties for node ID " + nodeId + " no longer exist"); - } - - // TODO clear node property cache for this node id - */ - } - - /** - * Callback for avm_node_properties DAO - */ - private class AVMNodePropertyEntityCallbackDAO implements EntityLookupCallbackDAO, AVMNodePropertyEntity, Serializable> - { - private final Pair, AVMNodePropertyEntity> convertEntityToPair(AVMNodePropertyEntity nodePropEntity) - { - if (nodePropEntity == null) - { - return null; - } - else - { - Pair key = new Pair(nodePropEntity.getNodeId(), nodePropEntity.getQnameId()); - return new Pair, AVMNodePropertyEntity>(key, nodePropEntity); - } - } - - public Serializable getValueKey(AVMNodePropertyEntity value) - { - return null; - } - - public Pair, AVMNodePropertyEntity> createValue(AVMNodePropertyEntity value) - { - insertNodePropertyEntity(value); - return convertEntityToPair(value); - } - - public Pair, AVMNodePropertyEntity> findByKey(Pair key) - { - AVMNodePropertyEntity entity = getNodePropertyEntity(key.getFirst(), key.getSecond()); - return convertEntityToPair(entity); - } - - public Pair, AVMNodePropertyEntity> findByValue(AVMNodePropertyEntity value) - { - if ((value.getNodeId() != null) && (value.getQnameId() != null)) - { - return findByKey(new Pair(value.getNodeId(), value.getQnameId())); - } - return null; - } - - public int updateValue(Pair key, AVMNodePropertyEntity value) - { - return updateNodePropertyEntity(value); - } - - public int deleteByKey(Pair key) - { - return deleteNodePropertyEntity(key.getFirst(), key.getSecond()); - } - - public int deleteByValue(AVMNodePropertyEntity value) - { - throw new UnsupportedOperationException("deleteByValue(AVMNodePropertyEntity)"); - } - } - - protected abstract void insertNodePropertyEntity(AVMNodePropertyEntity propEntity); - protected abstract int updateNodePropertyEntity(AVMNodePropertyEntity propEntity); - protected abstract AVMNodePropertyEntity getNodePropertyEntity(long nodeId, long qnameId); - protected abstract List getNodePropertyEntities(long nodeId); - protected abstract int deleteNodePropertyEntity(long nodeId, long qnameId); - protected abstract int deleteNodePropertyEntities(long nodeId); -} diff --git a/source/java/org/alfresco/repo/domain/avm/AbstractAVMNodeLinksDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/AbstractAVMNodeLinksDAOImpl.java deleted file mode 100644 index cd7cfa1c6d..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AbstractAVMNodeLinksDAOImpl.java +++ /dev/null @@ -1,555 +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 . - */ -package org.alfresco.repo.domain.avm; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.repo.cache.SimpleCache; -import org.alfresco.repo.cache.lookup.EntityLookupCache; -import org.alfresco.repo.cache.lookup.EntityLookupCache.EntityLookupCallbackDAO; -import org.alfresco.util.Pair; -import org.springframework.extensions.surf.util.ParameterCheck; -import org.alfresco.util.SearchLanguageConversion; -import org.springframework.dao.ConcurrencyFailureException; - -/** - * Abstract implementation for AVMNodeLinks DAO. - *

- * This provides basic services such as caching but defers to the underlying implementation - * for CRUD operations. - * - * @author janv - * @since 3.2 - */ -public abstract class AbstractAVMNodeLinksDAOImpl implements AVMNodeLinksDAO -{ - private static final String CACHE_REGION_AVM_CHILD_ENTRY = "AVMChildEntry"; - private static final String CACHE_REGION_AVM_HISTORY_LINK = "AVMHistoryLink"; - - private final AVMChildEntryEntityCallbackDAO avmChildEntryEntityDaoCallback; - private final AVMHistoryLinkEntityCallbackDAO avmHistoryLinkEntityDaoCallback; - - /** - * Cache for the AVM child entry entity:
- * KEY: ChildKey
- * VALUE: AVMChildEntryEntity
- * VALUE KEY: Pair of node IDs (parent, child)
- */ - private EntityLookupCache> avmChildEntryCache; - - /** - * Cache for the AVM history link entity:
- * KEY: Descendent ID
- * VALUE: AVMHistoryLinkEntity
- * VALUE KEY: AVMHistoryLinkEntity
- */ - private EntityLookupCache avmHistoryLinkCache; - - /** - * Set the cache to use for avm_child_entry lookups (optional). - * - * @param avmChildEntryCache the cache of IDs to AVMChildEntryEntities - */ - public void setAvmChildEntryCache(SimpleCache avmChildEntryCache) - { - this.avmChildEntryCache = new EntityLookupCache>( - avmChildEntryCache, - CACHE_REGION_AVM_CHILD_ENTRY, - avmChildEntryEntityDaoCallback); - } - - /** - * Set the cache to use for avm_history_link lookups (optional). - * - * @param avmHistoryLinkCache the cache of ID to ID (from descendent to ancestor) - */ - public void setAvmHistoryLinkCache(SimpleCache avmHistoryLinkCache) - { - this.avmHistoryLinkCache = new EntityLookupCache( - avmHistoryLinkCache, - CACHE_REGION_AVM_HISTORY_LINK, - avmHistoryLinkEntityDaoCallback); - } - - /** - * Default constructor. - *

- * This sets up the DAO accessors to bypass any caching to handle the case where the caches are not - * supplied in the setters. - */ - public AbstractAVMNodeLinksDAOImpl() - { - this.avmChildEntryEntityDaoCallback = new AVMChildEntryEntityCallbackDAO(); - this.avmChildEntryCache = new EntityLookupCache>(avmChildEntryEntityDaoCallback); - - this.avmHistoryLinkEntityDaoCallback = new AVMHistoryLinkEntityCallbackDAO(); - this.avmHistoryLinkCache = new EntityLookupCache(avmHistoryLinkEntityDaoCallback); - } - - /** - * {@inheritDoc} - */ - public void createChildEntry(long parentNodeId, String name, long childNodeId) - { - ParameterCheck.mandatory("name", name); - - AVMChildEntryEntity ceEntity = new AVMChildEntryEntity(); - ceEntity.setParentNodeId(parentNodeId); - ceEntity.setName(name); - ceEntity.setChildNodeId(childNodeId); - - Pair entityPair = avmChildEntryCache.getOrCreateByValue(ceEntity); - entityPair.getSecond(); - } - - /** - * {@inheritDoc} - */ - public AVMChildEntryEntity getChildEntry(long parentNodeId, String name) - { - ParameterCheck.mandatory("name", name); - - Pair entityPair = avmChildEntryCache.getByKey(new ChildKey(parentNodeId, name)); - if (entityPair == null) - { - return null; - } - return entityPair.getSecond(); - } - - /** - * {@inheritDoc} - */ - public List getChildEntriesByParent(long parentNodeId, String childNamePattern) - { - List result = null; - - if ((childNamePattern == null) || (childNamePattern.length() == 0)) - { - result = getChildEntryEntitiesByParent(parentNodeId); - } - else - { - String pattern = SearchLanguageConversion.convert(SearchLanguageConversion.DEF_LUCENE, SearchLanguageConversion.DEF_SQL_LIKE, childNamePattern); - result = getChildEntryEntitiesByParent(parentNodeId, pattern); - } - - if (result == null) - { - result = new ArrayList(0); - } - - return result; - } - - /** - * {@inheritDoc} - */ - public AVMChildEntryEntity getChildEntry(long parentNodeId, long childNodeId) - { - AVMChildEntryEntity ceEntity = new AVMChildEntryEntity(); - ceEntity.setParentNodeId(parentNodeId); - ceEntity.setChildNodeId(childNodeId); - - Pair entityPair = avmChildEntryCache.getByValue(ceEntity); - if (entityPair == null) - { - return null; - } - return entityPair.getSecond(); - } - - /** - * {@inheritDoc} - */ - public List getChildEntriesByChild(long childNodeId) - { - List result = getChildEntryEntitiesByChild(childNodeId); - if (result == null) - { - result = new ArrayList(0); - } - - return result; - } - - /** - * {@inheritDoc} - */ - public void updateChildEntry(AVMChildEntryEntity childEntryEntity) - { - ParameterCheck.mandatory("childEntryEntity", childEntryEntity); - ParameterCheck.mandatory("childEntryEntity.getParentNodeId()", childEntryEntity.getParentNodeId()); - ParameterCheck.mandatory("childEntryEntity.getChildId()", childEntryEntity.getChildId()); - ParameterCheck.mandatory("childEntryEntity.getName()", childEntryEntity.getName()); - - ChildKey key = new ChildKey(childEntryEntity.getParentNodeId(), childEntryEntity.getName()); - int updated = avmChildEntryCache.updateValue(key, childEntryEntity); - if (updated < 1) - { - throw new ConcurrencyFailureException("AVMChildEntry for parent/name (" + key.getParentNodeId() + ", " + key.getName() + ") no longer exists"); - } - } - - /** - * {@inheritDoc} - */ - public void deleteChildEntry(AVMChildEntryEntity childEntryEntity) - { - ParameterCheck.mandatory("childEntryEntity", childEntryEntity); - - ParameterCheck.mandatory("childEntryEntity.getParentNodeId()", childEntryEntity.getParentNodeId()); - ParameterCheck.mandatory("childEntryEntity.getName()", childEntryEntity.getName()); - - ChildKey key = new ChildKey(childEntryEntity.getParentNodeId(), childEntryEntity.getName()); - Pair entityPair = avmChildEntryCache.getByKey(key); - if (entityPair == null) - { - return; - } - - int deleted = avmChildEntryCache.deleteByKey(key); - if (deleted < 1) - { - throw new ConcurrencyFailureException("AVMChildEntry for parent/name (" + key.getParentNodeId() + ", " + key.getName() + ") no longer exists"); - } - } - - /** - * {@inheritDoc} - */ - public void deleteChildEntriesByParent(long parentNodeId) - { - List ceEntities = getChildEntriesByParent(parentNodeId, null); - if (ceEntities.size() == 0) - { - return; - } - - for (AVMChildEntryEntity ceEntity : ceEntities) - { - deleteChildEntry(ceEntity); - } - - // TODO single delete + cache(s) - - /* - int deleted = deleteChildEntryEntities(parentNodeId); - if (deleted < 1) - { - throw new ConcurrencyFailureException("AVMChildEntries for parent node ID " + parentNodeId + " no longer exist"); - } - - // TODO clear child entry cache for this parent node id - */ - } - - private static class ChildKey implements Serializable - { - private static final long serialVersionUID = 848161072437569305L; - - /** - * The Parent Node Id - */ - private Long parentNodeId; - - /** - * The child's name. - */ - private String name; - - public ChildKey(Long parentNodeId, String name) - { - this.parentNodeId = parentNodeId; - this.name = name; - } - - public Long getParentNodeId() - { - return parentNodeId; - } - - public String getName() - { - return name; - } - - /** - * 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 parentNodeId.equals(o.getParentNodeId()) && - name.equalsIgnoreCase(o.getName()); - } - - /** - * Override of hashCode. - */ - public int hashCode() - { - return parentNodeId.hashCode() + name.toLowerCase().hashCode(); - } - } - - /** - * Callback for avm_child_entry DAO - */ - private class AVMChildEntryEntityCallbackDAO implements EntityLookupCallbackDAO> - { - private final Pair convertEntityToPair(AVMChildEntryEntity ceEntity) - { - if (ceEntity == null) - { - return null; - } - else - { - return new Pair(new ChildKey(ceEntity.getParentNodeId(), ceEntity.getName()), ceEntity); - } - } - - public Pair getValueKey(AVMChildEntryEntity value) - { - return new Pair(value.getParentNodeId(), value.getChildId()); - } - - public Pair createValue(AVMChildEntryEntity value) - { - createChildEntryEntity(value); - return convertEntityToPair(value); - } - - public Pair findByKey(ChildKey key) - { - AVMChildEntryEntity entity = getChildEntryEntity(key.getParentNodeId(), key.getName()); - return convertEntityToPair(entity); - } - - public Pair findByValue(AVMChildEntryEntity value) - { - AVMChildEntryEntity entity = getChildEntryEntity(value.getParentNodeId(), value.getChildId()); - return convertEntityToPair(entity); - } - - public int updateValue(ChildKey key, AVMChildEntryEntity value) - { - return updateChildEntryEntity(value); - } - - public int deleteByKey(ChildKey key) - { - return deleteChildEntryEntity(key.getParentNodeId(), key.getName()); - } - - public int deleteByValue(AVMChildEntryEntity value) - { - return deleteChildEntryEntity(value.getParentNodeId(), value.getChildId()); - } - } - - protected abstract List getChildEntryEntitiesByParent(long parentNodeId); - protected abstract List getChildEntryEntitiesByParent(long parentNodeId, String childNamePattern); - protected abstract List getChildEntryEntitiesByChild(long childNodeId); - - protected abstract AVMChildEntryEntity getChildEntryEntity(long parentNodeId, String name); - protected abstract AVMChildEntryEntity getChildEntryEntity(long parentNodeId, long childNodeId); - protected abstract AVMChildEntryEntity getChildEntryEntity(AVMChildEntryEntity childEntryEntity); - - protected abstract void createChildEntryEntity(AVMChildEntryEntity childEntryEntity); - - protected abstract int updateChildEntryEntity(AVMChildEntryEntity childEntryEntity); // specific rename 'case' only - - protected abstract int deleteChildEntryEntity(long parentNodeId, String name); - protected abstract int deleteChildEntryEntity(long parentNodeId, long childNodeId); - protected abstract int deleteChildEntryEntities(long parentNodeId); - - /** - * {@inheritDoc} - */ - public void createMergeLink(long mergeFromNodeId, long mergeToNodeId) - { - createMergeLinkEntity(mergeFromNodeId, mergeToNodeId); - } - - /** - * {@inheritDoc} - */ - public void deleteMergeLink(long mergeFromNodeId, long mergeToNodeId) - { - AVMMergeLinkEntity mlEntity = getMergeLinkByTo(mergeToNodeId); - if (mlEntity == null) - { - return; - } - - int deleted = deleteMergeLinkEntity(mergeFromNodeId, mergeToNodeId); - if (deleted < 1) - { - throw new ConcurrencyFailureException("AVMMergeLink (" + mergeFromNodeId + ", " + mergeToNodeId + ") no longer exists"); - } - } - - /** - * {@inheritDoc} - */ - public AVMMergeLinkEntity getMergeLinkByTo(long mergeToNodeId) - { - return getMergeLinkEntityByTo(mergeToNodeId); - } - - /** - * {@inheritDoc} - */ - public List getMergeLinksByFrom(long mergeFromNodeId) - { - return getMergeLinkEntitiesByFrom(mergeFromNodeId); - } - - protected abstract void createMergeLinkEntity(long mergeFromNodeId, long mergeToNodeId); - protected abstract int deleteMergeLinkEntity(long mergeFromNodeId, long mergeToNodeId); - protected abstract AVMMergeLinkEntity getMergeLinkEntityByTo(long mergeToNodeId); - protected abstract List getMergeLinkEntitiesByFrom(long mergeFromNodeId); - - /** - * {@inheritDoc} - */ - public void createHistoryLink(long ancestorNodeId, long descendentNodeId) - { - AVMHistoryLinkEntity hlEntity = new AVMHistoryLinkEntity(ancestorNodeId, descendentNodeId); - - avmHistoryLinkCache.getOrCreateByValue(hlEntity); // ignore return value - } - - /** - * {@inheritDoc} - */ - public void deleteHistoryLink(long ancestorNodeId, long descendentNodeId) - { - AVMHistoryLinkEntity hlEntity = new AVMHistoryLinkEntity(ancestorNodeId, descendentNodeId); - Pair entityPair = avmHistoryLinkCache.getByValue(hlEntity); - if (entityPair == null) - { - return; - } - - int deleted = avmHistoryLinkCache.deleteByValue(hlEntity); - if (deleted < 1) - { - throw new ConcurrencyFailureException("AVMHistoryLinkEntity (" + ancestorNodeId + ", " + descendentNodeId + ") no longer exists"); - } - } - - /** - * {@inheritDoc} - */ - public AVMHistoryLinkEntity getHistoryLinkByDescendent(long descendentNodeId) - { - Pair entityPair = avmHistoryLinkCache.getByKey(descendentNodeId); - if (entityPair == null) - { - return null; - } - return entityPair.getSecond(); - } - - /** - * {@inheritDoc} - */ - public List getHistoryLinksByAncestor(long ancestorNodeId) - { - // not via cache - return getHistoryLinkEntitiesByAncestor(ancestorNodeId); - } - - /** - * Callback for avm_history_link DAO - */ - private class AVMHistoryLinkEntityCallbackDAO implements EntityLookupCallbackDAO - { - private final Pair convertEntityToPair(AVMHistoryLinkEntity hlEntity) - { - if (hlEntity == null) - { - return null; - } - else - { - return new Pair(hlEntity.getDescendentNodeId(), hlEntity); - } - } - - public AVMHistoryLinkEntity getValueKey(AVMHistoryLinkEntity value) - { - return value; - } - - public Pair createValue(AVMHistoryLinkEntity value) - { - createHistoryLinkEntity(value.getAncestorNodeId(), value.getDescendentNodeId()); - return convertEntityToPair(value); - } - - public Pair findByKey(Long key) - { - AVMHistoryLinkEntity entity = getHistoryLinkEntityByDescendent(key); - return convertEntityToPair(entity); - } - - public Pair findByValue(AVMHistoryLinkEntity value) - { - AVMHistoryLinkEntity entity = getHistoryLinkEntity(value.getAncestorNodeId(), value.getDescendentNodeId()); - return convertEntityToPair(entity); - } - - public int updateValue(Long key, AVMHistoryLinkEntity value) - { - throw new UnsupportedOperationException("updateValue(Long, AVMHistoryLinkEntity"); - } - - public int deleteByKey(Long key) - { - AVMHistoryLinkEntity entity = getHistoryLinkEntityByDescendent(key); - return deleteHistoryLinkEntity(entity.getAncestorNodeId(), entity.getDescendentNodeId()); - } - - public int deleteByValue(AVMHistoryLinkEntity value) - { - return deleteHistoryLinkEntity(value.getAncestorNodeId(), value.getDescendentNodeId()); - } - } - - protected abstract void createHistoryLinkEntity(long ancestorNodeId, long descendentNodeId); - protected abstract int deleteHistoryLinkEntity(long ancestorNodeId, long descendentNodeId); - protected abstract AVMHistoryLinkEntity getHistoryLinkEntity(long ancestorNodeId, long descendentNodeId); - protected abstract AVMHistoryLinkEntity getHistoryLinkEntityByDescendent(long descendentNodeId); - protected abstract List getHistoryLinkEntitiesByAncestor(long ancestorNodeId); -} diff --git a/source/java/org/alfresco/repo/domain/avm/AbstractAVMStoreDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/AbstractAVMStoreDAOImpl.java deleted file mode 100644 index cf8fac56ce..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AbstractAVMStoreDAOImpl.java +++ /dev/null @@ -1,549 +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 . - */ -package org.alfresco.repo.domain.avm; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.cache.SimpleCache; -import org.alfresco.repo.cache.lookup.EntityLookupCache; -import org.alfresco.repo.cache.lookup.EntityLookupCache.EntityLookupCallbackDAO; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.domain.qname.QNameDAO; -import org.alfresco.service.namespace.QName; -import org.springframework.dao.ConcurrencyFailureException; -import org.alfresco.util.Pair; -import org.springframework.extensions.surf.util.ParameterCheck; - -/** - * Abstract implementation for AVMStore DAO. - *

- * This provides basic services such as caching but defers to the underlying implementation - * for CRUD operations. - * - * @author janv - * @since 3.2 - */ -public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO -{ - private static final String CACHE_REGION_AVM_STORE = "AVMStore"; - private static final String CACHE_REGION_AVM_STORE_PROP = "AVMStoreProp"; - - private final AVMStoreEntityCallbackDAO avmStoreEntityDaoCallback; - private final AVMStorePropertyEntityCallbackDAO avmStorePropEntityDaoCallback; - - private QNameDAO qnameDAO; - - /** - * Cache for the AVM store entity:
- * KEY: ID
- * VALUE: AVMStoreEntity
- * VALUE KEY: Name
- */ - private EntityLookupCache avmStoreCache; - - /** - * Cache for the AVM store property entity:
- * KEY: Pair of IDs (store, qname)
- * VALUE: AVMStorePropertyEntity
- * VALUE KEY: None
- */ - private EntityLookupCache, AVMStorePropertyEntity, Serializable> avmStorePropCache; - - /** - * Set the cache to use for avm_stores lookups (optional). - * - * @param avmStoreCache the cache of IDs to AVMStoreEntities - */ - public void setAvmStoreCache(SimpleCache avmStoreCache) - { - this.avmStoreCache = new EntityLookupCache( - avmStoreCache, - CACHE_REGION_AVM_STORE, - avmStoreEntityDaoCallback); - } - - /** - * Set the cache to use for avm_store_properties lookups (optional). - * - * @param avmStorePropCache the cache of IDs to AVMStorePropertyEntities - */ - public void setAvmStorePropertyCache(SimpleCache avmStorePropCache) - { - this.avmStorePropCache = new EntityLookupCache, AVMStorePropertyEntity, Serializable>( - avmStorePropCache, - CACHE_REGION_AVM_STORE_PROP, - avmStorePropEntityDaoCallback); - } - - public void setQnameDAO(QNameDAO qnameDAO) - { - this.qnameDAO = qnameDAO; - } - - - /** - * Default constructor. - *

- * This sets up the DAO accessors to bypass any caching to handle the case where the caches are not - * supplied in the setters. - */ - public AbstractAVMStoreDAOImpl() - { - this.avmStoreEntityDaoCallback = new AVMStoreEntityCallbackDAO(); - this.avmStoreCache = new EntityLookupCache(avmStoreEntityDaoCallback); - - this.avmStorePropEntityDaoCallback = new AVMStorePropertyEntityCallbackDAO(); - this.avmStorePropCache = new EntityLookupCache, AVMStorePropertyEntity, Serializable>(avmStorePropEntityDaoCallback); - } - - /** - * {@inheritDoc} - */ - public AVMStoreEntity createStore(String name) - { - ParameterCheck.mandatory("name", name); - - AVMStoreEntity storeEntity = new AVMStoreEntity(); - - storeEntity.setVersion(0L); - storeEntity.setName(name); - storeEntity.setVers(0L); - - Pair entityPair = avmStoreCache.getOrCreateByValue(storeEntity); - return entityPair.getSecond(); - } - - /** - * {@inheritDoc} - */ - public AVMStoreEntity getStore(long storeId) - { - Pair entityPair = avmStoreCache.getByKey(storeId); - if (entityPair == null) - { - return null; - } - return entityPair.getSecond(); - } - - /** - * {@inheritDoc} - */ - public AVMStoreEntity getStoreByRoot(long rootNodeId) - { - // TODO review - not via cache - return getStoreEntityByRoot(rootNodeId); - } - - /** - * {@inheritDoc} - */ - public AVMStoreEntity getStore(String name) - { - ParameterCheck.mandatory("name", name); - - AVMStoreEntity storeEntity = new AVMStoreEntity(); - storeEntity.setName(name); - - Pair entityPair = avmStoreCache.getByValue(storeEntity); - if (entityPair == null) - { - return null; - } - return entityPair.getSecond(); - } - - /** - * {@inheritDoc} - */ - public List getAllStores() - { - // not via cache - return getAllStoreEntities(); - } - - /** - * {@inheritDoc} - */ - public void updateStore(AVMStoreEntity storeEntity) - { - ParameterCheck.mandatory("storeEntity", storeEntity); - ParameterCheck.mandatory("storeEntity.getId()", storeEntity.getId()); - ParameterCheck.mandatory("storeEntity.getVers()", storeEntity.getVers()); - - int updated = avmStoreCache.updateValue(storeEntity.getId(), storeEntity); - if (updated < 1) - { - throw new ConcurrencyFailureException("AVMStore with ID (" + storeEntity.getId() + ") no longer exists or has been updated concurrently"); - } - } - - /** - * {@inheritDoc} - */ - public void deleteStore(long storeId) - { - Pair entityPair = avmStoreCache.getByKey(storeId); - if (entityPair == null) - { - return; - } - - int deleted = avmStoreCache.deleteByKey(storeId); - if (deleted < 1) - { - throw new ConcurrencyFailureException("AVMStore with ID " + storeId + " no longer exists"); - } - } - - /** - * Callback for avm_stores DAO - */ - private class AVMStoreEntityCallbackDAO implements EntityLookupCallbackDAO - { - private final Pair convertEntityToPair(AVMStoreEntity storeEntity) - { - if (storeEntity == null) - { - return null; - } - else - { - return new Pair(storeEntity.getId(), storeEntity); - } - } - - public String getValueKey(AVMStoreEntity value) - { - return value.getName(); - } - - public Pair createValue(AVMStoreEntity value) - { - AVMStoreEntity entity = createStoreEntity(value); - return convertEntityToPair(entity); - } - - public Pair findByKey(Long key) - { - AVMStoreEntity entity = getStoreEntity(key); - return convertEntityToPair(entity); - } - - public Pair findByValue(AVMStoreEntity value) - { - if ((value == null) || (value.getName() == null)) - { - throw new AlfrescoRuntimeException("Unexpected: AVMStoreEntity / name must not be null"); - } - return convertEntityToPair(getStoreEntity(value.getName())); - } - - public int updateValue(Long key, AVMStoreEntity value) - { - return updateStoreEntity(value); - } - - public int deleteByKey(Long key) - { - return deleteStoreEntity(key); - } - - public int deleteByValue(AVMStoreEntity value) - { - // TODO - throw new UnsupportedOperationException("deleteByValue(AVMStoreEntity)"); - } - } - - /** - * {@inheritDoc} - */ - public void clearStoreEntityCache() - { - avmStoreCache.clear(); - } - - protected abstract AVMStoreEntity getStoreEntity(long id); - protected abstract AVMStoreEntity getStoreEntity(String name); - protected abstract AVMStoreEntity getStoreEntityByRoot(long rootNodeId); - protected abstract List getAllStoreEntities(); - protected abstract AVMStoreEntity createStoreEntity(AVMStoreEntity storeEntity); - protected abstract int deleteStoreEntity(long id); - protected abstract int updateStoreEntity(AVMStoreEntity storeEntity); - - /** - * {@inheritDoc} - */ - public void createOrUpdateStoreProperty(long storeId, QName qname, PropertyValue value) - { - ParameterCheck.mandatory("qname", qname); - ParameterCheck.mandatory("value", value); - - // Get the persistent ID for the QName - Pair qnamePair = qnameDAO.getOrCreateQName(qname); - Long qnameId = qnamePair.getFirst(); - - AVMStorePropertyEntity propEntity = new AVMStorePropertyEntity(storeId, qnameId, value); - - Pair key = new Pair(storeId, propEntity.getQnameId()); - Pair, AVMStorePropertyEntity> entityPair = avmStorePropCache.getByKey(key); - - if (entityPair != null) - { - int updated = avmStorePropCache.updateValue(key, propEntity); - if (updated < 1) - { - throw new ConcurrencyFailureException("AVMStorePropertyEntity with IDs (" + propEntity.getAvmStoreId() + ", " + propEntity.getQnameId() + ") no longer exists"); - } - } - else - { - avmStorePropCache.getOrCreateByValue(propEntity); - } - } - - /** - * {@inheritDoc} - */ - public PropertyValue getStoreProperty(long storeId, QName qname) - { - // Get the persistent ID for the QName - Pair qnamePair = qnameDAO.getQName(qname); - if (qnamePair != null) - { - Long qnameId = qnamePair.getFirst(); - - Pair key = new Pair(storeId, qnameId); - Pair, AVMStorePropertyEntity> entityPair = avmStorePropCache.getByKey(key); - if (entityPair == null) - { - return null; - } - return entityPair.getSecond(); - } - return null; - } - - /** - * {@inheritDoc} - */ - public Map getStoreProperties(long storeId) - { - // not via cache - List propEntities = getStorePropertyEntities(storeId); - - Map props = new HashMap(propEntities.size()); - for (AVMStorePropertyEntity propEntity : propEntities) - { - Pair qnamePair = qnameDAO.getQName(propEntity.getQnameId()); - if (qnamePair != null) - { - props.put(qnamePair.getSecond(), propEntity); - } - } - return props; - } - - /** - * {@inheritDoc} - */ - public Map> getStorePropertiesByKeyPattern(String uriPattern, String localNamePattern) - { - ParameterCheck.mandatoryString("uriPattern", uriPattern); - ParameterCheck.mandatoryString("localNamePattern", localNamePattern); - - // not via cache - List spEntities = getStorePropertyEntitiesByKeyPattern(uriPattern, localNamePattern); - - Map> results = new HashMap>(10); - - for (AVMStorePropertyEntity spEntity : spEntities) - { - String storeName = getStore(spEntity.getAvmStoreId()).getName(); - - Pair qnamePair = qnameDAO.getQName(spEntity.getQnameId()); - if (qnamePair != null) - { - QName propQName = qnamePair.getSecond(); - - Map pairs = null; - if ((pairs = results.get(storeName)) == null) - { - pairs = new HashMap(); - results.put(storeName, pairs); - } - pairs.put(propQName, spEntity); - } - - } - return results; - } - - /** - * {@inheritDoc} - */ - public Map getStorePropertiesByStoreAndKeyPattern(long storeId, String uriPattern, String localNamePattern) - { - ParameterCheck.mandatoryString("uriPattern", uriPattern); - ParameterCheck.mandatoryString("localNamePattern", localNamePattern); - - // not via cache - List propEntities = getStorePropertyEntitiesByStoreAndKeyPattern(storeId, uriPattern, localNamePattern); - - Map props = new HashMap(propEntities.size()); - for (AVMStorePropertyEntity propEntity : propEntities) - { - Pair qnamePair = qnameDAO.getQName(propEntity.getQnameId()); - if (qnamePair != null) - { - props.put(qnamePair.getSecond(), propEntity); - } - } - return props; - } - - /** - * {@inheritDoc} - */ - public void deleteStoreProperty(long storeId, QName qname) - { - // Get the persistent ID for the QName - Pair qnamePair = qnameDAO.getQName(qname); - if (qnamePair != null) - { - Long qnameId = qnamePair.getFirst(); - - Pair key = new Pair(storeId, qnameId); - Pair, AVMStorePropertyEntity> entityPair = avmStorePropCache.getByKey(key); - if (entityPair == null) - { - return; - } - - int deleted = avmStorePropCache.deleteByKey(key); - if (deleted < 1) - { - throw new ConcurrencyFailureException("AVMStoreProperty with key (" + storeId + ", " + qnameId + ") no longer exists"); - } - } - } - - /** - * {@inheritDoc} - */ - public void deleteStoreProperties(long storeId) - { - Map props = getStoreProperties(storeId); - if (props.size() == 0) - { - return; - } - - for (QName qname : props.keySet()) - { - deleteStoreProperty(storeId, qname); - } - - // TODO single delete + cache(s) - - /* - int deleted = deleteStorePropertyEntities(storeId); - if (deleted < 1) - { - throw new ConcurrencyFailureException("AVMStoreProperties for store ID " + storeId + " no longer exist"); - } - - // TODO clear store property cache for this store id - */ - } - - /** - * Callback for avm_store_properties DAO - */ - private class AVMStorePropertyEntityCallbackDAO implements EntityLookupCallbackDAO, AVMStorePropertyEntity, Serializable> - { - private final Pair, AVMStorePropertyEntity> convertEntityToPair(AVMStorePropertyEntity storePropEntity) - { - if (storePropEntity == null) - { - return null; - } - else - { - Pair key = new Pair(storePropEntity.getAvmStoreId(), storePropEntity.getQnameId()); - return new Pair, AVMStorePropertyEntity>(key, storePropEntity); - } - } - - public Serializable getValueKey(AVMStorePropertyEntity value) - { - return null; - } - - public Pair, AVMStorePropertyEntity> createValue(AVMStorePropertyEntity value) - { - insertStorePropertyEntity(value); - return convertEntityToPair(value); - } - - public Pair, AVMStorePropertyEntity> findByKey(Pair key) - { - AVMStorePropertyEntity entity = getStorePropertyEntity(key.getFirst(), key.getSecond()); - return convertEntityToPair(entity); - } - - public Pair, AVMStorePropertyEntity> findByValue(AVMStorePropertyEntity value) - { - if ((value.getAvmStoreId() != null) && (value.getQnameId() != null)) - { - return findByKey(new Pair(value.getAvmStoreId(), value.getQnameId())); - } - return null; - } - - public int updateValue(Pair key, AVMStorePropertyEntity value) - { - return updateStorePropertyEntity(value); - } - - public int deleteByKey(Pair key) - { - return deleteStorePropertyEntity(key.getFirst(), key.getSecond()); - } - - public int deleteByValue(AVMStorePropertyEntity value) - { - throw new UnsupportedOperationException("deleteByValue(AVMStorePropertyEntity)"); - } - } - - protected abstract void insertStorePropertyEntity(AVMStorePropertyEntity propEntity); - protected abstract int updateStorePropertyEntity(AVMStorePropertyEntity propEntity); - protected abstract AVMStorePropertyEntity getStorePropertyEntity(long storeId, long qnameId); - protected abstract List getStorePropertyEntities(long storeId); - protected abstract List getStorePropertyEntitiesByKeyPattern(String uriPattern, String localNamePattern); - protected abstract List getStorePropertyEntitiesByStoreAndKeyPattern(long storeId, String uriPattern, String localNamePattern); - protected abstract int deleteStorePropertyEntity(long storeId, long qnameId); - protected abstract int deleteStorePropertyEntities(long storeId); -} diff --git a/source/java/org/alfresco/repo/domain/avm/AbstractAVMVersionRootDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/AbstractAVMVersionRootDAOImpl.java deleted file mode 100644 index 5e2613304f..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/AbstractAVMVersionRootDAOImpl.java +++ /dev/null @@ -1,314 +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 . - */ -package org.alfresco.repo.domain.avm; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.cache.NullCache; -import org.alfresco.repo.cache.SimpleCache; -import org.alfresco.util.Pair; -import org.springframework.extensions.surf.util.ParameterCheck; -import org.springframework.dao.ConcurrencyFailureException; - -/** - * Abstract implementation for AVMVersionRoot DAO. - *

- * This provides basic services such as caching but defers to the underlying implementation - * for CRUD operations. - * - * @author janv - * @since 3.2 - */ -public abstract class AbstractAVMVersionRootDAOImpl implements AVMVersionRootDAO -{ - private SimpleCache vrEntityCache; - - /** - * Set the cache to use for avm_version_roots lookups (optional). - * - * @param vrEntityCache - */ - public void setVersionRootEntityCache(SimpleCache vrEntityCache) - { - this.vrEntityCache = vrEntityCache; - } - - @SuppressWarnings("unchecked") - public AbstractAVMVersionRootDAOImpl() - { - this.vrEntityCache = (SimpleCache)new NullCache(); - } - - /** - * {@inheritDoc} - */ - public AVMVersionRootEntity createVersionRoot(long storeId, long rootNodeId, int version, String creator, String tag, String description) - { - ParameterCheck.mandatory("creator", creator); - - AVMVersionRootEntity vrEntity = new AVMVersionRootEntity(); - vrEntity.setStoreId(storeId); - vrEntity.setRootNodeId(rootNodeId); - vrEntity.setVersion(version); - vrEntity.setCreator(creator); - vrEntity.setCreatedDate(new Date().getTime()); // app server date/time - vrEntity.setTag(tag); - vrEntity.setDescription(description); - - vrEntity = createVersionRootEntity(vrEntity); - - // Cache it - vrEntityCache.put(new Pair(storeId, version), vrEntity.getId()); - vrEntityCache.put(vrEntity.getId(), vrEntity); - - return vrEntity; - } - - /** - * {@inheritDoc} - */ - public void updateVersionRoot(AVMVersionRootEntity vrEntity) - { - ParameterCheck.mandatory("vrEntity", vrEntity); - - ParameterCheck.mandatory("vrEntity.storeId", vrEntity.getStoreId()); - ParameterCheck.mandatory("vrEntity.id", vrEntity.getId()); - ParameterCheck.mandatory("vrEntity.version", vrEntity.getVersion()); - - int updated = updateVersionRootEntity(vrEntity); - if (updated != 1) - { - // unexpected number of rows affected - throw new ConcurrencyFailureException("Incorrect number of rows affected for updateVersionRoot: " + vrEntity + ": expected 1, actual " + updated); - } - - // Cache it - vrEntityCache.put(new Pair(vrEntity.getStoreId(), vrEntity.getVersion()), vrEntity.getId()); - vrEntityCache.put(vrEntity.getId(), vrEntity); - } - - /** - * {@inheritDoc} - */ - public List getAllInStore(long storeId) - { - return getAllVersionRootEntitiesByStoreId(storeId); - } - - /** - * {@inheritDoc} - */ - protected AVMVersionRootEntity getByID(long vrEntityId) - { - AVMVersionRootEntity vrEntity = (AVMVersionRootEntity) vrEntityCache.get(vrEntityId); - if (vrEntity != null) - { - return vrEntity; - } - - // Get it from the DB - vrEntity = getVersionRootEntityById(vrEntityId); - if (vrEntity != null) - { - // Cache it - vrEntityCache.put(new Pair(vrEntity.getStoreId(), vrEntity.getVersion()), vrEntity.getId()); - vrEntityCache.put(vrEntity.getId(), vrEntity); - } - - return vrEntity; - } - - /** - * {@inheritDoc} - */ - public AVMVersionRootEntity getByVersionID(long storeId, int version) - { - // Check the cache - Long vrEntityId = (Long) vrEntityCache.get(new Pair(storeId, version)); - AVMVersionRootEntity vrEntity = null; - if (vrEntityId != null) - { - vrEntity = (AVMVersionRootEntity) vrEntityCache.get(vrEntityId); - if (vrEntity != null) - { - return vrEntity; - } - } - - // Get it from the DB - vrEntity = getVersionRootEntityByStoreVersion(storeId, version); - if (vrEntity != null) - { - // Cache it - vrEntityCache.put(new Pair(vrEntity.getStoreId(), vrEntity.getVersion()), vrEntity.getId()); - vrEntityCache.put(vrEntity.getId(), vrEntity); - } - - return vrEntity; - } - - /** - * {@inheritDoc} - */ - public AVMVersionRootEntity getByRoot(long rootNodeId) - { - return getVersionRootEntityByRootNodeId(rootNodeId); - } - - /** - * {@inheritDoc} - */ - public List getByDates(long storeId, Date from, Date to) - { - if ((from != null) && (to != null)) - { - return getVersionRootEntitiesByBetween(storeId, from.getTime(), to.getTime()); - } - else if ((from == null) && (to != null)) - { - return getVersionRootEntitiesByTo(storeId, to.getTime()); - } - else if ((to == null) && (from != null)) - { - return getVersionRootEntitiesByFrom(storeId, from.getTime()); - } - else - { - throw new AlfrescoRuntimeException("getByDates: from and to are both null for store id: "+storeId); - } - } - - /** - * {@inheritDoc} - */ - public AVMVersionRootEntity getMaxVersion(long storeId) - { - return getVersionRootEntityMaxVersion(storeId); - } - - /** - * {@inheritDoc} - */ - public Long getMaxVersionID(long storeId) - { - return getVersionRootEntityMaxVersionId(storeId); - } - - /** - * {@inheritDoc} - */ - public void deleteVersionRoot(long vrEntityId) - { - AVMVersionRootEntity vrEntity = getByID(vrEntityId); - if (vrEntity == null) - { - return; - } - - int deleted = deleteVersionRootEntity(vrEntityId); - if (deleted < 1) - { - throw new ConcurrencyFailureException("AVMVersionRoot with ID " + vrEntityId + " no longer exists"); - } - - // Remove from cache - vrEntityCache.remove(new Pair(vrEntity.getStoreId(), vrEntity.getVersion())); - vrEntityCache.remove(vrEntityId); - } - - protected abstract AVMVersionRootEntity createVersionRootEntity(AVMVersionRootEntity vrEntity); - protected abstract int updateVersionRootEntity(AVMVersionRootEntity updateVersionRootEntity); - protected abstract int deleteVersionRootEntity(long vrEntityId); - protected abstract AVMVersionRootEntity getVersionRootEntityMaxVersion(long storeId); - protected abstract Long getVersionRootEntityMaxVersionId(long storeId); - protected abstract AVMVersionRootEntity getVersionRootEntityById(long vrEntityId); - protected abstract AVMVersionRootEntity getVersionRootEntityByStoreVersion(long storeId, int version); - protected abstract AVMVersionRootEntity getVersionRootEntityByRootNodeId(long rootNodeId); - protected abstract List getAllVersionRootEntitiesByStoreId(long storeId); - protected abstract List getVersionRootEntitiesByTo(long storeId, long to); - protected abstract List getVersionRootEntitiesByFrom(long storeId, long from); - protected abstract List getVersionRootEntitiesByBetween(long storeId, long from, long to); - - /** - * {@inheritDoc} - */ - public AVMVersionLayeredNodeEntryEntity createVersionLayeredNodeEntry(long versionRootId, String md5sum, String path) - { - ParameterCheck.mandatory("md5sum", md5sum); - ParameterCheck.mandatory("path", path); - - return createVersionLayeredNodeEntryEntity(versionRootId, md5sum, path); - } - - /** - * {@inheritDoc} - */ - public void deleteVersionLayeredNodeEntries(long versionRootId) - { - List vlneEntities = getVersionLayeredNodeEntries(versionRootId); - if (vlneEntities.size() == 0) - { - return; - } - - int deleted = deleteVersionLayeredNodeEntryEntities(versionRootId); - if (deleted < 1) - { - throw new ConcurrencyFailureException("AVMVersionLayeredNodeEntries with version root id " + versionRootId + " no longer exist"); - } - } - - /** - * {@inheritDoc} - */ - public List getVersionLayeredNodeEntries(long versionRootId) - { - return getVersionLayeredNodeEntryEntities(versionRootId); - } - - protected abstract AVMVersionLayeredNodeEntryEntity createVersionLayeredNodeEntryEntity(long versionRootId, String md5sum, String path); - protected abstract int deleteVersionLayeredNodeEntryEntities(long versionRootId); - protected abstract List getVersionLayeredNodeEntryEntities(long storeId); - - - protected abstract List getVersionRootEntitiesByVersionsTo(long storeId, long to); - protected abstract List getVersionRootEntitiesByVersionsFrom(long storeId, long from); - protected abstract List getVersionRootEntitiesByVersionsBetween(long storeId, long from, long to); - - public List getByVersionsTo(long id, int version) - { - return getVersionRootEntitiesByVersionsTo(id, version); - } - - public List getByVersionsFrom(long id, int version) - { - return getVersionRootEntitiesByVersionsFrom(id, version); - } - - public List getByVersionsBetween(long id, int startVersion, int endVersion) - { - return getVersionRootEntitiesByVersionsBetween(id, startVersion, endVersion); - } - - - -} diff --git a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMLockDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMLockDAOImpl.java deleted file mode 100644 index c03ff31be7..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMLockDAOImpl.java +++ /dev/null @@ -1,103 +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 . - */ -package org.alfresco.repo.domain.avm.ibatis; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.repo.cache.SimpleCache; -import org.alfresco.repo.domain.avm.AbstractAVMLockDAOImpl; -import org.alfresco.repo.domain.propval.AbstractPropertyValueDAOImpl.CachePucKey; -import org.alfresco.repo.domain.propval.PropertyUniqueContextEntity; -import org.mybatis.spring.SqlSessionTemplate; - -/** - * iBatis-specific implementation of the AVMLock DAO. - * - * @author janv - * @since 3.4 - */ -public class AVMLockDAOImpl extends AbstractAVMLockDAOImpl -{ - private static final String DELETE_MATCHING_AVM_LOCKS_1_KV ="alfresco.avm.delete_PropertyUniqueContextByValuesWithOneKV"; - private static final String DELETE_MATCHING_AVM_LOCKS_0_KV ="alfresco.avm.delete_PropertyUniqueContextByValuesWithNoKV"; - - - private SqlSessionTemplate template; - - public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) - { - this.template = sqlSessionTemplate; - } - - private SimpleCache propertyUniqueContextCache; // cluster-aware - - /** - * Set the cache to use for avm_version_roots lookups (optional). - * - * @param vrEntityCache - */ - public void setPropertyUniqueContextCache(SimpleCache propertyUniqueContextCache) - { - this.propertyUniqueContextCache = propertyUniqueContextCache; - } - - @Override - protected int deletePropertyUniqueContexts(Long avmLocksValueId, Long avmStoreNameId, String dirPathToMatch, String lockDataStoreKey, String lockDataStoreValue) - { - if (dirPathToMatch == null) - { - dirPathToMatch = "%"; - } - else if (! dirPathToMatch.endsWith("%")) - { - dirPathToMatch = dirPathToMatch + "%"; - } - - try - { - if (lockDataStoreKey != null) - { - Map params = new HashMap(5); - params.put("value1PropId", avmLocksValueId); - params.put("value2PropId", avmStoreNameId); - params.put("value3LikeStr", dirPathToMatch); - params.put("lockDataStoreKey", lockDataStoreKey); - params.put("lockDataStoreValue", lockDataStoreValue); - - return template.delete(DELETE_MATCHING_AVM_LOCKS_1_KV, params); - } - else - { - Map params = new HashMap(3); - params.put("value1PropId", avmLocksValueId); - params.put("value2PropId", avmStoreNameId); - params.put("value3LikeStr", dirPathToMatch); - - return template.delete(DELETE_MATCHING_AVM_LOCKS_0_KV, params); - } - } - finally - { - // reasonable to clear for now (eg. only used by AVMLockingService.removeLocks*) - // note: in future, if we need to support mass removal based on specific key grouping then we need to use more intelligent cache (removal) - propertyUniqueContextCache.clear(); - } - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeDAOImpl.java deleted file mode 100644 index 5e5ebb2b51..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeDAOImpl.java +++ /dev/null @@ -1,314 +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 . - */ -package org.alfresco.repo.domain.avm.ibatis; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.repo.domain.avm.AVMAspectEntity; -import org.alfresco.repo.domain.avm.AVMNodeEntity; -import org.alfresco.repo.domain.avm.AVMNodePropertyEntity; -import org.alfresco.repo.domain.avm.AbstractAVMNodeDAOImpl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.ibatis.session.ResultContext; -import org.apache.ibatis.session.ResultHandler; -import org.apache.ibatis.session.RowBounds; -import org.mybatis.spring.SqlSessionTemplate; - -/** - * iBatis-specific implementation of the AVMNode DAO. - * - * @author janv - * @since 3.2 - */ -public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl -{ - private static Log logger = LogFactory.getLog(AVMNodeDAOImpl.class); - - private static final String INSERT_AVM_NODE = "alfresco.avm.insert.insert_AVMNode"; - private static final String SELECT_AVM_NODE_BY_ID = "alfresco.avm.select_AVMNodeById"; - private static final String UPDATE_AVM_NODE = "alfresco.avm.update_AVMNode"; - private static final String UPDATE_AVM_NODE_MODTIME_AND_GUID = "alfresco.avm.update_AVMNode_modTimeAndGuid"; - private static final String UPDATE_AVM_NODE_MODTIME_AND_CDATA = "alfresco.avm.update_AVMNode_modTimeAndContentData"; - private static final String DELETE_AVM_NODE = "alfresco.avm.delete_AVMNode"; - - private static final String SELECT_AVM_NODES_NEW_IN_STORE = "alfresco.avm.select_AVMNodes_newInStore"; - private static final String SELECT_AVM_NODES_NEW_LAYERED_IN_STORE = "alfresco.avm.select_AVMNodes_newLayeredInStore"; - private static final String SELECT_AVM_NODE_IDS_NEW_LAYERED_IN_STORE = "alfresco.avm.select_AVMNodes_IDs_newLayeredInStore"; - private static final String UPDATE_AVM_NODES_CLEAR_NEW_IN_STORE = "alfresco.avm.update_AVMNodes_clearNewInStore"; - private static final String SELECT_AVM_NODES_NULL_PARENT_AND_ISROOT_TF= "alfresco.avm.select_AVMNodes_nullParentAndIsRootTF"; - private static final String SELECT_AVM_NODES_LAYERED_DIRECTORIES_AND_PRIMARY_TF = "alfresco.avm.select_AVMNodes_layeredDirectoriesAndPrimaryTF"; - private static final String SELECT_AVM_NODES_LAYERED_FILES = "alfresco.avm.select_AVMNodes_layeredFiles"; - - private static final String SELECT_AVM_CONTENT_URLS_FOR_PLAIN_FILES = "alfresco.avm.select_ContentUrlsForPlainFiles"; - - private static final String SELECT_AVM_NODE_ASPECTS = "alfresco.avm.select_AVMNodeAspects"; - private static final String INSERT_AVM_NODE_ASPECT = "alfresco.avm.insert.insert_AVMNodeAspect"; - private static final String DELETE_AVM_NODE_ASPECT = "alfresco.avm.delete_AVMNodeAspect"; - private static final String DELETE_AVM_NODE_ASPECTS = "alfresco.avm.delete_AVMNodeAspects"; - - private static final String INSERT_AVM_NODE_PROP = "alfresco.avm.insert.insert_AVMNodeProperty"; - private static final String UPDATE_AVM_NODE_PROP = "alfresco.avm.update_AVMNodeProperty"; - private static final String SELECT_AVM_NODE_PROP = "alfresco.avm.select_AVMNodeProperty"; - private static final String SELECT_AVM_NODE_PROPS = "alfresco.avm.select_AVMNodeProperties"; - private static final String DELETE_AVM_NODE_PROP = "alfresco.avm.delete_AVMNodeProperty"; - private static final String DELETE_AVM_NODE_PROPS = "alfresco.avm.delete_AVMNodeProperties"; - - - private SqlSessionTemplate template; - - public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) - { - this.template = sqlSessionTemplate; - } - - @Override - protected AVMNodeEntity createNodeEntity(AVMNodeEntity nodeEntity) - { - template.insert(INSERT_AVM_NODE, nodeEntity); - return nodeEntity; - } - - @Override - protected AVMNodeEntity getNodeEntity(long id) - { - Map params = new HashMap(1); - params.put("id", id); - return (AVMNodeEntity) template.selectOne(SELECT_AVM_NODE_BY_ID, params); - } - - @Override - protected int updateNodeEntity(AVMNodeEntity updateNodeEntity) - { - updateNodeEntity.incrementVers(); - - return template.update(UPDATE_AVM_NODE, updateNodeEntity); - } - - @Override - protected int updateNodeEntityModTimeAndGuid(AVMNodeEntity updateNodeEntity) - { - updateNodeEntity.incrementVers(); - - // partial update - return template.update(UPDATE_AVM_NODE_MODTIME_AND_GUID, updateNodeEntity); - } - - @Override - protected int updateNodeEntityModTimeAndContentData(AVMNodeEntity updateNodeEntity) - { - updateNodeEntity.incrementVers(); - - // partial update - return template.update(UPDATE_AVM_NODE_MODTIME_AND_CDATA, updateNodeEntity); - } - - @Override - protected int deleteNodeEntity(long nodeId) - { - Map params = new HashMap(1); - params.put("id", nodeId); - return template.delete(DELETE_AVM_NODE, params); - } - - @Override - protected void updateNodeEntitiesClearNewInStore(long storeId) - { - Map params = new HashMap(1); - params.put("id", storeId); - template.update(UPDATE_AVM_NODES_CLEAR_NEW_IN_STORE, params); - } - - @SuppressWarnings("unchecked") - @Override - protected List getNodeEntitiesNewInStore(long storeId) - { - Map params = new HashMap(1); - params.put("id", storeId); - return (List) template.selectList(SELECT_AVM_NODES_NEW_IN_STORE, params); - } - - @SuppressWarnings("unchecked") - @Override - protected List getLayeredNodeEntitiesNewInStore(long storeId) - { - Map params = new HashMap(1); - params.put("id", storeId); - return (List) template.selectList(SELECT_AVM_NODES_NEW_LAYERED_IN_STORE, params); - } - - @SuppressWarnings("unchecked") - @Override - protected List getLayeredNodeEntityIdsNewInStore(long storeId) - { - Map params = new HashMap(1); - params.put("id", storeId); - return (List) template.selectList(SELECT_AVM_NODE_IDS_NEW_LAYERED_IN_STORE, params); - } - - @SuppressWarnings("unchecked") - @Override - protected List getNodeEntityOrphans(int maxSize) - { - Map params = new HashMap(1); - params.put("bool", false); - - // all nodes with null parent and not a root - return (List) template.selectList(SELECT_AVM_NODES_NULL_PARENT_AND_ISROOT_TF, params, new RowBounds(0, maxSize)); - } - - @SuppressWarnings("unchecked") - @Override - protected List getAllLayeredDirectoryNodeEntities() - { - Map params = new HashMap(1); - params.put("bool", true); - - // all primary layered directories - return (List) template.selectList(SELECT_AVM_NODES_LAYERED_DIRECTORIES_AND_PRIMARY_TF, params); - } - - @SuppressWarnings("unchecked") - @Override - protected List getAllLayeredFileNodeEntities() - { - return (List) template.selectList(SELECT_AVM_NODES_LAYERED_FILES); - } - - @Override - protected void getPlainFileContentUrls(ContentUrlHandler handler) - { - CleanResultHandler resultHandler = new CleanResultHandler(handler); - - template.selectList(SELECT_AVM_CONTENT_URLS_FOR_PLAIN_FILES, resultHandler); - - if (logger.isDebugEnabled()) - { - logger.debug(" Listed " + resultHandler.total + " content URLs"); - } - } - - /** - * Row handler for cleaning content URLs - */ - private static class CleanResultHandler implements ResultHandler - { - private final ContentUrlHandler handler; - - private int total = 0; - - private CleanResultHandler(ContentUrlHandler handler) - { - this.handler = handler; - } - public void handleResult(ResultContext context) - { - handler.handle((String)context.getResultObject()); - total++; - if (logger.isDebugEnabled() && (total == 0 || (total % 1000 == 0) )) - { - logger.debug(" Listed " + total + " content URLs"); - } - } - } - - @SuppressWarnings("unchecked") - @Override - protected List getAspectEntities(long nodeId) - { - Map params = new HashMap(1); - params.put("id", nodeId); - return (List) template.selectList(SELECT_AVM_NODE_ASPECTS, params); - } - - @Override - protected void createAspectEntity(long nodeId, long qnameId) - { - AVMAspectEntity aspectEntity = new AVMAspectEntity(nodeId, qnameId); - template.insert(INSERT_AVM_NODE_ASPECT, aspectEntity); - } - - @Override - protected int deleteAspectEntity(long nodeId, long qnameId) - { - AVMAspectEntity aspectEntity = new AVMAspectEntity(nodeId, qnameId); - return template.delete(DELETE_AVM_NODE_ASPECT, aspectEntity); - } - - @Override - protected int deleteAspectEntities(long nodeId) - { - Map params = new HashMap(1); - params.put("id", nodeId); - return template.delete(DELETE_AVM_NODE_ASPECTS, params); - } - - @Override - protected void insertNodePropertyEntity(AVMNodePropertyEntity propEntity) - { - template.insert(INSERT_AVM_NODE_PROP, propEntity); - } - - @Override - protected int updateNodePropertyEntity(AVMNodePropertyEntity updatePropEntity) - { - return template.update(UPDATE_AVM_NODE_PROP, updatePropEntity); - } - - @Override - protected AVMNodePropertyEntity getNodePropertyEntity(long nodeId, long qnameId) - { - AVMNodePropertyEntity propEntity = new AVMNodePropertyEntity(); - propEntity.setNodeId(nodeId); - propEntity.setQnameId(qnameId); - - return (AVMNodePropertyEntity) template.selectOne(SELECT_AVM_NODE_PROP, propEntity); - } - - @Override - @SuppressWarnings("unchecked") - protected List getNodePropertyEntities(long nodeId) - { - Map params = new HashMap(1); - params.put("id", nodeId); - - return (List) template.selectList(SELECT_AVM_NODE_PROPS, params); - } - - @Override - protected int deleteNodePropertyEntity(long nodeId, long qnameId) - { - AVMNodePropertyEntity propEntity = new AVMNodePropertyEntity(); - propEntity.setNodeId(nodeId); - propEntity.setQnameId(qnameId); - - return template.delete(DELETE_AVM_NODE_PROP, propEntity); - } - - @Override - protected int deleteNodePropertyEntities(long nodeId) - { - Map params = new HashMap(1); - params.put("id", nodeId); - - return template.delete(DELETE_AVM_NODE_PROPS, params); - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeLinksDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeLinksDAOImpl.java deleted file mode 100644 index 72cced331b..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeLinksDAOImpl.java +++ /dev/null @@ -1,237 +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 . - */ -package org.alfresco.repo.domain.avm.ibatis; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.repo.domain.avm.AVMChildEntryEntity; -import org.alfresco.repo.domain.avm.AVMHistoryLinkEntity; -import org.alfresco.repo.domain.avm.AVMMergeLinkEntity; -import org.alfresco.repo.domain.avm.AbstractAVMNodeLinksDAOImpl; -import org.mybatis.spring.SqlSessionTemplate; - -/** - * iBatis-specific implementation of the AVMNodeLinks DAO. - * - * @author janv - * @since 3.2 - */ -public class AVMNodeLinksDAOImpl extends AbstractAVMNodeLinksDAOImpl -{ - private static final String SELECT_AVM_NODE_CHILD_ENTRY ="alfresco.avm.select_AVMChildEntry"; // parent + name + child - - private static final String SELECT_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_NAME ="alfresco.avm.select_AVMChildEntryByParentAndName"; // parent + name - - private static final String SELECT_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_CHILD ="alfresco.avm.select_AVMChildEntryByParentAndChild"; // parent + child - private static final String SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT ="alfresco.avm.select_AVMNodeChildEntriesByParent"; // parent - - private static final String SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT_AND_NAME_PATTERN ="alfresco.avm.select_AVMNodeChildEntriesByParentAndNamePattern"; // parent + name pattern - - private static final String SELECT_AVM_NODE_CHILD_ENTRIES_BY_CHILD ="alfresco.avm.select_AVMNodeChildEntriesByChild"; // child - - private static final String INSERT_AVM_NODE_CHILD_ENTRY ="alfresco.avm.insert.insert_AVMChildEntry"; // parent + name + child - - private static final String UPDATE_AVM_NODE_CHILD_ENTRY ="alfresco.avm.update_AVMChildEntry"; // parent + child (update name) - - private static final String DELETE_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_NAME ="alfresco.avm.delete_AVMChildEntryByParentAndName"; // parent + name - - private static final String DELETE_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_CHILD ="alfresco.avm.delete_AVMChildEntryByParentAndChild"; // parent + child - private static final String DELETE_AVM_NODE_CHILD_ENTRIES_BY_PARENT ="alfresco.avm.delete_AVMNodeChildEntriesByParent"; // parent - - private static final String INSERT_AVM_MERGE_LINK ="alfresco.avm.insert.insert_AVMMergeLink"; - private static final String DELETE_AVM_MERGE_LINK ="alfresco.avm.delete_AVMMergeLink"; - - private static final String SELECT_AVM_MERGE_LINKS_BY_FROM ="alfresco.avm.select_AVMMergeLinksByFrom"; - private static final String SELECT_AVM_MERGE_LINK_BY_TO ="alfresco.avm.select_AVMMergeLinkByTo"; - - private static final String INSERT_AVM_HISTORY_LINK ="alfresco.avm.insert.insert_AVMHistoryLink"; - private static final String DELETE_AVM_HISTORY_LINK ="alfresco.avm.delete_AVMHistoryLink"; - - private static final String SELECT_AVM_HISTORY_LINKS_BY_ANCESTOR ="alfresco.avm.select_AVMHistoryLinksByAncestor"; - private static final String SELECT_AVM_HISTORY_LINK_BY_DESCENDENT ="alfresco.avm.select_AVMHistoryLinkByDescendent"; - private static final String SELECT_AVM_HISTORY_LINK ="alfresco.avm.select_AVMHistoryLink"; - - - private SqlSessionTemplate template; - public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) - { - this.template = sqlSessionTemplate; - } - - - @Override - protected AVMChildEntryEntity getChildEntryEntity(AVMChildEntryEntity childEntryEntity) - { - return (AVMChildEntryEntity) template.selectOne(SELECT_AVM_NODE_CHILD_ENTRY, childEntryEntity); - } - - @Override - protected AVMChildEntryEntity getChildEntryEntity(long parentNodeId, String name) - { - AVMChildEntryEntity childEntryEntity = new AVMChildEntryEntity(parentNodeId, name); - - return (AVMChildEntryEntity) template.selectOne(SELECT_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_NAME, childEntryEntity); - } - - @Override - protected AVMChildEntryEntity getChildEntryEntity(long parentNodeId, long childNodeId) - { - AVMChildEntryEntity childEntryEntity = new AVMChildEntryEntity(parentNodeId, childNodeId); - return (AVMChildEntryEntity) template.selectOne(SELECT_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_CHILD, childEntryEntity); - } - - @SuppressWarnings("unchecked") - @Override - protected List getChildEntryEntitiesByParent(long parentNodeId) - { - Map params = new HashMap(1); - params.put("id", parentNodeId); - return (List) template.selectList(SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT, params); - } - - @SuppressWarnings("unchecked") - @Override - protected List getChildEntryEntitiesByParent(long parentNodeId, String childNamePattern) - { - Map params = new HashMap(1); - params.put("id", parentNodeId); - params.put("pattern", childNamePattern.toLowerCase()); - - return (List) template.selectList(SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT_AND_NAME_PATTERN, params); - } - - @SuppressWarnings("unchecked") - @Override - protected List getChildEntryEntitiesByChild(long childNodeId) - { - Map params = new HashMap(1); - params.put("id", childNodeId); - return (List) template.selectList(SELECT_AVM_NODE_CHILD_ENTRIES_BY_CHILD, params); - } - - @Override - protected void createChildEntryEntity(AVMChildEntryEntity childEntryEntity) - { - template.insert(INSERT_AVM_NODE_CHILD_ENTRY, childEntryEntity); - } - - @Override - protected int updateChildEntryEntity(AVMChildEntryEntity childEntryEntity) - { - // TODO: concurrency control - note: specific rename 'case' only - //childEntryEntity.incrementVers(); - - return template.update(UPDATE_AVM_NODE_CHILD_ENTRY, childEntryEntity); - } - - @Override - protected int deleteChildEntryEntity(long parentNodeId, String name) - { - AVMChildEntryEntity childEntryEntity = new AVMChildEntryEntity(parentNodeId, name); - return template.delete(DELETE_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_NAME, childEntryEntity); - } - - @Override - protected int deleteChildEntryEntity(long parentNodeId, long childNodeId) - { - AVMChildEntryEntity childEntryEntity = new AVMChildEntryEntity(parentNodeId, childNodeId); - return template.delete(DELETE_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_CHILD, childEntryEntity); - } - - @Override - protected int deleteChildEntryEntities(long parentNodeId) - { - Map params = new HashMap(1); - params.put("id", parentNodeId); - return template.delete(DELETE_AVM_NODE_CHILD_ENTRIES_BY_PARENT, params); - } - - - @Override - protected void createMergeLinkEntity(long mergeFromNodeId, long mergeToNodeId) - { - AVMMergeLinkEntity mergeLinkEntity = new AVMMergeLinkEntity(mergeFromNodeId, mergeToNodeId); - template.insert(INSERT_AVM_MERGE_LINK, mergeLinkEntity); - } - - @Override - protected int deleteMergeLinkEntity(long mergeFromNodeId, long mergeToNodeId) - { - AVMMergeLinkEntity mLinkEntity = new AVMMergeLinkEntity(mergeFromNodeId, mergeToNodeId); - return template.delete(DELETE_AVM_MERGE_LINK, mLinkEntity); - } - - @Override - protected AVMMergeLinkEntity getMergeLinkEntityByTo(long mergeToNodeId) - { - Map params = new HashMap(1); - params.put("id", mergeToNodeId); - return (AVMMergeLinkEntity) template.selectOne(SELECT_AVM_MERGE_LINK_BY_TO, params); - } - - @SuppressWarnings("unchecked") - @Override - protected List getMergeLinkEntitiesByFrom(long mergeFromNodeId) - { - Map params = new HashMap(1); - params.put("id", mergeFromNodeId); - return (List) template.selectList(SELECT_AVM_MERGE_LINKS_BY_FROM, params); - } - - - @Override - protected void createHistoryLinkEntity(long ancestorNodeId, long mergeToNodeId) - { - AVMHistoryLinkEntity hLinkEntity = new AVMHistoryLinkEntity(ancestorNodeId, mergeToNodeId); - template.insert(INSERT_AVM_HISTORY_LINK, hLinkEntity); - } - - @Override - protected int deleteHistoryLinkEntity(long ancestorNodeId, long descendentNodeId) - { - AVMHistoryLinkEntity hLinkEntity = new AVMHistoryLinkEntity(ancestorNodeId, descendentNodeId); - return template.delete(DELETE_AVM_HISTORY_LINK, hLinkEntity); - } - - @Override - protected AVMHistoryLinkEntity getHistoryLinkEntityByDescendent(long descendentNodeId) - { - Map params = new HashMap(1); - params.put("id", descendentNodeId); - return (AVMHistoryLinkEntity) template.selectOne(SELECT_AVM_HISTORY_LINK_BY_DESCENDENT, params); - } - - @Override - protected AVMHistoryLinkEntity getHistoryLinkEntity(long ancestorNodeId, long descendentNodeId) - { - AVMHistoryLinkEntity hLinkEntity = new AVMHistoryLinkEntity(ancestorNodeId, descendentNodeId); - return (AVMHistoryLinkEntity) template.selectOne(SELECT_AVM_HISTORY_LINK, hLinkEntity); - } - - @SuppressWarnings("unchecked") - @Override - protected List getHistoryLinkEntitiesByAncestor(long ancestorNodeId) - { - Map params = new HashMap(1); - params.put("id", ancestorNodeId); - return (List) template.selectList(SELECT_AVM_HISTORY_LINKS_BY_ANCESTOR, params); - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMStoreDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMStoreDAOImpl.java deleted file mode 100644 index f38abfc727..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMStoreDAOImpl.java +++ /dev/null @@ -1,229 +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 . - */ -package org.alfresco.repo.domain.avm.ibatis; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.repo.domain.avm.AVMStoreEntity; -import org.alfresco.repo.domain.avm.AVMStorePropertyEntity; -import org.alfresco.repo.domain.avm.AbstractAVMStoreDAOImpl; -import org.mybatis.spring.SqlSessionTemplate; - -/** - * iBatis-specific implementation of the AVMStore DAO. - * - * @author janv - * @since 3.2 - */ -public class AVMStoreDAOImpl extends AbstractAVMStoreDAOImpl -{ - private static final String SELECT_AVM_STORE_BY_ID ="alfresco.avm.select_AVMStoreById"; - - private static final String SELECT_AVM_STORE_BY_KEY ="alfresco.avm.select_AVMStoreByKey"; // name - private static final String SELECT_AVM_STORE_BY_KEY_L ="alfresco.avm.select_AVMStoreByKeyL"; // lower(name) - - private static final String SELECT_AVM_STORE_BY_ROOT_NODE_ID ="alfresco.avm.select_AVMStoreByRootNodeId"; - private static final String SELECT_AVM_STORE_ALL ="alfresco.avm.select_AVMStoreAll"; - - private static final String INSERT_AVM_STORE ="alfresco.avm.insert.insert_AVMStore"; - private static final String DELETE_AVM_STORE ="alfresco.avm.delete_AVMStore"; - private static final String UPDATE_AVM_STORE ="alfresco.avm.update_AVMStore"; - - private static final String INSERT_AVM_STORE_PROP ="alfresco.avm.insert.insert_AVMStoreProperty"; - private static final String UPDATE_AVM_STORE_PROP ="alfresco.avm.update_AVMStoreProperty"; - private static final String SELECT_AVM_STORE_PROP ="alfresco.avm.select_AVMStoreProperty"; - private static final String SELECT_AVM_STORE_PROPS ="alfresco.avm.select_AVMStoreProperties"; - - private static final String SELECT_AVM_STORE_PROPS_BY_KEY_PATTERN ="alfresco.avm.select_AVMStorePropertiesByKeyPattern"; // uri + local_name - private static final String SELECT_AVM_STORE_PROPS_BY_KEY_PATTERN_L ="alfresco.avm.select_AVMStorePropertiesByKeyPatternL"; // uri + lower(local_name) - - private static final String SELECT_AVM_STORE_PROPS_BY_STORE_AND_KEY_PATTERN ="alfresco.avm.select_AVMStorePropertiesByStoreAndKeyPattern"; // store id + uri + local_name - private static final String SELECT_AVM_STORE_PROPS_BY_STORE_AND_KEY_PATTERN_L ="alfresco.avm.select_AVMStorePropertiesByStoreAndKeyPatternL"; // store id + uri + lower(local_name) - - private static final String DELETE_AVM_STORE_PROP ="alfresco.avm.delete_AVMStoreProperty"; - private static final String DELETE_AVM_STORE_PROPS ="alfresco.avm.delete_AVMStoreProperties"; - - - private SqlSessionTemplate template; - - public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) - { - this.template = sqlSessionTemplate; - } - - - // Initial generic fixes for ALF-2278 (pending SAIL-365) & ALF-498 (pending SAIL-359) - // Note: in order to override to false, DB must be setup to be case-insensitive (at least on column avm_stores.name) - private boolean toLower = true; - - public void setToLower(boolean toLower) - { - this.toLower = toLower; - } - - @Override - protected AVMStoreEntity getStoreEntity(long id) - { - Map params = new HashMap(1); - params.put("id", id); - return (AVMStoreEntity) template.selectOne(SELECT_AVM_STORE_BY_ID, params); - } - - @Override - protected AVMStoreEntity getStoreEntity(String name) - { - AVMStoreEntity storeEntity = new AVMStoreEntity(); - storeEntity.setName(name); - - if (toLower) - { - return (AVMStoreEntity) template.selectOne(SELECT_AVM_STORE_BY_KEY_L, storeEntity); - } - return (AVMStoreEntity) template.selectOne(SELECT_AVM_STORE_BY_KEY, storeEntity); - } - - @Override - protected AVMStoreEntity getStoreEntityByRoot(long rootNodeId) - { - Map params = new HashMap(1); - params.put("id", rootNodeId); - return (AVMStoreEntity) template.selectOne(SELECT_AVM_STORE_BY_ROOT_NODE_ID, params); - } - - @SuppressWarnings("unchecked") - @Override - protected List getAllStoreEntities() - { - return (List) template.selectList(SELECT_AVM_STORE_ALL); - } - - @Override - protected AVMStoreEntity createStoreEntity(AVMStoreEntity storeEntity) - { - template.insert(INSERT_AVM_STORE, storeEntity); - return storeEntity; - } - - @Override - protected int updateStoreEntity(AVMStoreEntity updateStoreEntity) - { - updateStoreEntity.incrementVers(); - - return template.update(UPDATE_AVM_STORE, updateStoreEntity); - } - - @Override - protected int deleteStoreEntity(long id) - { - Map params = new HashMap(1); - params.put("id", id); - return template.delete(DELETE_AVM_STORE, params); - } - - @Override - protected void insertStorePropertyEntity(AVMStorePropertyEntity propEntity) - { - template.insert(INSERT_AVM_STORE_PROP, propEntity); - } - - @Override - protected int updateStorePropertyEntity(AVMStorePropertyEntity updatePropEntity) - { - return template.update(UPDATE_AVM_STORE_PROP, updatePropEntity); - } - - @Override - protected AVMStorePropertyEntity getStorePropertyEntity(long storeId, long qnameId) - { - AVMStorePropertyEntity propEntity = new AVMStorePropertyEntity(); - propEntity.setAvmStoreId(storeId); - propEntity.setQnameId(qnameId); - - return (AVMStorePropertyEntity) template.selectOne(SELECT_AVM_STORE_PROP, propEntity); - } - - @SuppressWarnings("unchecked") - @Override - protected List getStorePropertyEntities(long storeId) - { - Map params = new HashMap(1); - params.put("id", storeId); - - try - { - return (List) template.selectList(SELECT_AVM_STORE_PROPS, params); - } - catch (Throwable e) - { - throw new RuntimeException("Unable to query for store properties: " + params, e); - } - } - - @SuppressWarnings("unchecked") - @Override - protected List getStorePropertyEntitiesByKeyPattern(String uriPattern, String localNamePattern) - { - Map params = new HashMap(2); - params.put("uri", uriPattern); - params.put("localname", localNamePattern); - - if (toLower) - { - return (List) template.selectList(SELECT_AVM_STORE_PROPS_BY_KEY_PATTERN_L, params); - } - return (List) template.selectList(SELECT_AVM_STORE_PROPS_BY_KEY_PATTERN, params); - } - - @SuppressWarnings("unchecked") - @Override - protected List getStorePropertyEntitiesByStoreAndKeyPattern(long storeId, String uriPattern, String localNamePattern) - { - Map params = new HashMap(3); - params.put("id", storeId); - params.put("uri", uriPattern); - params.put("localname", localNamePattern); - - if (toLower) - { - return (List) template.selectList(SELECT_AVM_STORE_PROPS_BY_STORE_AND_KEY_PATTERN_L, params); - } - return (List) template.selectList(SELECT_AVM_STORE_PROPS_BY_STORE_AND_KEY_PATTERN, params); - } - - @Override - protected int deleteStorePropertyEntity(long storeId, long qnameId) - { - AVMStorePropertyEntity propEntity = new AVMStorePropertyEntity(); - propEntity.setAvmStoreId(storeId); - propEntity.setQnameId(qnameId); - - return template.delete(DELETE_AVM_STORE_PROP, propEntity); - } - - @Override - protected int deleteStorePropertyEntities(long storeId) - { - Map params = new HashMap(1); - params.put("id", storeId); - - return template.delete(DELETE_AVM_STORE_PROPS, params); - } -} diff --git a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMVersionRootDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMVersionRootDAOImpl.java deleted file mode 100644 index 7ffe6c056d..0000000000 --- a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMVersionRootDAOImpl.java +++ /dev/null @@ -1,233 +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 . - */ -package org.alfresco.repo.domain.avm.ibatis; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.repo.domain.avm.AVMStoreEntity; -import org.alfresco.repo.domain.avm.AVMVersionLayeredNodeEntryEntity; -import org.alfresco.repo.domain.avm.AVMVersionRootEntity; -import org.alfresco.repo.domain.avm.AbstractAVMVersionRootDAOImpl; -import org.mybatis.spring.SqlSessionTemplate; - -/** - * iBatis-specific implementation of the AVMVersionRoot DAO - * - * @author janv - * @since 3.2 - */ -public class AVMVersionRootDAOImpl extends AbstractAVMVersionRootDAOImpl -{ - private static final String INSERT_AVM_VERSION_ROOT ="alfresco.avm.insert.insert_AVMVersionRoot"; - private static final String DELETE_AVM_VERSION_ROOT ="alfresco.avm.delete_AVMVersionRoot"; - private static final String UPDATE_AVM_VERSION_ROOT ="alfresco.avm.update_AVMVersionRoot"; - - private static final String SELECT_AVM_VERSION_ROOT_MAX_VERSION ="alfresco.avm.select_AVMVersionRootMaxVersion"; - private static final String SELECT_AVM_VERSION_ROOT_MAX_VERSION_ID ="alfresco.avm.select_AVMVersionRootMaxVersionID"; - private static final String SELECT_AVM_VERSION_ROOT_BY_ID ="alfresco.avm.select_AVMVersionRootById"; - private static final String SELECT_AVM_VERSION_ROOT_BY_STORE_VERSION ="alfresco.avm.select_AVMVersionRootByStoreVersion"; - private static final String SELECT_AVM_VERSION_ROOT_BY_ROOT_NODE_ID ="alfresco.avm.select_AVMVersionRootByRootNodeId"; - private static final String SELECT_AVM_VERSION_ROOTS_BY_STORE_ID ="alfresco.avm.select_AVMVersionRootsByStoreId"; - private static final String SELECT_AVM_VERSION_ROOTS_BY_DATE_TO ="alfresco.avm.select_AVMVersionRootsByTo"; - private static final String SELECT_AVM_VERSION_ROOTS_BY_DATE_FROM ="alfresco.avm.select_AVMVersionRootsByFrom"; - private static final String SELECT_AVM_VERSION_ROOTS_BY_DATES_BETWEEN ="alfresco.avm.select_AVMVersionRootsBetween"; - - private static final String SELECT_AVM_VERSION_ROOTS_BY_VERSION_TO ="alfresco.avm.select_AVMVersionRootsByVersionTo"; - private static final String SELECT_AVM_VERSION_ROOTS_BY_VERSION_FROM ="alfresco.avm.select_AVMVersionRootsByVersionFrom"; - private static final String SELECT_AVM_VERSION_ROOTS_BY_VERSIONS_BETWEEN ="alfresco.avm.select_AVMVersionRootsByVersionsBetween"; - - private static final String INSERT_AVM_VERSION_LAYERED_NODE_ENTRY ="alfresco.avm.insert.insert_AVMVersionLayeredNodeEntry"; - private static final String DELETE_AVM_VERSION_LAYERED_NODE_ENTRIES ="alfresco.avm.delete_AVMVersionLayeredNodeEntries"; - private static final String SELECT_AVM_VERSION_LAYERED_NODE_ENTRIES ="alfresco.avm.select_AVMVersionLayeredNodeEntries"; - - - private SqlSessionTemplate template; - - public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) - { - this.template = sqlSessionTemplate; - } - - - @Override - protected AVMVersionRootEntity createVersionRootEntity(AVMVersionRootEntity newVersionRootEntity) - { - template.insert(INSERT_AVM_VERSION_ROOT, newVersionRootEntity); - return newVersionRootEntity; - } - - @Override - protected int updateVersionRootEntity(AVMVersionRootEntity updateVersionRootEntity) - { - return template.update(UPDATE_AVM_VERSION_ROOT, updateVersionRootEntity); - } - - @Override - protected AVMVersionRootEntity getVersionRootEntityMaxVersion(long storeId) - { - AVMStoreEntity storeEntity = new AVMStoreEntity(); - storeEntity.setId(storeId); - return (AVMVersionRootEntity) template.selectOne(SELECT_AVM_VERSION_ROOT_MAX_VERSION, storeEntity); - } - - @Override - protected Long getVersionRootEntityMaxVersionId(long storeId) - { - Map params = new HashMap(1); - params.put("id", storeId); - Integer maxVersionId = (Integer) template.selectOne(SELECT_AVM_VERSION_ROOT_MAX_VERSION_ID, params); - if (maxVersionId == null) - { - return null; - } - return new Long(maxVersionId); - } - - @Override - protected AVMVersionRootEntity getVersionRootEntityById(long vrEntityId) - { - Map params = new HashMap(1); - params.put("id", vrEntityId); - return (AVMVersionRootEntity) template.selectOne(SELECT_AVM_VERSION_ROOT_BY_ID, params); - } - - @Override - protected AVMVersionRootEntity getVersionRootEntityByStoreVersion(long storeId, int version) - { - AVMVersionRootEntity vrEntity = new AVMVersionRootEntity(); - vrEntity.setStoreId(storeId); - vrEntity.setVersion(version); - - return (AVMVersionRootEntity) template.selectOne(SELECT_AVM_VERSION_ROOT_BY_STORE_VERSION, vrEntity); - } - - @Override - protected AVMVersionRootEntity getVersionRootEntityByRootNodeId(long rootNodeId) - { - Map params = new HashMap(1); - params.put("id", rootNodeId); - return (AVMVersionRootEntity) template.selectOne(SELECT_AVM_VERSION_ROOT_BY_ROOT_NODE_ID, params); - } - - @SuppressWarnings("unchecked") - @Override - protected List getAllVersionRootEntitiesByStoreId(long storeId) - { - Map params = new HashMap(1); - params.put("id", storeId); - return (List) template.selectList(SELECT_AVM_VERSION_ROOTS_BY_STORE_ID, params); - } - - @SuppressWarnings("unchecked") - protected List getVersionRootEntitiesByTo(long storeId, long to) - { - Map params = new HashMap(2); - params.put("id", storeId); - params.put("to", to); - return (List) template.selectList(SELECT_AVM_VERSION_ROOTS_BY_DATE_TO, params); - } - - @SuppressWarnings("unchecked") - protected List getVersionRootEntitiesByFrom(long storeId, long from) - { - Map params = new HashMap(2); - params.put("id", storeId); - params.put("from", from); - return (List) template.selectList(SELECT_AVM_VERSION_ROOTS_BY_DATE_FROM, params); - } - - @SuppressWarnings("unchecked") - protected List getVersionRootEntitiesByBetween(long storeId, long from, long to) - { - Map params = new HashMap(3); - params.put("id", storeId); - params.put("from", from); - params.put("to", to); - return (List) template.selectList(SELECT_AVM_VERSION_ROOTS_BY_DATES_BETWEEN, params); - } - - @SuppressWarnings("unchecked") - @Override - protected List getVersionRootEntitiesByVersionsBetween(long storeId, long from, long to) - { - Map params = new HashMap(3); - params.put("id", storeId); - params.put("from", from); - params.put("to", to); - return (List) template.selectList(SELECT_AVM_VERSION_ROOTS_BY_VERSIONS_BETWEEN, params); - } - - @SuppressWarnings("unchecked") - @Override - protected List getVersionRootEntitiesByVersionsFrom(long storeId, long from) - { - Map params = new HashMap(2); - params.put("id", storeId); - params.put("from", from); - return (List) template.selectList(SELECT_AVM_VERSION_ROOTS_BY_VERSION_FROM, params); - } - - @SuppressWarnings("unchecked") - @Override - protected List getVersionRootEntitiesByVersionsTo(long storeId, long to) - { - Map params = new HashMap(2); - params.put("id", storeId); - params.put("to", to); - return (List) template.selectList(SELECT_AVM_VERSION_ROOTS_BY_VERSION_TO, params); - } - - @Override - protected int deleteVersionRootEntity(long vrEntityId) - { - Map params = new HashMap(1); - params.put("id", vrEntityId); - return template.delete(DELETE_AVM_VERSION_ROOT, params); - } - - @Override - protected AVMVersionLayeredNodeEntryEntity createVersionLayeredNodeEntryEntity(long versionRootId, String md5sum, String path) - { - AVMVersionLayeredNodeEntryEntity vlneEntity = new AVMVersionLayeredNodeEntryEntity(); - vlneEntity.setVersionRootId(versionRootId); - vlneEntity.setMd5sum(md5sum); - vlneEntity.setPath(path); - template.insert(INSERT_AVM_VERSION_LAYERED_NODE_ENTRY, vlneEntity); - return vlneEntity; - } - - @Override - protected int deleteVersionLayeredNodeEntryEntities(long versionRootId) - { - Map params = new HashMap(1); - params.put("id", versionRootId); - return template.delete(DELETE_AVM_VERSION_LAYERED_NODE_ENTRIES, params); - } - - @SuppressWarnings("unchecked") - @Override - protected List getVersionLayeredNodeEntryEntities(long versionRootId) - { - Map params = new HashMap(1); - params.put("id", versionRootId); - return (List) template.selectList(SELECT_AVM_VERSION_LAYERED_NODE_ENTRIES, params); - } -} diff --git a/source/java/org/alfresco/repo/domain/patch/AbstractPatchDAOImpl.java b/source/java/org/alfresco/repo/domain/patch/AbstractPatchDAOImpl.java index 31be0e3cbd..e6c6d4cfcf 100644 --- a/source/java/org/alfresco/repo/domain/patch/AbstractPatchDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/patch/AbstractPatchDAOImpl.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.Map; import org.alfresco.ibatis.BatchingDAO; -import org.alfresco.repo.domain.avm.AVMNodeEntity; import org.alfresco.repo.domain.contentdata.ContentDataDAO; import org.alfresco.service.cmr.repository.ContentData; import org.apache.ibatis.session.ResultHandler; @@ -51,46 +50,6 @@ public abstract class AbstractPatchDAOImpl implements PatchDAO, BatchingDAO this.contentDataDAO = contentDataDAO; } - /** - * {@inheritDoc} - */ - public long getAVMNodesCountWhereNewInStore() - { - return getAVMNodeEntitiesCountWhereNewInStore(); - } - - public List getEmptyGUIDS(int count) - { - return getAVMNodeEntitiesWithEmptyGUID(count); - } - - public List getNullVersionLayeredDirectories(int count) - { - return getNullVersionLayeredDirectoryNodeEntities(count); - } - - public List getNullVersionLayeredFiles(int count) - { - return getNullVersionLayeredFileNodeEntities(count); - } - - public int updateAVMNodesNullifyAcl(List nodeIds) - { - return updateAVMNodeEntitiesNullifyAcl(nodeIds); - } - - public int updateAVMNodesSetAcl(long aclId, List nodeIds) - { - return updateAVMNodeEntitiesSetAcl(aclId, nodeIds); - } - - protected abstract long getAVMNodeEntitiesCountWhereNewInStore(); - protected abstract List getAVMNodeEntitiesWithEmptyGUID(int maxResults); - protected abstract List getNullVersionLayeredDirectoryNodeEntities(int maxResults); - protected abstract List getNullVersionLayeredFileNodeEntities(int maxResults); - protected abstract int updateAVMNodeEntitiesNullifyAcl(List nodeIds); - protected abstract int updateAVMNodeEntitiesSetAcl(long aclId, List nodeIds); - public long getMaxAclId() { return getMaxAclEntityId(); @@ -224,15 +183,6 @@ public abstract class AbstractPatchDAOImpl implements PatchDAO, BatchingDAO protected abstract void getOldAttrTenantsImpl(ResultHandler resultHandler); - // note: caller's row handler is expected to migrate the attrs - @Override - public void migrateOldAttrAVMLocks(ResultHandler resultHandler) - { - getOldAttrAVMLocksImpl(resultHandler); - } - - protected abstract void getOldAttrAVMLocksImpl(ResultHandler resultHandler); - // note: caller's row handler is expected to migrate the attrs @Override public void migrateOldAttrPropertyBackedBeans(ResultHandler resultHandler) diff --git a/source/java/org/alfresco/repo/domain/patch/PatchDAO.java b/source/java/org/alfresco/repo/domain/patch/PatchDAO.java index 908b5ac841..8519eaad7a 100644 --- a/source/java/org/alfresco/repo/domain/patch/PatchDAO.java +++ b/source/java/org/alfresco/repo/domain/patch/PatchDAO.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.alfresco.repo.domain.avm.AVMNodeEntity; import org.alfresco.repo.domain.contentdata.ContentDataDAO; import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.NodeRef; @@ -39,24 +38,6 @@ import org.apache.ibatis.session.ResultHandler; */ public interface PatchDAO { - // AVM-related - - public long getAVMNodesCountWhereNewInStore(); - - public List getEmptyGUIDS(int count); - - public List getNullVersionLayeredDirectories(int count); - - public List getNullVersionLayeredFiles(int count); - - public long getMaxAvmNodeID(); - - public List getAvmNodesWithOldContentProperties(Long minNodeId, Long maxNodeId); - - public int updateAVMNodesNullifyAcl(List nodeIds); - - public int updateAVMNodesSetAcl(long aclId, List nodeIds); - // DM-related public long getMaxAdmNodeID(); @@ -189,11 +170,6 @@ public interface PatchDAO */ public void migrateOldAttrTenants(ResultHandler resultHandler); - /** - * Migrate old AVM Lock attributes (if any) - */ - public void migrateOldAttrAVMLocks(ResultHandler resultHandler); - /** * Migrate old Property-Backed Bean attributes (if any) */ diff --git a/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java b/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java index 2ce940a55d..0c3ce00717 100644 --- a/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java @@ -28,7 +28,6 @@ import java.util.Set; import org.alfresco.ibatis.IdsEntity; import org.alfresco.model.ContentModel; import org.alfresco.repo.domain.CrcHelper; -import org.alfresco.repo.domain.avm.AVMNodeEntity; import org.alfresco.repo.domain.locale.LocaleDAO; import org.alfresco.repo.domain.node.ChildAssocEntity; import org.alfresco.repo.domain.patch.AbstractPatchDAOImpl; @@ -48,7 +47,7 @@ import org.apache.ibatis.session.RowBounds; import org.mybatis.spring.SqlSessionTemplate; /** - * iBatis-specific implementation of the AVMPatch DAO. + * iBatis-specific implementation of the PatchDAO. * * @author janv * @since 3.2 @@ -57,13 +56,7 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl { private static Log logger = LogFactory.getLog(PatchDAOImpl.class); - private static final String SELECT_AVM_NODE_ENTITIES_COUNT_WHERE_NEW_IN_STORE = "alfresco.avm.select_AVMNodeEntitiesCountWhereNewInStore"; - private static final String SELECT_AVM_NODE_ENTITIES_WITH_EMPTY_GUID = "alfresco.avm.select_AVMNodesWithEmptyGUID"; - private static final String SELECT_AVM_LD_NODE_ENTITIES_NULL_VERSION = "alfresco.avm.select_AVMNodes_nullVersionLayeredDirectories"; - private static final String SELECT_AVM_LF_NODE_ENTITIES_NULL_VERSION = "alfresco.avm.select_AVMNodes_nullVersionLayeredFiles"; - private static final String SELECT_AVM_MAX_NODE_ID = "alfresco.patch.select_avmMaxNodeId"; private static final String SELECT_ADM_MAX_NODE_ID = "alfresco.patch.select_admMaxNodeId"; - private static final String SELECT_AVM_NODES_WITH_OLD_CONTENT_PROPERTIES = "alfresco.patch.select_avmNodesWithOldContentProperties"; private static final String SELECT_ADM_OLD_CONTENT_PROPERTIES = "alfresco.patch.select_admOldContentProperties"; private static final String SELECT_AUTHORITIES_AND_CRC = "alfresco.patch.select_authoritiesAndCrc"; private static final String SELECT_PERMISSIONS_ALL_ACL_IDS = "alfresco.patch.select_AllAclIds"; @@ -78,8 +71,6 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl private static final String UPDATE_ADM_OLD_CONTENT_PROPERTY = "alfresco.patch.update_admOldContentProperty"; private static final String UPDATE_CONTENT_MIMETYPE_ID = "alfresco.patch.update_contentMimetypeId"; - private static final String UPDATE_AVM_NODE_LIST_NULLIFY_ACL = "alfresco.avm.update_AVMNodeList_nullifyAcl"; - private static final String UPDATE_AVM_NODE_LIST_SET_ACL = "alfresco.avm.update_AVMNodeList_setAcl"; private static final String UPDATE_CHILD_ASSOC_CRC = "alfresco.patch.update_childAssocCrc"; private static final String UPDATE_CREATE_SIZE_CURRENT_PROPERTY = "alfresco.patch.update_CreateSizeCurrentProperty"; @@ -88,7 +79,6 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl private static final String DELETE_PERMISSIONS_ACL_MEMBERS_FOR_ACL_LIST = "alfresco.permissions.delete_AclMembersForAclList"; private static final String SELECT_OLD_ATTR_TENANTS = "alfresco.patch.select_oldAttrTenants"; - private static final String SELECT_OLD_ATTR_AVM_LOCKS= "alfresco.patch.select_oldAttrAVMLocks"; private static final String SELECT_OLD_ATTR_PBBS = "alfresco.patch.select_oldAttrPropertyBackedBeans"; private static final String SELECT_OLD_ATTR_CHAINING_URS = "alfresco.patch.select_oldAttrChainingURS"; private static final String SELECT_OLD_ATTR_CUSTOM_NAMES = "alfresco.patch.select_oldAttrCustomNames"; @@ -167,64 +157,6 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl */ } - @Override - protected long getAVMNodeEntitiesCountWhereNewInStore() - { - Long count = (Long) template.selectOne(SELECT_AVM_NODE_ENTITIES_COUNT_WHERE_NEW_IN_STORE); - return count == null ? 0L : count; - } - - @SuppressWarnings("unchecked") - @Override - protected List getAVMNodeEntitiesWithEmptyGUID(int maxResults) - { - if (maxResults < 0) - { - maxResults = RowBounds.NO_ROW_LIMIT; - } - - return (List) template.selectList(SELECT_AVM_NODE_ENTITIES_WITH_EMPTY_GUID, new RowBounds(0, maxResults)); - } - - @SuppressWarnings("unchecked") - @Override - protected List getNullVersionLayeredDirectoryNodeEntities(int maxResults) - { - if (maxResults < 0) - { - maxResults = RowBounds.NO_ROW_LIMIT; - } - - return (List) template.selectList(SELECT_AVM_LD_NODE_ENTITIES_NULL_VERSION, new RowBounds(0, maxResults)); - } - - @SuppressWarnings("unchecked") - @Override - protected List getNullVersionLayeredFileNodeEntities(int maxResults) - { - if (maxResults < 0) - { - maxResults = RowBounds.NO_ROW_LIMIT; - } - - return (List) template.selectList(SELECT_AVM_LF_NODE_ENTITIES_NULL_VERSION, new RowBounds(0, maxResults)); - } - - public long getMaxAvmNodeID() - { - Long count = (Long) template.selectOne(SELECT_AVM_MAX_NODE_ID); - return count == null ? 0L : count; - } - - @SuppressWarnings("unchecked") - public List getAvmNodesWithOldContentProperties(Long minNodeId, Long maxNodeId) - { - IdsEntity ids = new IdsEntity(); - ids.setIdOne(minNodeId); - ids.setIdTwo(maxNodeId); - return (List) template.selectList(SELECT_AVM_NODES_WITH_OLD_CONTENT_PROPERTIES, ids); - } - public long getMaxAdmNodeID() { Long count = (Long) template.selectOne(SELECT_ADM_MAX_NODE_ID); @@ -281,22 +213,6 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl return rowsAffected; } - @Override - protected int updateAVMNodeEntitiesNullifyAcl(List nodeIds) - { - return template.update(UPDATE_AVM_NODE_LIST_NULLIFY_ACL, nodeIds); - } - - @Override - protected int updateAVMNodeEntitiesSetAcl(long aclId, List nodeIds) - { - IdListOfIdsParam params = new IdListOfIdsParam(); - params.setId(aclId); - params.setListOfIds(nodeIds); - - return template.update(UPDATE_AVM_NODE_LIST_SET_ACL, params); - } - @Override protected long getMaxAclEntityId() { @@ -527,12 +443,6 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl template.select(SELECT_OLD_ATTR_TENANTS, resultHandler); } - @Override - protected void getOldAttrAVMLocksImpl(ResultHandler resultHandler) - { - template.select(SELECT_OLD_ATTR_AVM_LOCKS, resultHandler); - } - @Override protected void getOldAttrPropertyBackedBeansImpl(ResultHandler resultHandler) { diff --git a/source/java/org/alfresco/repo/domain/permissions/ADMAccessControlListDAO.java b/source/java/org/alfresco/repo/domain/permissions/ADMAccessControlListDAO.java index a420a4ddff..67b17b783e 100644 --- a/source/java/org/alfresco/repo/domain/permissions/ADMAccessControlListDAO.java +++ b/source/java/org/alfresco/repo/domain/permissions/ADMAccessControlListDAO.java @@ -144,13 +144,10 @@ public class ADMAccessControlListDAO implements AccessControlListDAO for (Pair pair : stores) { - if (!pair.getSecond().getProtocol().equals(StoreRef.PROTOCOL_AVM)) - { - CounterSet update; - Long rootNodeId = nodeDAO.getRootNode(pair.getSecond()).getFirst(); - update = fixOldDmAcls(rootNodeId, nodeDAO.getNodeAclId(rootNodeId), (Long)null, true); - result.add(update); - } + CounterSet update; + Long rootNodeId = nodeDAO.getRootNode(pair.getSecond()).getFirst(); + update = fixOldDmAcls(rootNodeId, nodeDAO.getNodeAclId(rootNodeId), (Long)null, true); + result.add(update); } HashMap toReturn = new HashMap(); diff --git a/source/java/org/alfresco/repo/domain/permissions/AVMPermissionsDaoComponentImpl.java b/source/java/org/alfresco/repo/domain/permissions/AVMPermissionsDaoComponentImpl.java deleted file mode 100644 index 1211329317..0000000000 --- a/source/java/org/alfresco/repo/domain/permissions/AVMPermissionsDaoComponentImpl.java +++ /dev/null @@ -1,193 +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 . - */ -package org.alfresco.repo.domain.permissions; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.alfresco.repo.security.permissions.ACLType; -import org.alfresco.repo.security.permissions.AccessControlEntry; -import org.alfresco.repo.security.permissions.AccessControlList; -import org.alfresco.repo.security.permissions.SimpleAccessControlListProperties; -import org.alfresco.repo.security.permissions.impl.AclChange; -import org.alfresco.service.cmr.repository.InvalidNodeRefException; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * AVM permissions dao component impl - * - * Manage creation and deletion of ACL entries for the AVM ACL implementation - * - * @author andyh - */ -public class AVMPermissionsDaoComponentImpl extends AbstractPermissionsDaoComponentImpl -{ - @Override - protected CreationReport createAccessControlList(NodeRef nodeRef, boolean inherit, Acl existing) - { - if (existing == null) - { - SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties(); - properties.setAclType(ACLType.DEFINING); - properties.setVersioned(true); - - Acl acl = aclDaoComponent.createAccessControlList(properties); - long id = acl.getId(); - - List changes = new ArrayList(); - changes.add(new AclDAOImpl.AclChangeImpl(null, id, null, acl.getAclType())); - changes.addAll(getACLDAO(nodeRef).setInheritanceForChildren(nodeRef, id, null)); - getACLDAO(nodeRef).setAccessControlList(nodeRef, acl); - return new CreationReport(acl, changes); - } - SimpleAccessControlListProperties properties; - Long id; - List changes; - Acl acl; - switch (existing.getAclType()) - { - case OLD: - throw new IllegalStateException("Can not mix old and new style permissions"); - case DEFINING: - return new CreationReport(existing, Collections. emptyList()); - case FIXED: - case GLOBAL: - case SHARED: - // create new defining, wire up and report changes to acl required. - properties = new SimpleAccessControlListProperties(); - properties.setAclType(ACLType.DEFINING); - properties.setInherits(existing.getInherits()); - properties.setVersioned(true); - - acl = aclDaoComponent.createAccessControlList(properties); - id = acl.getId(); - - changes = new ArrayList(); - changes.add(new AclDAOImpl.AclChangeImpl(existing.getId(), id, existing.getAclType(), acl.getAclType())); - changes.addAll(aclDaoComponent.mergeInheritedAccessControlList(existing.getId(), id)); - // set this to inherit to children - changes.addAll(getACLDAO(nodeRef).setInheritanceForChildren(nodeRef, id, aclDaoComponent.getInheritedAccessControlList(existing.getId()))); - - getACLDAO(nodeRef).setAccessControlList(nodeRef, acl); - return new CreationReport(acl, changes); - case LAYERED: - // Need to get the indirected node ACL - Long indirectAclId = getACLDAO(nodeRef).getIndirectAcl(nodeRef); - Long inheritedAclId = getACLDAO(nodeRef).getInheritedAcl(nodeRef); - - // create new defining, wire up and report changes to acl required. - properties = new SimpleAccessControlListProperties(); - properties.setAclType(ACLType.DEFINING); - if (indirectAclId != null) - { - properties.setInherits(aclDaoComponent.getAccessControlListProperties(indirectAclId).getInherits()); - } - properties.setVersioned(true); - - acl = aclDaoComponent.createAccessControlList(properties); - id = acl.getId(); - - changes = new ArrayList(); - changes.add(new AclDAOImpl.AclChangeImpl(existing.getId(), id, existing.getAclType(), acl.getAclType())); - if (indirectAclId != null) - { - AccessControlList indirectAcl = aclDaoComponent.getAccessControlList(indirectAclId); - for (AccessControlEntry entry : indirectAcl.getEntries()) - { - if (entry.getPosition() == 0) - { - aclDaoComponent.setAccessControlEntry(id, entry); - } - } - } - if (inheritedAclId != null) - { - changes.addAll(aclDaoComponent.mergeInheritedAccessControlList(inheritedAclId, id)); - } - // set this to inherit to children - changes.addAll(getACLDAO(nodeRef).setInheritanceForChildren(nodeRef, id, existing.getInheritedAcl())); - - getACLDAO(nodeRef).setAccessControlList(nodeRef, acl); - return new CreationReport(acl, changes); - default: - throw new IllegalStateException("Unknown type " + existing.getAclType()); - } - } - - public void deletePermissions(NodeRef nodeRef) - { - Acl acl = null; - try - { - acl = getAccessControlList(nodeRef); - } - catch (InvalidNodeRefException e) - { - return; - } - if (acl != null) - { - switch (acl.getAclType()) - { - case OLD: - throw new IllegalStateException("Can not mix old and new style permissions"); - case DEFINING: - if (acl.getInheritsFrom() != null) - { - Long inheritsFrom = acl.getInheritsFrom(); - getACLDAO(nodeRef).setAccessControlList(nodeRef, aclDaoComponent.getAcl(inheritsFrom)); - List changes = new ArrayList(); - changes.addAll(getACLDAO(nodeRef).setInheritanceForChildren(nodeRef, inheritsFrom, aclDaoComponent.getInheritedAccessControlList(acl.getId()))); - getACLDAO(nodeRef).updateChangedAcls(nodeRef, changes); - aclDaoComponent.deleteAccessControlList(acl.getId()); - } - else - { - // TODO: could just cear out existing - SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties(); - properties.setAclType(ACLType.DEFINING); - properties.setInherits(Boolean.FALSE); - properties.setVersioned(true); - - Acl newAcl = aclDaoComponent.createAccessControlList(properties); - long id = newAcl.getId(); - - getACLDAO(nodeRef).setAccessControlList(nodeRef, newAcl); - List changes = new ArrayList(); - changes.addAll(getACLDAO(nodeRef).setInheritanceForChildren(nodeRef, id, acl.getInheritedAcl())); - getACLDAO(nodeRef).updateChangedAcls(nodeRef, changes); - aclDaoComponent.deleteAccessControlList(acl.getId()); - } - break; - case FIXED: - throw new IllegalStateException("Delete not supported for fixed permissions"); - case GLOBAL: - throw new IllegalStateException("Delete not supported for global permissions"); - case SHARED: - // nothing to do - return; - case LAYERED: - throw new IllegalStateException("Layering is not supported for DM permissions"); - default: - throw new IllegalStateException("Unknown type " + acl.getAclType()); - } - } - } -} diff --git a/source/java/org/alfresco/repo/exporter/AVMZipExporterServiceImpl.java b/source/java/org/alfresco/repo/exporter/AVMZipExporterServiceImpl.java deleted file mode 100644 index 20dddd7bde..0000000000 --- a/source/java/org/alfresco/repo/exporter/AVMZipExporterServiceImpl.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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 . - */ -package org.alfresco.repo.exporter; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.SortedMap; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.util.zip.ZipOutputStream; - -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.view.AVMZipExporterService; -import org.apache.poi.util.IOUtils; - -/** - * Exporter which allows the saving of part of an AVM - * filesystem to a Zip file. - * - * @author Nick Burch - */ -public class AVMZipExporterServiceImpl implements AVMZipExporterService -{ - private AVMService avmService; - - /** - * Sets the AVM Service to be used for exporting from - * - * @param avmService The AVM Service - */ - public void setAvmService(AVMService avmService) - { - this.avmService = avmService; - } - - /** - * Exports the given path and version as a zip file, stored - * in the specified file. - * - * @param output The File to store the Zip in - * @param path The AVM path to export - * @param version The AVM version IO - * @param recurse Should the export recurse into directories? - */ - public void export(File output, int version, String path, boolean recurse) - throws IOException, ZipException - { - ZipOutputStream out = new ZipOutputStream(new FileOutputStream(output)); - export(out, version, path, recurse); - out.close(); - } - - /** - * Exports the given path and version into an already open - * Zip file. This method can be used to output multiple different - * AVM resources into one file. - * - * @param output The File to store the Zip in - * @param path The AVM path to export - * @param version The AVM version IO - * @param recurse Should the export recurse into directories? - */ - public void export(ZipOutputStream out, int version, String path, boolean recurse) - throws IOException, ZipException - { - AVMNodeDescriptor node = avmService.lookup(version, path); - export(out, node, recurse); - } - - /** - * Exports the given AVM node into an already open - * Zip file. This method can be used to output multiple different - * AVM resources into one file. - * - * @param output The File to store the Zip in - * @param node The AVM node to export - * @param recurse Should the export recurse into directories? - */ - public void export(ZipOutputStream out, AVMNodeDescriptor node, boolean recurse) - throws IOException, ZipException - { - // Create the zip entry - ZipEntry entry; - - // store:/foo/bar -> foo/bar/ - // store:/foo/baz.txt -> foo/baz.txt - String name = node.getPath().substring( - node.getPath().indexOf(':') + 1 - ).substring(1); - if(node.isDirectory()) { - entry = new ZipEntry(name + "/"); - } else { - entry = new ZipEntry(name); - } - out.putNextEntry(entry); - - // Output the contents - if(node.isDirectory()) { - if(recurse) { - SortedMap contents = - avmService.getDirectoryListing(node); - for(AVMNodeDescriptor child : contents.values()) { - export(out, child, recurse); - } - } - } else { - InputStream stream = avmService.getFileInputStream(node); - IOUtils.copy(stream, out); - } - } -} diff --git a/source/java/org/alfresco/repo/importer/AVMImporter.java b/source/java/org/alfresco/repo/importer/AVMImporter.java deleted file mode 100644 index 6815437c3e..0000000000 --- a/source/java/org/alfresco/repo/importer/AVMImporter.java +++ /dev/null @@ -1,52 +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 . - */ -package org.alfresco.repo.importer; - -import java.io.IOException; -import java.io.InputStream; - -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; - -/** - * Importer which allows the loading of part of an AVM - * filesystem from external resources. - * - * @author Nick Burch - */ -public interface AVMImporter -{ - /** - * Imports the given path and version from the source data. - * - * @param input The stream to read from - * @param path The AVM path to import - * @param version The AVM version ID - */ - public void importNode(InputStream input, String path) - throws IOException; - - /** - * Imports the given AVM node from the source data. - * - * @param input The stream to read from - * @param node The AVM node to import - */ - public void importNode(InputStream input, AVMNodeDescriptor node) - throws IOException; -} diff --git a/source/java/org/alfresco/repo/importer/AVMZipBootstrap.java b/source/java/org/alfresco/repo/importer/AVMZipBootstrap.java deleted file mode 100644 index b121048e73..0000000000 --- a/source/java/org/alfresco/repo/importer/AVMZipBootstrap.java +++ /dev/null @@ -1,243 +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 . - */ -package org.alfresco.repo.importer; - -import java.util.zip.ZipFile; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.security.authentication.AuthenticationContext; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.PropertyCheck; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.context.ApplicationEvent; -import org.springframework.extensions.surf.util.AbstractLifecycleBean; - -/** - * A Bootstrap-time Importer which allows the loading - * of part of an AVM filesystem from a Zip file - * - * @author Nick Burch - */ -public class AVMZipBootstrap extends AbstractLifecycleBean -{ - // Logger - private static final Log logger = LogFactory.getLog(AVMZipBootstrap.class); - - private TransactionService transactionService; - private RetryingTransactionHelper retryingTransactionHelper; - private NodeService nodeService; - private AuthenticationContext authenticationContext; - private AVMService avmService; - private AVMZipImporter avmZipImporter; - - private boolean allowWrite = true; - private String location; - private String avmRoot; - - /** - * Set whether we write or not - * - * @param write true (default) if the import must go ahead, otherwise no import will occur - */ - public void setAllowWrite(boolean write) - { - this.allowWrite = write; - } - - /** - * Sets the Root of the AVM store to import to. - */ - public void setAvmRoot(String avmRoot) - { - this.avmRoot = avmRoot; - } - - /** - * Sets the location of the zip file to import from - */ - public void setLocation(String location) - { - this.location = location; - } - - /** - * Sets the AVM Importer to be used for importing to - * - * @param avmZipImporter The AVM Importer Service - */ - public void setAvmZipImporter(AVMZipImporter avmZipImporter) - { - this.avmZipImporter = avmZipImporter; - } - - /** - * Sets the AVM Service to be used for exporting from - * - * @param avmService The AVM Service - */ - public void setAvmService(AVMService avmService) - { - this.avmService = avmService; - } - - /** - * Sets the Transaction Service - * - * @param userTransaction the transaction service - */ - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - /** - * Sets the retrying transaction helper specific to the importer bootstrap. This transaction helper's parameters are - * tuned to the longer-running import transaction. - * - * @param retryingTransactionHelper - * the retrying transaction helper - */ - public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) - { - this.retryingTransactionHelper = retryingTransactionHelper; - } - - /** - * Sets the node service - * - * @param nodeService the node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Set the authentication component - * - * @param authenticationContext - */ - public void setAuthenticationContext(AuthenticationContext authenticationContext) - { - this.authenticationContext = authenticationContext; - } - - /** - * Bootstrap the Repository - */ - public void bootstrap() - { - PropertyCheck.mandatory(this, "avmZipImporter", avmZipImporter); - PropertyCheck.mandatory(this, "retryingTransactionHelper", retryingTransactionHelper); - PropertyCheck.mandatory(this, "nodeService", nodeService); - - if (avmRoot == null) - { - if (logger.isDebugEnabled()) - { - logger.debug("No AVM Root URL - bootstrap import ignored"); - } - return; - } - - if (location == null) - { - if (logger.isDebugEnabled()) - { - logger.debug("No Location given to import from - bootstrap import ignored"); - } - return; - } - - try - { - // import the content - note: in MT case, this will run in System context of tenant domain - RunAsWork importRunAs = new RunAsWork() - { - public Object doWork() throws Exception - { - RetryingTransactionCallback doImportCallback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - doImport(); - return null; - } - }; - return retryingTransactionHelper.doInTransaction(doImportCallback, transactionService.isReadOnly(), false); - } - }; - AuthenticationUtil.runAs(importRunAs, authenticationContext.getSystemUserName()); - } - catch(Throwable e) - { - throw new AlfrescoRuntimeException("Bootstrap failed", e); - } - } - - /** - * Perform the actual import work. This is just separated to allow for simpler TXN demarcation. - */ - private void doImport() throws Throwable - { - if (!allowWrite) - { - // we're in read-only node - logger.warn("Skipping import as read-only: " + avmRoot); - } - else - { - // Create the store if necessary - String store = avmRoot.substring(0, avmRoot.indexOf(':')); - if(avmService.getStore(store) == null) - { - avmService.createStore(store); - } - - logger.debug("Bootstrapping AVM data from " + location + " to " + avmRoot); - - // Open the Zip - ZipFile zip = new ZipFile( - ImporterBootstrap.getFile(location) - ); - - // Now do the import - avmZipImporter.importNodes(zip, avmRoot); - } - } - - @Override - protected void onBootstrap(ApplicationEvent event) - { - bootstrap(); - } - - @Override - protected void onShutdown(ApplicationEvent event) - { - // NOOP - } -} diff --git a/source/java/org/alfresco/repo/importer/AVMZipImporter.java b/source/java/org/alfresco/repo/importer/AVMZipImporter.java deleted file mode 100644 index ef555026de..0000000000 --- a/source/java/org/alfresco/repo/importer/AVMZipImporter.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * 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 . - */ -package org.alfresco.repo.importer; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Enumeration; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.util.zip.ZipFile; - -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.avm.AVMService; -import org.alfresco.service.cmr.avm.AVMStoreDescriptor; -import org.alfresco.service.cmr.avm.AVMWrongTypeException; -import org.apache.poi.util.IOUtils; - -/** - * Importer which allows the loading of part of an AVM - * filesystem from a Zip file, typically called at - * boostrap time. - * - * @author Nick Burch - */ -public class AVMZipImporter implements AVMImporter -{ - private AVMService avmService; - - /** - * Sets the AVM Service to be used for importing to - * - * @param avmService The AVM Service - */ - public void setAvmService(AVMService avmService) - { - this.avmService = avmService; - } - - /** - * Imports all the entries in the Zip File into - * the AVM store. - * @param storePath The full store path, eg stores:/alfresco/foo/ - */ - public void importNodes(ZipFile zip, String storePath) throws IOException, ZipException - { - String store = storePath; - String path = null; - - int splitAt = storePath.indexOf(':'); - if(splitAt != -1) { - store = storePath.substring(0, splitAt); - path = storePath.substring(splitAt+1); - } - - AVMStoreDescriptor avmStore = avmService.getStore(store); - if(avmStore == null) - { - throw new IllegalArgumentException("No AVM store found with name " + store); - } - - importNodes(zip, avmStore, path); - } - - /** - * Imports all the entries in the Zip File into - * the AVM store. - * @param avmStore The AVM Store to import into - * @param storePath Where in the AVM store to unpack into - */ - @SuppressWarnings("unchecked") - public void importNodes(ZipFile zip, AVMStoreDescriptor avmStore, String storePath) throws IOException, ZipException - { - if(avmStore == null) - { - throw new IllegalArgumentException("An AVM Store must be supplied"); - } - - // Normalise the store path - if(storePath == null) { - storePath = "/"; - } - if(! storePath.startsWith("/")) { - storePath = "/" + storePath; - } - if(! storePath.endsWith("/")) { - storePath = storePath + "/"; - } - - // Process the zip file - Enumeration entries = (Enumeration) zip.entries(); - while(entries.hasMoreElements()) - { - // Grab the entry, and build the AVM path for it - ZipEntry entry = entries.nextElement(); - String relativeName = entry.getName(); - if(relativeName.startsWith("/")) { - relativeName = relativeName.substring(1); - } - String avmName = storePath + relativeName; - - // Import in the appropriate way for the file - if(entry.isDirectory()) - { - ensureDirectory(avmStore, avmName); - } - else - { - String dir = avmName.substring(0, avmName.lastIndexOf('/') + 1); - ensureDirectory(avmStore, dir); - - String avmPath = avmStore.getName() + ":" + avmName; - importNode(zip.getInputStream(entry), avmPath); - } - } - } - - /** - * Recursively creates directories in AVM as required - */ - protected void ensureDirectory(AVMStoreDescriptor store, String name) - { - if(! name.endsWith("/")) { - throw new IllegalArgumentException(name + " isn't a directory"); - } else { - name = name.substring(0, name.length()-1); - } - if(! name.startsWith("/")) { - // Make it absolute - name = "/" + name; - } - if(name.equals("/")) { - throw new IllegalArgumentException("Can't create a store"); - } - - // Build up the AVM path - int splitAt = name.lastIndexOf('/'); - String avmPath = store.getName() + ":" + name.substring(0, splitAt); - String avmName = name.substring(splitAt+1); - - try { - avmService.createDirectory(avmPath, avmName); - } catch(AVMNotFoundException nfe) { - // Recurse - String parent = name.substring(0, splitAt+1); - ensureDirectory(store, parent); - // And re-do - avmService.createDirectory(avmPath, avmName); - } catch(AVMExistsException exists) { - // Already there - } catch(AVMWrongTypeException wte) { - // Currently there, but not a directory... - throw wte; - } - } - - /** - * Imports the given path and version from the source data. - * - * @param input The stream to read from - * @param path The AVM path to import - */ - public void importNode(InputStream input, String path) - throws IOException - { - try - { - OutputStream out = avmService.getFileOutputStream(path); - IOUtils.copy(input, out); - } - catch(AVMNotFoundException e) - { - int splitAt = path.lastIndexOf('/'); - String avmPath = path.substring(0, splitAt); - String avmName = path.substring(splitAt+1); - avmService.createFile(avmPath, avmName, input); - } - } - - /** - * Imports the given AVM node from the source data. - * - * @param input The stream to read from - * @param node The AVM node to import - */ - public void importNode(InputStream input, AVMNodeDescriptor node) - throws IOException - { - OutputStream out = avmService.getFileOutputStream(node.getPath()); - IOUtils.copy(input, out); - } -} diff --git a/source/java/org/alfresco/repo/jscript/AVM.java b/source/java/org/alfresco/repo/jscript/AVM.java deleted file mode 100644 index e15d61f643..0000000000 --- a/source/java/org/alfresco/repo/jscript/AVM.java +++ /dev/null @@ -1,245 +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 . - */ -package org.alfresco.repo.jscript; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.config.JNDIConstants; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMStoreDescriptor; -import org.springframework.extensions.surf.util.ParameterCheck; -import org.alfresco.wcm.asset.AssetInfo; -import org.alfresco.wcm.sandbox.SandboxService; -import org.alfresco.wcm.util.WCMUtil; -import org.mozilla.javascript.Context; -import org.mozilla.javascript.Scriptable; - -/** - * Helper to access AVM nodes from a script context. - * - * @author Kevin Roast - */ -public final class AVM extends BaseScopableProcessorExtension -{ - /** Repository Service Registry */ - private ServiceRegistry services; - - /** - * Set the service registry - * - * @param serviceRegistry the service registry - */ - public void setServiceRegistry(ServiceRegistry serviceRegistry) - { - this.services = serviceRegistry; - } - - /** - * @return a array of all AVM stores in the system - */ - public Scriptable getStores() - { - List stores = this.services.getAVMService().getStores(); - Object[] results = new Object[stores.size()]; - int i=0; - for (AVMStoreDescriptor store : stores) - { - results[i++] = new AVMScriptStore(this.services, store, getScope()); - } - return Context.getCurrentContext().newArray(getScope(), results); - } - - /** - * Return an AVM store object for the specified store name - * - * @param store Store name to lookup - * - * @return the AVM store object for the specified store or null if not found - */ - public AVMScriptStore lookupStore(String store) - { - ParameterCheck.mandatoryString("Store", store); - AVMScriptStore avmStore = null; - AVMStoreDescriptor descriptor = this.services.getAVMService().getStore(store); - if (descriptor != null) - { - avmStore = new AVMScriptStore(this.services, descriptor, getScope()); - } - return avmStore; - } - - /** - * Return an AVM Node representing the public store root folder. - * - * @param store Store name to lookup root folder for - * - * @return AVM Node representing the public store root folder, or null if not found. - */ - public AVMNode lookupStoreRoot(String store) - { - AVMNode rootNode = null; - if (store != null && store.length() != 0) - { - String rootPath = store + ':' + getWebappsFolderPath(); - AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, rootPath); - if (nodeDesc != null) - { - rootNode = new AVMNode(AVMNodeConverter.ToNodeRef(-1, rootPath), this.services, getScope()); - } - } - return rootNode; - } - - /** - * Return an AVM Node for the fully qualified path. - * - * @param path Fully qualified path to node to lookup - * - * @return AVM Node for the fully qualified path, or null if not found. - */ - public AVMNode lookupNode(String path) - { - AVMNode node = null; - if (path != null && path.length() != 0) - { - AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, path); - if (nodeDesc != null) - { - node = new AVMNode(AVMNodeConverter.ToNodeRef(-1, path), this.services, getScope()); - } - } - return node; - } - - /** - * Return the list of modified items for the specified user sandbox against staging store id - * for a specific webapp. - * - * @param storeId Root Store ID - * @param username Username to get modified items for - * @param webapp Webapp name to filter by - * - * @return List of AVMNode objects representing the modified items - */ - public List getModifiedItems(String storeId, String username, String webapp) - { - ParameterCheck.mandatoryString("Store ID", storeId); - ParameterCheck.mandatoryString("Username", username); - ParameterCheck.mandatoryString("Webapp", webapp); - - SandboxService sbService = this.services.getSandboxService(); - - String userStoreId = userSandboxStore(storeId, username); - - // get modified items - not including deleted - List assets = sbService.listChangedWebApp(userStoreId, webapp, false); - - List items = new ArrayList(assets.size()); - - for (AssetInfo asset : assets) - { - // convert each diff/node record into an AVM Node wrapper - items.add(new AVMNode(asset.getAvmPath(), -1, this.services, getScope())); - } - - return items; - } - - /** - * @param storeId Store ID to build staging store name for - * - * @return the Staging Store name for the given store ID - */ - public static String stagingStore(String storeId) - { - return WCMUtil.buildStagingStoreName(storeId); - } - - /** - * @param storeId Store ID to build sandbox store name for - * @param username Username of the sandbox user - * - * @return the Sandbox Store name for the given store ID and username - */ - public static String userSandboxStore(String storeId, String username) - { - return WCMUtil.buildUserMainStoreName(storeId, username); - } - - /** - * @param storeId Store ID to build preview URL for - * - * @return the preview URL to the staging store for the specified store ID - */ - public String websiteStagingUrl(String storeId) - { - return this.services.getPreviewURIService().getPreviewURI(storeId, null); - } - - /** - * @param storeId Store ID to build preview URL for - * @param username Username to build sandbox preview URL for - * - * @return the preview URL to the user sandbox for the specified store ID and username - */ - public String websiteUserSandboxUrl(String storeId, String username) - { - ParameterCheck.mandatoryString("Store ID", storeId); - ParameterCheck.mandatoryString("Username", username); - return websiteStagingUrl(userSandboxStore(storeId, username)); - } - - /** - * @param store Store ID of the asset - * @param assetPath Store relative path to the asset - * - * @return the preview URL to the specified store asset - */ - public String assetUrl(String storeId, String assetPath) - { - return this.services.getPreviewURIService().getPreviewURI(storeId, assetPath); - } - - /** - * @param avmPath Fully qualified AVM path of the asset - * - * @return the preview URL to the specified asset - */ - public String assetUrl(String avmPath) - { - ParameterCheck.mandatoryString("AVM Path", avmPath); - String[] s = avmPath.split(":"); - if (s.length != 2) - { - throw new IllegalArgumentException("Expected exactly one ':' in " + avmPath); - } - return assetUrl(s[0], s[1]); - } - - /** - * @return the path to the webapps folder in a standard web store. - */ - public static String getWebappsFolderPath() - { - return JNDIConstants.DIR_DEFAULT_WWW_APPBASE; - } -} diff --git a/source/java/org/alfresco/repo/jscript/AVMNode.java b/source/java/org/alfresco/repo/jscript/AVMNode.java deleted file mode 100644 index c88bd54a5d..0000000000 --- a/source/java/org/alfresco/repo/jscript/AVMNode.java +++ /dev/null @@ -1,366 +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 . - */ -package org.alfresco.repo.jscript; - -import java.util.Set; - -import org.alfresco.model.WCMModel; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; -import org.mozilla.javascript.Scriptable; -import org.springframework.extensions.surf.util.ParameterCheck; - -/** - * Represents a AVM specific node in the Script context. Provides specific implementations - * of AVM specific methods such as copy, move, rename etc. - * - * @author Kevin Roast - */ -public class AVMNode extends ScriptNode -{ - private String path; - private int version; - private boolean deleted; - private AVMNodeDescriptor avmRef; - private QName type; - - - public AVMNode(NodeRef nodeRef, ServiceRegistry services) - { - this(nodeRef, services, null); - } - - public AVMNode(NodeRef nodeRef, ServiceRegistry services, Scriptable scope) - { - super(nodeRef, services, scope); - - Pair versionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - init(versionPath.getSecond(), versionPath.getFirst()); - } - - public AVMNode(String path, int version, ServiceRegistry services, Scriptable scope) - { - super(AVMNodeConverter.ToNodeRef(version, path), services, scope); - - init(path, version); - } - - private void init(String path, int version) - { - this.path = path; - this.version = version; - AVMNodeDescriptor descriptor = this.services.getAVMService().lookup(version, path, true); - if (descriptor == null) - { - throw new IllegalArgumentException("Invalid node specified: " + this.nodeRef.toString()); - } - this.avmRef = descriptor; - this.deleted = descriptor.isDeleted(); - } - - /** - * Factory methods - */ - @Override - public ScriptNode newInstance(NodeRef nodeRef, ServiceRegistry services, Scriptable scope) - { - return new AVMNode(nodeRef, services, scope); - } - - public ScriptNode newInstance(String path, int version, ServiceRegistry services, Scriptable scope) - { - return new AVMNode(AVMNodeConverter.ToNodeRef(version, path), services, scope); - } - - // TODO: changing the 'name' property (either directly using .name or with .properties.name) - // invalidates the path and the base noderef instance! - // AVMService has a specific rename method - use this and block name property changes? - - /** - * @return the full AVM Path to this node - */ - public String getPath() - { - return this.path; - } - - public int getVersion() - { - return this.version; - } - - /** - * @return AVM path to the parent node - */ - public String getParentPath() - { - return AVMNodeConverter.SplitBase(this.path)[0]; - } - - /** - * @return QName type of this node - */ - public String getType() - { - if (this.type == null) - { - if (this.deleted == false) - { - this.type = this.services.getNodeService().getType(this.nodeRef); - } - else - { - this.type = avmRef.isDeletedDirectory() ? WCMModel.TYPE_AVM_FOLDER : WCMModel.TYPE_AVM_CONTENT; - } - } - - return type.toString(); - } - - public boolean isDirectory() - { - return this.avmRef.isDirectory() || this.avmRef.isDeletedDirectory(); - } - - public boolean isFile() - { - return this.avmRef.isFile() || this.avmRef.isDeletedFile(); - } - - /** - * @return Helper to return the 'name' property for the node - */ - @Override - public String getName() - { - return this.avmRef.getName(); - } - - /** - * @return true if the node is currently locked - */ - public boolean getIsLocked() - { - String lockOwner = this.services.getAVMLockingService().getLockOwner( - getWebProject(), path.substring(path.indexOf("/"))); - return (lockOwner != null); - } - - /** - * @return true if this node is locked and the current user is the lock owner - */ - public boolean isLockOwner() - { - String lockOwner = this.services.getAVMLockingService().getLockOwner( - getWebProject(), path.substring(path.indexOf("/"))); - if (lockOwner != null) - { - return lockOwner.equals(this.services.getAuthenticationService().getCurrentUserName()); - } - else - { - return true; - } - } - - /** - * @return true if this user can perform operations on the node when locked. - * This is true if the item is either unlocked, or locked and the current user is the lock owner, - * or locked and the current user has Content Manager role in the associated web project. - */ - public boolean hasLockAccess() - { - return this.services.getAVMLockingService().hasAccess( - getWebProject(), path, this.services.getAuthenticationService().getCurrentUserName()); - } - - /** - * Copy this Node into a new parent destination. - * - * @param destination Parent node for the copy - * - * @return the copy of this node - */ - @Override - public ScriptNode copy(ScriptNode destination) - { - ParameterCheck.mandatory("Destination Node", destination); - - return getCrossRepositoryCopyHelper().copy(this, destination, getName()); - } - - /** - * Copy this Node into a new parent destination. - * - * @param destination Parent path for the copy - * - * @return the copy of this node - */ - public ScriptNode copy(String destination) - { - ParameterCheck.mandatoryString("Destination Path", destination); - - this.services.getAVMService().copy(this.version, this.path, destination, getName()); - return newInstance( - AVMNodeConverter.ToNodeRef(-1, AVMNodeConverter.ExtendAVMPath(destination, getName())), - this.services, this.scope); - } - - /** - * Move this Node to a new parent destination node. - * - * @param destination Node - * - * @return true on successful move, false on failure to move. - */ - @Override - public boolean move(ScriptNode destination) - { - ParameterCheck.mandatory("Destination Node", destination); - - boolean success = false; - - if (destination instanceof AVMNode) - { - success = move(((AVMNode)destination).getPath()); - } - - return success; - } - - /** - * Move this Node to a new parent destination path. - * - * @param destination Path - * - * @return true on successful move, false on failure to move. - */ - public boolean move(String destination) - { - ParameterCheck.mandatoryString("Destination Path", destination); - - boolean success = false; - - if (destination != null && destination.length() != 0) - { - AVMNode parent = (AVMNode)this.getParent(); - this.services.getAVMService().rename( - parent.getPath(), getName(), destination, getName()); - - reset(AVMNodeConverter.ExtendAVMPath(destination, getName())); - - success = true; - } - - return success; - } - - /** - * Rename this node to the specified name - * - * @param name New name for the node - * - * @return true on success, false otherwise - */ - public boolean rename(String name) - { - ParameterCheck.mandatoryString("Destination name", name); - - boolean success = false; - - if (name != null && name.length() != 0) - { - String parentPath = ((AVMNode)this.getParent()).getPath(); - this.services.getAVMService().rename( - parentPath, getName(), parentPath, name); - - reset(AVMNodeConverter.ExtendAVMPath(parentPath, name)); - - success = true; - } - - return success; - } - - /** - * @return The list of aspects applied to this node - */ - @Override - public Set getAspectsSet() - { - if (this.aspects == null) - { - this.aspects = this.services.getAVMService().getAspects(this.version, this.path); - } - - return this.aspects; - } - - /** - * Reset the Node cached state - */ - private void reset(String path) - { - super.reset(); - this.path = path; - this.nodeRef = AVMNodeConverter.ToNodeRef(this.version, path); - this.id = nodeRef.getId(); - AVMNodeDescriptor descriptor = this.services.getAVMService().lookup(this.version, path, true); - if (descriptor == null) - { - throw new IllegalArgumentException("Invalid node specified: " + nodeRef.toString()); - } - this.avmRef = descriptor; - this.deleted = descriptor.isDeleted(); - } - - /** - * @return the WebProject identifier for the current path - */ - private String getWebProject() - { - String webProject = this.path.substring(0, this.path.indexOf(':')); - int index = webProject.indexOf("--"); - if (index != -1) - { - webProject = webProject.substring(0, index); - } - return webProject; - } - - @Override - public String toString() - { - if (this.services.getAVMService().lookup(version, this.path) != null) - { - return "AVM Path: " + getPath() + - "\nNode Type: " + getType() + - "\nNode Properties: " + this.getProperties().size() + - "\nNode Aspects: " + this.getAspectsSet().toString(); - } - else - { - return "Node no longer exists: " + nodeRef; - } - } -} diff --git a/source/java/org/alfresco/repo/jscript/AVMScriptStore.java b/source/java/org/alfresco/repo/jscript/AVMScriptStore.java deleted file mode 100644 index 7d7011f0bf..0000000000 --- a/source/java/org/alfresco/repo/jscript/AVMScriptStore.java +++ /dev/null @@ -1,186 +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 . - */ -package org.alfresco.repo.jscript; - -import java.io.Serializable; -import java.util.Date; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.repo.template.AVM; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMStoreDescriptor; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.ResultSetRow; -import org.alfresco.service.cmr.search.SearchService; -import org.mozilla.javascript.Context; -import org.mozilla.javascript.Scriptable; - -/** - * @author Kevin Roast - */ -public class AVMScriptStore implements Serializable -{ - private ServiceRegistry services; - private AVMStoreDescriptor descriptor; - private Scriptable scope; - - /** - * Constructor - * - * @param services - * @param store Store descriptor this object represents - * @param scope - */ - public AVMScriptStore(ServiceRegistry services, AVMStoreDescriptor store, Scriptable scope) - { - this.descriptor = store; - this.services = services; - this.scope = scope; - } - - /** - * @return Store name - */ - public String getName() - { - return this.descriptor.getName(); - } - - /** - * @return Store name - */ - public String getId() - { - return this.descriptor.getName(); - } - - /** - * @return User who created the store - */ - public String getCreator() - { - return this.descriptor.getCreator(); - } - - /** - * @return Creation date of the store - */ - public Serializable getCreatedDate() - { - return new ValueConverter().convertValueForScript( - this.services, this.scope, null, new Date(this.descriptor.getCreateDate())); - } - - /** - * @return the root node of all webapps in the store - */ - public AVMNode lookupRoot() - { - AVMNode rootNode = null; - String rootPath = this.descriptor.getName() + ':' + AVM.getWebappsFolderPath(); - AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, rootPath); - if (nodeDesc != null) - { - rootNode = new AVMNode(AVMNodeConverter.ToNodeRef(-1, rootPath), this.services, this.scope); - } - return rootNode; - } - - /** - * Lookup a node in the store, the path is assumed to be related to the webapps folder root. - * Therefore a valid path would be "/ROOT/WEB-INF/lib/web.xml". - * - * @param path Relative to the webapps folder root path for this store. - * - * @return node if found, null otherwise. - */ - public AVMNode lookupNode(String path) - { - AVMNode node = null; - if (path != null && path.length() != 0) - { - if (path.charAt(0) != '/') - { - path = '/' + path; - } - path = this.descriptor.getName() + ':' + AVM.getWebappsFolderPath() + path; - AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, path); - if (nodeDesc != null) - { - node = new AVMNode(path, -1, this.services, this.scope); - } - } - return node; - } - - /** - * Perform a lucene query against this store. - * - * @param query Lucene - * - * @return array of AVM node object results - empty array if no results found - */ - public Scriptable luceneSearch(String query) - { - Object[] nodes = null; - - // perform the search against the repo - ResultSet results = null; - try - { - results = this.services.getSearchService().query( - new StoreRef(StoreRef.PROTOCOL_AVM, this.descriptor.getName()), - SearchService.LANGUAGE_LUCENE, - query); - - if (results.length() != 0) - { - nodes = new Object[results.length()]; - for (int i=0; i. - */ -package org.alfresco.repo.jscript; - -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.util.Pair; -import org.springframework.extensions.surf.util.ParameterCheck; -import org.mozilla.javascript.Scriptable; - -/** - * Helper bean to access Cross Repository copy services from a script context. - * - * @author Kevin Roast - */ -public final class CrossRepositoryCopy extends BaseScopableProcessorExtension -{ - public final static String BEAN_NAME = "crossCopyScript"; - - /** Service registry */ - private ServiceRegistry services; - - /** - * Set the service registry - * - * @param services the service registry - */ - public void setServiceRegistry(ServiceRegistry services) - { - this.services = services; - } - - /** - * Perform a copy of a source node to the specified parent destination node. The name will - * be applied to the destination node copy. - *

- * Inter-store copy operations between Workspace and AVM and visa-versa are supported. - * - * @param src Source node instance - * @param dest Destination parent node instance - * @param name Name of the node copy - * - * @return node representing the copy if successful, null on unsupported store type. - * - * @throws org.alfresco.error.AlfrescoRuntimeException on copy error - */ - public ScriptNode copy(ScriptNode src, ScriptNode dest, String name) - { - ParameterCheck.mandatory("Node source", src); - ParameterCheck.mandatory("Node destination", dest); - ParameterCheck.mandatory("Node destination name", name); - - ScriptNode result = null; - - // perform the copy operation using the repository service - this.services.getCrossRepositoryCopyService().copy(src.getNodeRef(), dest.getNodeRef(), name); - - // if we get here then copy succeeded - retrieve the new node reference - if (dest.getNodeRef().getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) - { - Pair versionPath = AVMNodeConverter.ToAVMVersionPath(dest.getNodeRef()); - String destPath = AVMNodeConverter.ExtendAVMPath(versionPath.getSecond(), name); - AVMNodeDescriptor node = this.services.getAVMService().lookup(-1, destPath); - if (node != null) - { - result = ((AVMNode)dest).newInstance(destPath, -1, this.services, getScope()); - } - } - else if (dest.getNodeRef().getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_WORKSPACE)) - { - result = dest.childByNamePath(name); - } - - return result; - } -} diff --git a/source/java/org/alfresco/repo/jscript/ScriptNode.java b/source/java/org/alfresco/repo/jscript/ScriptNode.java index c649e4280a..623767e2ad 100644 --- a/source/java/org/alfresco/repo/jscript/ScriptNode.java +++ b/source/java/org/alfresco/repo/jscript/ScriptNode.java @@ -85,7 +85,6 @@ import org.alfresco.service.cmr.repository.NoTransformerException; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.Path; -import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.TemplateImageResolver; import org.alfresco.service.cmr.repository.TransformationOptions; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; @@ -2033,19 +2032,9 @@ public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider { ParameterCheck.mandatory("Destination Node", destination); - ScriptNode copy = null; - - if (destination.getNodeRef().getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_WORKSPACE)) - { - NodeRef copyRef = this.services.getCopyService().copyAndRename(this.nodeRef, destination.getNodeRef(), - ContentModel.ASSOC_CONTAINS, null, deepCopy); - copy = newInstance(copyRef, this.services, this.scope); - } - else - { - // NOTE: the deepCopy flag is not respected for this copy mechanism - copy = getCrossRepositoryCopyHelper().copy(this, destination, getName()); - } + NodeRef copyRef = this.services.getCopyService().copyAndRename(this.nodeRef, destination.getNodeRef(), + ContentModel.ASSOC_CONTAINS, null, deepCopy); + ScriptNode copy = newInstance(copyRef, this.services, this.scope); return copy; } @@ -3502,15 +3491,6 @@ public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider this.siteNameResolved = false; } - /** - * @return helper object to perform cross repository copy of JavaScript Node objects - */ - protected CrossRepositoryCopy getCrossRepositoryCopyHelper() - { - return (CrossRepositoryCopy)this.services.getService( - QName.createQName("", CrossRepositoryCopy.BEAN_NAME)); - } - /** * Return a list or a single Node from executing an xpath against the parent Node. * diff --git a/source/java/org/alfresco/repo/model/Repository.java b/source/java/org/alfresco/repo/model/Repository.java index 56505bc670..fa8ea2f564 100644 --- a/source/java/org/alfresco/repo/model/Repository.java +++ b/source/java/org/alfresco/repo/model/Repository.java @@ -24,14 +24,11 @@ import java.util.List; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; -import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.model.FileInfo; import org.alfresco.service.cmr.model.FileNotFoundException; @@ -41,8 +38,6 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.namespace.NamespaceService; -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; @@ -65,7 +60,6 @@ public class Repository implements ApplicationContextAware private NodeService nodeService; private FileFolderService fileFolderService; private PersonService personService; - private AVMService avmService; // company home private StoreRef companyHomeStore; // ie. workspace://SpaceStore @@ -149,14 +143,6 @@ public class Repository implements ApplicationContextAware this.personService = personService; } - /** - * Sets the AVM service - */ - public void setAvmService(AVMService avmService) - { - this.avmService = avmService; - } - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { lifecycle.setApplicationContext(applicationContext); @@ -330,137 +316,93 @@ public class Repository implements ApplicationContextAware *
* Resolve to node via its display path. *
- * 3) AVM Path - {store_id}/{path} - *
- * Resolve to AVM node via its display path - *
- * 4) QName - {store_type}/{store_id}/{child_qname_path} TODO: Implement + * 3) QName - {store_type}/{store_id}/{child_qname_path} TODO: Implement *
* Resolve to node via its child qname path. * - * @param referenceType one of node, path, avmpath or qname + * @param referenceType one of node, path or qname * @return reference array of reference segments (as described above for each reference type) */ public NodeRef findNodeRef(String referenceType, String[] reference) { NodeRef nodeRef = null; - if (referenceType.equals("avmpath")) + // construct store reference + if (reference.length < 3) { - if (reference.length == 0) - { - throw new AlfrescoRuntimeException("Reference " + Arrays.toString(reference) + " is not properly formed"); - } - String path = reference[0] + ":/"; - if (reference.length > 1) - { - Object[] pathElements = ArrayUtils.subarray(reference, 1, reference.length); - path += StringUtils.join(pathElements, "/"); - } - AVMNodeDescriptor nodeDesc = avmService.lookup(-1, path); - if (nodeDesc != null) - { - nodeRef = AVMNodeConverter.ToNodeRef(-1, path); - } + throw new AlfrescoRuntimeException("Reference " + Arrays.toString(reference) + " is not properly formed"); } - else + StoreRef storeRef = new StoreRef(reference[0], reference[1]); + if (nodeService.exists(storeRef)) { - // construct store reference - if (reference.length < 3) + if (referenceType.equals("node")) { - throw new AlfrescoRuntimeException("Reference " + Arrays.toString(reference) + " is not properly formed"); - } - StoreRef storeRef = new StoreRef(reference[0], reference[1]); - if (nodeService.exists(storeRef)) - { - if (referenceType.equals("node")) + // find the node the rest of the path is relative to + NodeRef relRef = new NodeRef(storeRef, reference[2]); + if (nodeService.exists(relRef)) { - // find the node the rest of the path is relative to - NodeRef relRef = new NodeRef(storeRef, reference[2]); - if (nodeService.exists(relRef)) + // are there any relative path elements to process? + if (reference.length == 3 || reference.length == 4) { - // are there any relative path elements to process? - if (reference.length == 3 || reference.length == 4) - { - // just the NodeRef can be specified - nodeRef = relRef; - } - else - { - // process optional path elements - List paths = new ArrayList(reference.length - 3); - for (int i=3; i 2) - { - Object[] pathElements = ArrayUtils.subarray(reference, 2, reference.length); - path += StringUtils.join(pathElements, "/"); - } - AVMNodeDescriptor nodeDesc = avmService.lookup(-1, path); - if (nodeDesc != null) - { - nodeRef = AVMNodeConverter.ToNodeRef(-1, path); - } + // just the NodeRef can be specified + nodeRef = relRef; } else { - // TODO: Allow a root path to be specified - for now, hard-code to Company Home - //NodeRef rootNodeRef = nodeService.getRootNode(storeRef); - NodeRef rootNodeRef = getCompanyHome(); - if (reference.length == 3) + // process optional path elements + List paths = new ArrayList(reference.length - 3); + for (int i=3; i. - */ -package org.alfresco.repo.remote; - -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.service.cmr.avm.AVMNodeDescriptor; -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.remote.AVMRemote; -import org.alfresco.service.cmr.remote.AVMRemoteTransport; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; - -/** - * Client side wrapper for AVMRemoteTransport. - * @author britt - */ -public class AVMRemoteImpl implements AVMRemote -{ - /** - * The reference to the AVMRemoteTransport instance. - */ - private AVMRemoteTransport fTransport; - - /** - * The client ticket holder. - */ - private ClientTicketHolder fTicketHolder; - - /** - * Default constructor. - */ - public AVMRemoteImpl() - { - } - - /** - * Set the remote transport. - */ - public void setAvmRemoteTransport(AVMRemoteTransport transport) - { - fTransport = transport; - } - - public void setClientTicketHolder(ClientTicketHolder ticketHolder) - { - fTicketHolder = ticketHolder; - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#createAVMStore(java.lang.String) - */ - public void createStore(String name) - { - fTransport.createStore(fTicketHolder.getTicket(), name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#createBranch(int, java.lang.String, java.lang.String, java.lang.String) - */ - public void createBranch(int version, String srcPath, String dstPath, - String name) - { - fTransport.createBranch(fTicketHolder.getTicket(), version, - srcPath, dstPath, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#createDirectory(java.lang.String, java.lang.String) - */ - public void createDirectory(String path, String name) - { - fTransport.createDirectory(fTicketHolder.getTicket(), path, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#createFile(java.lang.String, java.lang.String) - */ - public OutputStream createFile(String path, String name) - { - return new AVMRemoteOutputStream(fTransport.createFile(fTicketHolder.getTicket(), path, name), fTransport, fTicketHolder); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#createLayeredDirectory(java.lang.String, java.lang.String, java.lang.String) - */ - public void createLayeredDirectory(String targetPath, String parent, - String name) - { - fTransport.createLayeredDirectory(fTicketHolder.getTicket(), targetPath, parent, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#createLayeredFile(java.lang.String, java.lang.String, java.lang.String) - */ - public void createLayeredFile(String targetPath, String parent, String name) - { - fTransport.createLayeredFile(fTicketHolder.getTicket(), targetPath, parent, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#createSnapshot(java.lang.String) - */ - public Map createSnapshot(String store, String label, String comment) - { - return fTransport.createSnapshot(fTicketHolder.getTicket(), store, label, comment); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#deleteNodeProperties(java.lang.String) - */ - public void deleteNodeProperties(String path) - { - fTransport.deleteNodeProperties(fTicketHolder.getTicket(), path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#deleteNodeProperty(java.lang.String, org.alfresco.service.namespace.QName) - */ - public void deleteNodeProperty(String path, QName name) - { - fTransport.deleteNodeProperty(fTicketHolder.getTicket(), path, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#deleteStoreProperty(java.lang.String, org.alfresco.service.namespace.QName) - */ - public void deleteStoreProperty(String store, QName name) - { - fTransport.deleteStoreProperty(fTicketHolder.getTicket(), store, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getAVMStore(java.lang.String) - */ - public AVMStoreDescriptor getStore(String name) - { - return fTransport.getStore(fTicketHolder.getTicket(), name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getAVMStoreRoot(int, java.lang.String) - */ - public AVMNodeDescriptor getStoreRoot(int version, String name) - { - return fTransport.getStoreRoot(fTicketHolder.getTicket(), version, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getAVMStoreVersions(java.lang.String) - */ - public List getStoreVersions(String name) - { - return fTransport.getStoreVersions(fTicketHolder.getTicket(), name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getAVMStoreVersions(java.lang.String, java.util.Date, java.util.Date) - */ - public List getStoreVersions(String name, Date from, - Date to) - { - return fTransport.getStoreVersions(fTicketHolder.getTicket(), name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getAVMStores() - */ - public List getStores() - { - return fTransport.getStores(fTicketHolder.getTicket()); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getCommonAncestor(org.alfresco.service.cmr.avm.AVMNodeDescriptor, org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public AVMNodeDescriptor getCommonAncestor(AVMNodeDescriptor left, - AVMNodeDescriptor right) - { - return fTransport.getCommonAncestor(fTicketHolder.getTicket(), left, right); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getDeleted(int, java.lang.String) - */ - public List getDeleted(int version, String path) - { - return fTransport.getDeleted(fTicketHolder.getTicket(), version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getDirectoryListing(int, java.lang.String) - */ - public SortedMap getDirectoryListing( - int version, String path) - { - return fTransport.getDirectoryListing(fTicketHolder.getTicket(), version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getDirectoryListing(org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public SortedMap getDirectoryListing( - AVMNodeDescriptor dir) - { - return fTransport.getDirectoryListing(fTicketHolder.getTicket(), dir); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getDirectoryListingDirect(int, java.lang.String) - */ - public SortedMap getDirectoryListingDirect( - int version, String path) - { - return fTransport.getDirectoryListing(fTicketHolder.getTicket(), version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getFileInputStream(int, java.lang.String) - */ - public InputStream getFileInputStream(int version, String path) - { - return new AVMRemoteInputStream(fTransport.getInputHandle(fTicketHolder.getTicket(), version, path), - fTransport, fTicketHolder); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getFileInputStream(org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public InputStream getFileInputStream(AVMNodeDescriptor desc) - { - return new AVMRemoteInputStream(fTransport.getInputHandle(fTicketHolder.getTicket(), desc), - fTransport, fTicketHolder); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getFileOutputStream(java.lang.String) - */ - public OutputStream getFileOutputStream(String path) - { - return new AVMRemoteOutputStream(fTransport.getOutputHandle(fTicketHolder.getTicket(), path), - fTransport, fTicketHolder); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getHistory(org.alfresco.service.cmr.avm.AVMNodeDescriptor, int) - */ - public List getHistory(AVMNodeDescriptor desc, int count) - { - return fTransport.getHistory(fTicketHolder.getTicket(), desc, count); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getIndirectionPath(int, java.lang.String) - */ - public String getIndirectionPath(int version, String path) - { - return fTransport.getIndirectionPath(fTicketHolder.getTicket(), version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getLatestSnapshotID(java.lang.String) - */ - public int getLatestSnapshotID(String storeName) - { - return fTransport.getLatestSnapshotID(fTicketHolder.getTicket(), storeName); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getLatestVersionID(java.lang.String) - */ - public int getNextVersionID(String storeName) - { - return fTransport.getNextVersionID(fTicketHolder.getTicket(), storeName); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getLayeringInfo(int, java.lang.String) - */ - public LayeringDescriptor getLayeringInfo(int version, String path) - { - return fTransport.getLayeringInfo(fTicketHolder.getTicket(), version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getNodeProperties(int, java.lang.String) - */ - public Map getNodeProperties(int version, String path) - { - return fTransport.getNodeProperties(fTicketHolder.getTicket(), version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getNodeProperty(int, java.lang.String, org.alfresco.service.namespace.QName) - */ - public PropertyValue getNodeProperty(int version, String path, QName name) - { - return fTransport.getNodeProperty(fTicketHolder.getTicket(), version, path, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getStoreProperties(java.lang.String) - */ - public Map getStoreProperties(String store) - { - return fTransport.getStoreProperties(fTicketHolder.getTicket(), store); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#getStoreProperty(java.lang.String, org.alfresco.service.namespace.QName) - */ - public PropertyValue getStoreProperty(String store, QName name) - { - return fTransport.getStoreProperty(fTicketHolder.getTicket(), store, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#lookup(int, java.lang.String) - */ - public AVMNodeDescriptor lookup(int version, String path) - { - return fTransport.lookup(fTicketHolder.getTicket(), version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#lookup(int, java.lang.String, boolean) - */ - public AVMNodeDescriptor lookup(int version, String path, boolean includeDeleted) - { - return fTransport.lookup(fTicketHolder.getTicket(), version, path, includeDeleted); - } - - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#lookup(org.alfresco.service.cmr.avm.AVMNodeDescriptor, java.lang.String) - */ - public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name) - { - return fTransport.lookup(fTicketHolder.getTicket(), dir, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#lookup(org.alfresco.service.cmr.avm.AVMNodeDescriptor, java.lang.String, boolean includeDeleted) - */ - public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name, boolean includeDeleted) - { - return fTransport.lookup(fTicketHolder.getTicket(), dir, name, includeDeleted); - } - - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#makePrimary(java.lang.String) - */ - public void makePrimary(String path) - { - fTransport.makePrimary(fTicketHolder.getTicket(), path); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#purgeAVMStore(java.lang.String) - */ - public void purgeStore(String name) - { - fTransport.purgeStore(fTicketHolder.getTicket(), name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#purgeVersion(int, java.lang.String) - */ - public void purgeVersion(int version, String name) - { - fTransport.purgeVersion(fTicketHolder.getTicket(), version, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#queryStorePropertyKey(java.lang.String, org.alfresco.service.namespace.QName) - */ - public Map queryStorePropertyKey(String store, - QName keyPattern) - { - return fTransport.queryStorePropertyKey(fTicketHolder.getTicket(), store, keyPattern); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#queryStoresPropertyKey(org.alfresco.service.namespace.QName) - */ - public Map> queryStoresPropertyKey( - QName keyPattern) - { - return fTransport.queryStoresPropertyKey(fTicketHolder.getTicket(), keyPattern); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#removeNode(java.lang.String, java.lang.String) - */ - public void removeNode(String parent, String name) - { - fTransport.removeNode(fTicketHolder.getTicket(), parent, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#rename(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - public void rename(String srcParent, String srcName, String dstParent, - String dstName) - { - fTransport.rename(fTicketHolder.getTicket(), srcParent, srcName, dstParent, dstName); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#retargetLayeredDirectory(java.lang.String, java.lang.String) - */ - public void retargetLayeredDirectory(String path, String target) - { - fTransport.retargetLayeredDirectory(fTicketHolder.getTicket(), path, target); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#setNodeProperties(java.lang.String, java.util.Map) - */ - public void setNodeProperties(String path, - Map properties) - { - fTransport.setNodeProperties(fTicketHolder.getTicket(), path, properties); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#setNodeProperty(java.lang.String, org.alfresco.service.namespace.QName, org.alfresco.repo.domain.PropertyValue) - */ - public void setNodeProperty(String path, QName name, PropertyValue value) - { - fTransport.setNodeProperty(fTicketHolder.getTicket(), path, name, value); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#setOpacity(java.lang.String, boolean) - */ - public void setOpacity(String path, boolean opacity) - { - fTransport.setOpacity(fTicketHolder.getTicket(), path, opacity); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#setStoreProperties(java.lang.String, java.util.Map) - */ - public void setStoreProperties(String store, Map props) - { - fTransport.setStoreProperties(fTicketHolder.getTicket(), store, props); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#setStoreProperty(java.lang.String, org.alfresco.service.namespace.QName, org.alfresco.repo.domain.PropertyValue) - */ - public void setStoreProperty(String store, QName name, PropertyValue value) - { - fTransport.setStoreProperty(fTicketHolder.getTicket(), store, name, value); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#uncover(java.lang.String, java.lang.String) - */ - public void uncover(String dirPath, String name) - { - fTransport.uncover(fTicketHolder.getTicket(), dirPath, name); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.avm.AVMRemote#renameStore(java.lang.String, java.lang.String) - */ - public void renameStore(String sourceName, String destName) - { - fTransport.renameStore(fTicketHolder.getTicket(), sourceName, destName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#addAspect(java.lang.String, org.alfresco.service.namespace.QName) - */ - public void addAspect(String path, QName aspectName) - { - fTransport.addAspect(fTicketHolder.getTicket(), path, aspectName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#getAspects(int, java.lang.String) - */ - public Set getAspects(int version, String path) - { - return fTransport.getAspects(fTicketHolder.getTicket(), version, path); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#hasAspect(int, java.lang.String, org.alfresco.service.namespace.QName) - */ - public boolean hasAspect(int version, String path, QName aspectName) - { - return fTransport.hasAspect(fTicketHolder.getTicket(), version, path, aspectName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#removeAspect(java.lang.String, org.alfresco.service.namespace.QName) - */ - public void removeAspect(String path, QName aspectName) - { - fTransport.removeAspect(fTicketHolder.getTicket(), path, aspectName); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#revert(java.lang.String, org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public void revert(String path, AVMNodeDescriptor toRevertTo) - { - fTransport.revert(fTicketHolder.getTicket(), path, toRevertTo); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#getAPath(org.alfresco.service.cmr.avm.AVMNodeDescriptor) - */ - public Pair getAPath(AVMNodeDescriptor desc) - { - return fTransport.getAPath(fTicketHolder.getTicket(), desc); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#setGuid(java.lang.String, java.lang.String) - */ - public void setGuid(String path, String guid) - { - fTransport.setGuid(fTicketHolder.getTicket(), path, guid); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#setEncoding(java.lang.String, java.lang.String) - */ - public void setEncoding(String path, String encoding) - { - fTransport.setEncoding(fTicketHolder.getTicket(), path, encoding); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.remote.AVMRemote#setMimeType(java.lang.String, java.lang.String) - */ - public void setMimeType(String path, String mimeType) - { - fTransport.setMimeType(fTicketHolder.getTicket(), path, mimeType); - } -} diff --git a/source/java/org/alfresco/repo/remote/AVMRemoteInputStream.java b/source/java/org/alfresco/repo/remote/AVMRemoteInputStream.java deleted file mode 100644 index 755316dcf7..0000000000 --- a/source/java/org/alfresco/repo/remote/AVMRemoteInputStream.java +++ /dev/null @@ -1,123 +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 . */ - -package org.alfresco.repo.remote; - -import java.io.IOException; -import java.io.InputStream; - -import org.alfresco.service.cmr.remote.AVMRemoteTransport; - -/** - * Wrapper around AVMRemote stream reading. - * @author britt - */ -public class AVMRemoteInputStream extends InputStream -{ - /** - * The AVMRemote reference. - */ - private AVMRemoteTransport fAVMRemote; - - /** - * The client ticket holder. - */ - private ClientTicketHolder fTicketHolder; - - /** - * The handle to the input stream. - */ - private String fHandle; - - /** - * Construct one. - * @param handle The handle returned by getInputStream(); - * @param remote The AVMRemote instance. - */ - public AVMRemoteInputStream(String handle, AVMRemoteTransport remote, - ClientTicketHolder ticketHolder) - { - fHandle = handle; - fAVMRemote = remote; - fTicketHolder = ticketHolder; - } - - /** - * Read in a single byte. - * @return The byte as 0-255 or -1 for eof. - */ - @Override - public int read() throws IOException - { - try - { - byte [] buff = fAVMRemote.readInput(fTicketHolder.getTicket(), fHandle, 1); - if (buff.length == 0) - { - return -1; - } - return ((int)buff[0]) & 0xff; - } - catch (Exception e) - { - throw new IOException("Remote I/O Error."); - } - } - - /** - * Read a buffer of bytes. - * @param b The buffer into which to put the bytes. - * @param off The offset into the buffer. - * @param len The number of bytes to read. - * @return The actual number of bytes read or -1 on eof. - */ - @Override - public int read(byte[] b, int off, int len) throws IOException - { - try - { - byte [] buff = fAVMRemote.readInput(fTicketHolder.getTicket(), fHandle, len); - if (buff.length == 0) - { - return -1; - } - System.arraycopy(buff, 0, b, off, buff.length); - return buff.length; - } - catch (Exception e) - { - throw new IOException("Remote I/O Error."); - } - } - - /** - * Close the underlying AVMRemote handle. - */ - @Override - public void close() throws IOException - { - try - { - fAVMRemote.closeInputHandle(fTicketHolder.getTicket(), fHandle); - } - catch (Exception e) - { - throw new IOException("Remote Error closing input stream."); - } - } -} diff --git a/source/java/org/alfresco/repo/remote/AVMRemoteOutputStream.java b/source/java/org/alfresco/repo/remote/AVMRemoteOutputStream.java deleted file mode 100644 index fafa5c044c..0000000000 --- a/source/java/org/alfresco/repo/remote/AVMRemoteOutputStream.java +++ /dev/null @@ -1,115 +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 . */ -package org.alfresco.repo.remote; - -import java.io.IOException; -import java.io.OutputStream; - -import org.alfresco.service.cmr.remote.AVMRemoteTransport; - -public class AVMRemoteOutputStream extends OutputStream -{ - private AVMRemoteTransport fAVMRemote; - - private String fHandle; - - private ClientTicketHolder fTicketHolder; - - /** - * Create a new one. - * @param handle The handle returned from an AVMRemote call. - * @param remote The AVMRemote instance. - */ - public AVMRemoteOutputStream(String handle, AVMRemoteTransport remote, - ClientTicketHolder ticketHolder) - { - fAVMRemote = remote; - fHandle = handle; - fTicketHolder = ticketHolder; - } - - /** - * Write one character. - * @param b The character. - */ - @Override - public void write(int b) - throws IOException - { - byte [] buff = new byte[1]; - buff[0] = (byte)b; - write(buff); - } - - /** - * Close the stream. - */ - @Override - public void close() - throws IOException - { - try - { - fAVMRemote.closeOutputHandle(fTicketHolder.getTicket(), fHandle); - } - catch (Exception e) - { - throw new IOException("IO Error: " + e); - } - } - - /** - * Write a portion of a block of bytes. - * @param b The buffer containing the data. - * @param off The offset into the buffer. - * @param len The number of bytes to write. - */ - @Override - public void write(byte[] b, int off, int len) - throws IOException - { - try - { - if (off == 0) - { - fAVMRemote.writeOutput(fTicketHolder.getTicket(), fHandle, b, len); - } - else - { - byte [] buff = new byte[len]; - System.arraycopy(b, off, buff, 0, len); - fAVMRemote.writeOutput(fTicketHolder.getTicket(), fHandle, buff, len); - } - } - catch (Exception e) - { - throw new IOException("IO Error: " + e); - } - } - - /** - * Write a buffer of data. - * @param b The buffer. - */ - @Override - public void write(byte[] b) - throws IOException - { - write(b, 0, b.length); - } -} diff --git a/source/java/org/alfresco/repo/remote/AVMSyncServiceRemote.java b/source/java/org/alfresco/repo/remote/AVMSyncServiceRemote.java deleted file mode 100644 index 1554aad7f7..0000000000 --- a/source/java/org/alfresco/repo/remote/AVMSyncServiceRemote.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2005-2012 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 . - */ -package org.alfresco.repo.remote; - -import java.util.List; - -import org.alfresco.service.cmr.avmsync.AVMDifference; -import org.alfresco.service.cmr.avmsync.AVMSyncService; -import org.alfresco.service.cmr.remote.AVMSyncServiceTransport; -import org.alfresco.util.NameMatcher; - -/** - * Client side wrapper around the RMI based AVMSyncServiceTransport. - * @author britt - */ -public class AVMSyncServiceRemote implements AVMSyncService -{ - /** - * The instance of AVMSyncServiceTransport. - */ - private AVMSyncServiceTransport fTransport; - - /** - * The ticket holder. - */ - private ClientTicketHolder fTicketHolder; - - /** - * Default constructor. - */ - public AVMSyncServiceRemote() - { - } - - /** - * Set the transport for the service. - */ - public void setAvmSyncServiceTransport(AVMSyncServiceTransport transport) - { - fTransport = transport; - } - - /** - * Setter. - * @param ticketHolder To set. - */ - public void setClientTicketHolder(ClientTicketHolder ticketHolder) - { - fTicketHolder = ticketHolder; - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avmsync.AVMSyncService#compare(int, java.lang.String, int, java.lang.String) - */ - public List compare(int srcVersion, String srcPath, - int dstVersion, String dstPath, NameMatcher excluder) - { - return fTransport.compare(fTicketHolder.getTicket(), srcVersion, srcPath, dstVersion, dstPath, excluder); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avmsync.AVMSyncService#flatten(java.lang.String, java.lang.String) - */ - public void flatten(String layerPath, String underlyingPath) - { - fTransport.flatten(fTicketHolder.getTicket(), layerPath, underlyingPath); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avmsync.AVMSyncService#resetLayer(java.lang.String) - */ - public void resetLayer(String layerPath) - { - fTransport.resetLayer(fTicketHolder.getTicket(), layerPath); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.avmsync.AVMSyncService#update(java.util.List, boolean, boolean, boolean, boolean, java.lang.String, java.lang.String) - */ - public void update(List diffList, - NameMatcher excluder, boolean ignoreConflicts, - boolean ignoreOlder, boolean overrideConflicts, - boolean overrideOlder, String tag, String description) - { - fTransport.update(fTicketHolder.getTicket(), diffList, excluder, ignoreConflicts, ignoreOlder, overrideConflicts, overrideOlder, tag, description); - } - - @Override - public List compare(int srcVersion, String srcPath, int dstVersion, String dstPath, NameMatcher excluder, boolean expandDirs) - { - return fTransport.compare(fTicketHolder.getTicket(), srcVersion, srcPath, dstVersion, dstPath, excluder, expandDirs); - } -} diff --git a/source/java/org/alfresco/repo/search/impl/lucene/AbstractLuceneIndexerAndSearcherFactory.java b/source/java/org/alfresco/repo/search/impl/lucene/AbstractLuceneIndexerAndSearcherFactory.java index 2d9c55ef4b..1d91331f08 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/AbstractLuceneIndexerAndSearcherFactory.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/AbstractLuceneIndexerAndSearcherFactory.java @@ -1538,7 +1538,6 @@ public abstract class AbstractLuceneIndexerAndSearcherFactory extends AbstractIn return null; } Set protocols = new HashSet(); - protocols.add(StoreRef.PROTOCOL_AVM); protocols.add(StoreRef.PROTOCOL_ARCHIVE); protocols.add(StoreRef.PROTOCOL_WORKSPACE); protocols.add("locks"); diff --git a/source/java/org/alfresco/repo/search/impl/lucene/fts/FullTextSearchIndexerBootstrapBean.java b/source/java/org/alfresco/repo/search/impl/lucene/fts/FullTextSearchIndexerBootstrapBean.java index 717454b21e..6b1a81b28e 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/fts/FullTextSearchIndexerBootstrapBean.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/fts/FullTextSearchIndexerBootstrapBean.java @@ -41,14 +41,7 @@ public class FullTextSearchIndexerBootstrapBean extends AbstractLifecycleBean List storeRefs = nodeService.getStores(); for (StoreRef storeRef : storeRefs) { - if (storeRef.getProtocol().equals(StoreRef.PROTOCOL_AVM)) - { - // nothing to do - } - else - { - fullTextSearchIndexer.requiresIndex(storeRef); - } + fullTextSearchIndexer.requiresIndex(storeRef); } } diff --git a/source/java/org/alfresco/repo/security/permissions/impl/PermissionServiceImpl.java b/source/java/org/alfresco/repo/security/permissions/impl/PermissionServiceImpl.java index 905f9e7b98..506881484f 100644 --- a/source/java/org/alfresco/repo/security/permissions/impl/PermissionServiceImpl.java +++ b/source/java/org/alfresco/repo/security/permissions/impl/PermissionServiceImpl.java @@ -31,8 +31,6 @@ import net.sf.acegisecurity.GrantedAuthority; 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.cache.SimpleCache; import org.alfresco.repo.domain.permissions.AclDAO; import org.alfresco.repo.policy.JavaBehaviour; @@ -479,12 +477,6 @@ public class PermissionServiceImpl extends AbstractLifecycleBean implements Perm return AccessStatus.DENIED; } - // AVM nodes - test for existence underneath - if (passedNodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) - { - return doAvmCan(passedNodeRef, permIn); - } - // Note: if we're directly accessing a frozen state (version) node (ie. in the 'version' store) we need to check permissions for the versioned node (ie. in the 'live' store) if (isVersionNodeRef(passedNodeRef)) { @@ -611,36 +603,16 @@ public class PermissionServiceImpl extends AbstractLifecycleBean implements Perm } - private AccessStatus doAvmCan(NodeRef nodeRef, PermissionReference permission) - { - /* Sparta: remove WCM/AVM - org.alfresco.util.Pair 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; - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.service.cmr.security.PermissionService#hasPermission(java.lang.Long, java.lang.String, - * java.lang.String) - */ public AccessStatus hasPermission(Long aclID, PermissionContext context, String permission) { return hasPermission(aclID, context, getPermissionReference(permission)); } - protected AccessStatus hasPermission(Long aclId, PermissionContext context, PermissionReference permission) { if (aclId == null) { - // Enforce store ACLs if set - the AVM default was to "allow" if there are no permissions set ... + // Enforce store ACLs if set if (context.getStoreAcl() == null) { return AccessStatus.ALLOWED; diff --git a/source/java/org/alfresco/repo/security/permissions/impl/acegi/ACLEntryVoter.java b/source/java/org/alfresco/repo/security/permissions/impl/acegi/ACLEntryVoter.java index 9834a86af8..f526ed4fae 100644 --- a/source/java/org/alfresco/repo/security/permissions/impl/acegi/ACLEntryVoter.java +++ b/source/java/org/alfresco/repo/security/permissions/impl/acegi/ACLEntryVoter.java @@ -574,29 +574,24 @@ public class ACLEntryVoter implements AccessDecisionVoter, InitializingBean // now we know the node - we can abstain for certain types and aspects (eg. RM) if(abstainForClassQNames.size() > 0) { - // For AVM we can not get type and aspect without going through internal AVM security checks - // AVM is never excluded - if(!testNodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) + // check node exists + if (nodeService.exists(testNodeRef)) { - // check node exists (note: for AVM deleted nodes, will skip the abstain check, since exists/getType is accessed via AVMNodeService) - if (nodeService.exists(testNodeRef)) + QName typeQName = nodeService.getType(testNodeRef); + if(abstainForClassQNames.contains(typeQName)) { - QName typeQName = nodeService.getType(testNodeRef); - if(abstainForClassQNames.contains(typeQName)) + return AccessDecisionVoter.ACCESS_ABSTAIN; + } + + Set aspectQNames = nodeService.getAspects(testNodeRef); + for(QName abstain : abstainForClassQNames) + { + if(aspectQNames.contains(abstain)) { return AccessDecisionVoter.ACCESS_ABSTAIN; } - - Set aspectQNames = nodeService.getAspects(testNodeRef); - for(QName abstain : abstainForClassQNames) - { - if(aspectQNames.contains(abstain)) - { - return AccessDecisionVoter.ACCESS_ABSTAIN; - } - } } - } + } } if (log.isDebugEnabled()) diff --git a/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java b/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java index 4c5ec38a63..135944450a 100644 --- a/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java +++ b/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java @@ -20,7 +20,6 @@ package org.alfresco.repo.service; import java.util.Collection; -import org.alfresco.mbeans.VirtServerRegistry; import org.alfresco.opencmis.dictionary.CMISDictionaryService; import org.alfresco.opencmis.search.CMISQueryService; import org.alfresco.repo.admin.SysAdminParams; @@ -34,10 +33,6 @@ import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.admin.RepoAdminService; import org.alfresco.service.cmr.attributes.AttributeService; import org.alfresco.service.cmr.audit.AuditService; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.avm.deploy.DeploymentService; -import org.alfresco.service.cmr.avm.locking.AVMLockingService; -import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.blog.BlogService; import org.alfresco.service.cmr.calendar.CalendarService; import org.alfresco.service.cmr.coci.CheckOutCheckInService; @@ -53,7 +48,6 @@ import org.alfresco.service.cmr.rating.RatingService; import org.alfresco.service.cmr.rendition.RenditionService; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.CopyService; -import org.alfresco.service.cmr.repository.CrossRepositoryCopyService; import org.alfresco.service.cmr.repository.MimetypeService; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.ScriptService; @@ -79,10 +73,6 @@ import org.alfresco.service.descriptor.DescriptorService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; -import org.alfresco.wcm.asset.AssetService; -import org.alfresco.wcm.preview.PreviewURIService; -import org.alfresco.wcm.sandbox.SandboxService; -import org.alfresco.wcm.webproject.WebProjectService; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; @@ -301,36 +291,6 @@ public class ServiceDescriptorRegistry return (AuditService)getService(AUDIT_SERVICE); } - /** - * Get the AVMService. - * @return The AVMService or null if there is none. - */ - @Override - public AVMService getAVMService() - { - return (AVMService)getService(AVM_SERVICE); - } - - /** - * Get the AVMService. - * @return The AVMService or null if there is none. - */ - @Override - public AVMService getAVMLockingAwareService() - { - return (AVMService)getService(AVM_LOCKING_AWARE_SERVICE); - } - - /** - * Get the AVM Sync Service. - * @return The AVM Sync Service. - */ - @Override - public AVMSyncService getAVMSyncService() - { - return (AVMSyncService)getService(AVM_SYNC_SERVICE); - } - @Override public OwnableService getOwnableService() { @@ -349,12 +309,6 @@ public class ServiceDescriptorRegistry return (SiteService) getService(SITE_SERVICE); } - @Override - public CrossRepositoryCopyService getCrossRepositoryCopyService() - { - return (CrossRepositoryCopyService)getService(CROSS_REPO_COPY_SERVICE); - } - @Override public AttributeService getAttributeService() { @@ -367,18 +321,6 @@ public class ServiceDescriptorRegistry return (ContentFilterLanguagesService) getService(CONTENT_FILTER_LANGUAGES_SERVICE); } - @Override - public AVMLockingService getAVMLockingService() - { - return (AVMLockingService)getService(AVM_LOCKING_SERVICE); - } - - @Override - public VirtServerRegistry getVirtServerRegistry() - { - return (VirtServerRegistry)getService(VIRT_SERVER_REGISTRY); - } - @Override public EditionService getEditionService() { @@ -403,36 +345,6 @@ public class ServiceDescriptorRegistry return (TaggingService)getService(TAGGING_SERVICE); } - @Override - public DeploymentService getDeploymentService() - { - return (DeploymentService) getService(DEPLOYMENT_SERVICE); - } - - @Override - public WebProjectService getWebProjectService() - { - return (WebProjectService)getService(WEBPROJECT_SERVICE); - } - - @Override - public SandboxService getSandboxService() - { - return (SandboxService)getService(SANDBOX_SERVICE); - } - - @Override - public AssetService getAssetService() - { - return (AssetService)getService(ASSET_SERVICE); - } - - @Override - public PreviewURIService getPreviewURIService() - { - return (PreviewURIService)getService(PREVIEW_URI_SERVICE); - } - @Override public FormService getFormService() { diff --git a/source/java/org/alfresco/repo/site/SiteAVMBootstrap.java b/source/java/org/alfresco/repo/site/SiteAVMBootstrap.java deleted file mode 100644 index a6e1d3f865..0000000000 --- a/source/java/org/alfresco/repo/site/SiteAVMBootstrap.java +++ /dev/null @@ -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 . - */ -package org.alfresco.repo.site; - -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.springframework.extensions.surf.util.AbstractLifecycleBean; -import org.alfresco.util.PropertyCheck; -import org.springframework.context.ApplicationEvent; - -/** - * This component is responsible for bootstraping the special Site AVM store. - * - * @author Kevin Roast - */ -public class SiteAVMBootstrap extends AbstractLifecycleBean -{ - /** AVM store name to create */ - private String storeName; - - /** Root directory name to create */ - private String rootDir; - - /** The AVM Service to use */ - private AVMService avmService; - - /** The Permission Service to use */ - private PermissionService permissionService; - - private TransactionService transactionService; - - - /** - * @param rootDir the rootDir to set - */ - public void setRootdir(String rootdir) - { - if (rootDir != null && rootDir.length() == 0) - { - rootDir = null; - } - this.rootDir = rootdir; - } - - /** - * @param storeName the storeName to set - */ - public void setStorename(String storename) - { - this.storeName = storename; - } - - /** - * @param avmService the AVMService avmService to set - */ - public void setAvmService(AVMService avmService) - { - this.avmService = avmService; - } - - /** - * @param permissionService the PermissionService to set - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - @Override - protected void onBootstrap(ApplicationEvent event) - { - // run as System on bootstrap - AuthenticationUtil.runAs(new RunAsWork() - { - public Object doWork() - { - bootstrap(); - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * Bootstrap the AVM store - */ - public void bootstrap() - { - // ensure properties have been set - PropertyCheck.mandatory(this, "avmService", avmService); - PropertyCheck.mandatory(this, "permissionService", permissionService); - PropertyCheck.mandatory(this, "transactionService", transactionService); - PropertyCheck.mandatory(this, "storeName", storeName); - PropertyCheck.mandatory(this, "rootDir", rootDir); - - // Avoid read-only mode errors - if (transactionService.isReadOnly()) - { - // Do nothing - return; - } - - if (this.avmService.getStore(storeName) == null) - { - // create the site store - this.avmService.createStore(storeName); - - // apply the special marker property - so we know this is a "sitestore" - // this will then be found by the FTP/CIFS virtual filesystem and expose the store - this.avmService.setStoreProperty(storeName, QName.createQName(null, ".sitestore"), - new PropertyValue(DataTypeDefinition.TEXT, "true")); - - // create the root directory - this.avmService.createDirectory(storeName + ":/", rootDir); - - // set default permissions on the new store - StoreRef store = new StoreRef(StoreRef.PROTOCOL_AVM, storeName); - this.permissionService.setPermission(store, PermissionService.ALL_AUTHORITIES, PermissionService.READ, true); - this.permissionService.setPermission(store, AuthenticationUtil.getGuestUserName(), PermissionService.READ, true); - } - } - - @Override - protected void onShutdown(ApplicationEvent event) - { - // nothing to do - } -} diff --git a/source/java/org/alfresco/repo/template/AVM.java b/source/java/org/alfresco/repo/template/AVM.java deleted file mode 100644 index b51923ff6d..0000000000 --- a/source/java/org/alfresco/repo/template/AVM.java +++ /dev/null @@ -1,235 +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 . - */ -package org.alfresco.repo.template; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.config.JNDIConstants; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMStoreDescriptor; -import org.springframework.extensions.surf.util.ParameterCheck; -import org.alfresco.wcm.asset.AssetInfo; -import org.alfresco.wcm.sandbox.SandboxService; -import org.alfresco.wcm.util.WCMUtil; - -/** - * AVM root object access for a template model. - * - * @author Kevin Roast - */ -public class AVM extends BaseTemplateProcessorExtension -{ - private ServiceRegistry services; - - /** - * Sets the service registry - * - * @param services the service registry - */ - public void setServiceRegistry(ServiceRegistry services) - { - this.services = services; - } - - /** - * @return a list of all AVM stores in the system - */ - public List getStores() - { - List stores = this.services.getAVMService().getStores(); - List results = new ArrayList(stores.size()); - for (AVMStoreDescriptor store : stores) - { - results.add(new AVMTemplateStore(this.services, getTemplateImageResolver(), store)); - } - return results; - } - - /** - * Return an AVM store object for the specified store name - * - * @param store Store name to lookup - * - * @return the AVM store object for the specified store or null if not found - */ - public AVMTemplateStore lookupStore(String store) - { - ParameterCheck.mandatoryString("Store", store); - AVMTemplateStore avmStore = null; - AVMStoreDescriptor descriptor = this.services.getAVMService().getStore(store); - if (descriptor != null) - { - avmStore = new AVMTemplateStore(this.services, getTemplateImageResolver(), descriptor); - } - return avmStore; - } - - /** - * Return the root node for a specified AVM store - * - * @param store Store name to find root node for - * - * @return the AVM store root node for the specified store or null if not found. - */ - public AVMTemplateNode lookupStoreRoot(String store) - { - ParameterCheck.mandatoryString("Store", store); - AVMTemplateNode root = null; - AVMTemplateStore avmStore = lookupStore(store); - if (avmStore != null) - { - root = avmStore.getLookupRoot(); - } - return root; - } - - /** - * Look a node by the absolute path. Path should include the store reference. - * - * @param path Absolute path to the node, including store reference. - * - * @return the node if found, null otherwise. - */ - public AVMTemplateNode lookupNode(String path) - { - ParameterCheck.mandatoryString("AVM Path", path); - AVMTemplateNode node = null; - AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, path); - if (nodeDesc != null) - { - node = new AVMTemplateNode(path, -1, this.services, getTemplateImageResolver()); - } - return node; - } - - /** - * Return the list of modified items for the specified user sandbox against staging store id - * for a specific webapp. - * - * @param storeId Root Store ID - * @param username Username to get modified items for - * @param webapp Webapp name to filter by - * - * @return List of AVMTemplateNode objects representing the modified items - */ - public List getModifiedItems(String storeId, String username, String webapp) - { - ParameterCheck.mandatoryString("Store ID", storeId); - ParameterCheck.mandatoryString("Username", username); - ParameterCheck.mandatoryString("Webapp", webapp); - - SandboxService sbService = this.services.getSandboxService(); - - String userStoreId = userSandboxStore(storeId, username); - - // get modified items - not including deleted - List assets = sbService.listChangedWebApp(userStoreId, webapp, false); - - List items = new ArrayList(assets.size()); - - for (AssetInfo asset : assets) - { - // convert each diff/node record into an AVM Node template wrapper - items.add(new AVMTemplateNode(asset.getAvmPath(), -1, this.services, getTemplateImageResolver())); - } - - return items; - } - - /** - * @param storeId Store ID to build staging store name for - * - * @return the Staging Store name for the given store ID - */ - public static String stagingStore(String storeId) - { - return WCMUtil.buildStagingStoreName(storeId); - } - - /** - * @param storeId Store ID to build sandbox store name for - * @param username Username of the sandbox user - * - * @return the Sandbox Store name for the given store ID and username - */ - public static String userSandboxStore(String storeId, String username) - { - return WCMUtil.buildUserMainStoreName(storeId, username); - } - - /** - * @param storeId Store ID to build preview URL for - * - * @return the preview URL to the staging store for the specified store ID - */ - public String websiteStagingUrl(String storeId) - { - return this.services.getPreviewURIService().getPreviewURI(storeId, null); - } - - /** - * @param storeId Store ID to build preview URL for - * @param username Username to build sandbox preview URL for - * - * @return the preview URL to the user sandbox for the specified store ID and username - */ - public String websiteUserSandboxUrl(String storeId, String username) - { - ParameterCheck.mandatoryString("Store ID", storeId); - ParameterCheck.mandatoryString("Username", username); - return websiteStagingUrl(userSandboxStore(storeId, username)); - } - - /** - * @param store Store ID of the asset - * @param assetPath Store relative path to the asset - * - * @return the preview URL to the specified store asset - */ - public String assetUrl(String storeId, String assetPath) - { - return this.services.getPreviewURIService().getPreviewURI(storeId, assetPath); - } - - /** - * @param avmPath Fully qualified AVM path of the asset - * - * @return the preview URL to the specified asset - */ - public String assetUrl(String avmPath) - { - ParameterCheck.mandatoryString("AVM Path", avmPath); - String[] s = avmPath.split(":"); - if (s.length != 2) - { - throw new IllegalArgumentException("Expected exactly one ':' in " + avmPath); - } - return assetUrl(s[0], s[1]); - } - - /** - * @return the path to the webapps folder in a standard web store. - */ - public static String getWebappsFolderPath() - { - return JNDIConstants.DIR_DEFAULT_WWW_APPBASE; - } -} diff --git a/source/java/org/alfresco/repo/template/AVMTemplateNode.java b/source/java/org/alfresco/repo/template/AVMTemplateNode.java deleted file mode 100644 index c7a1ecf1d0..0000000000 --- a/source/java/org/alfresco/repo/template/AVMTemplateNode.java +++ /dev/null @@ -1,601 +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 . - */ -package org.alfresco.repo.template; - -import java.io.Serializable; -import java.io.StringReader; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.WCMModel; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.locking.AVMLockingService.LockState; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.repository.TemplateImageResolver; -import org.alfresco.service.namespace.NamespacePrefixResolver; -import org.alfresco.service.namespace.NamespacePrefixResolverProvider; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.QNameMap; -import org.alfresco.util.Pair; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.URLEncoder; -import org.xml.sax.InputSource; - -import freemarker.ext.dom.NodeModel; - -/** - * AVM node class for use by a Template model. - *

- * The class exposes Node properties, children as dynamically populated maps and lists. - *

- * Various helper methods are provided to access common and useful node variables such - * as the content url and type information. - *

- * See {@link http://wiki.alfresco.com/wiki/Template_Guide} - * - * @author Kevin Roast - */ -@SuppressWarnings("serial") -public class AVMTemplateNode extends BasePermissionsNode implements NamespacePrefixResolverProvider -{ - private static Log logger = LogFactory.getLog(AVMTemplateNode.class); - - /** Cached values */ - private NodeRef nodeRef; - private String name; - private QName type; - private String path; - private int version; - private boolean deleted; - private QNameMap properties; - private boolean propsRetrieved = false; - private AVMTemplateNode parent = null; - private AVMNodeDescriptor avmRef; - - - // ------------------------------------------------------------------------------ - // Construction - - /** - * Constructor - * - * @param nodeRef The NodeRef for the AVM node this wrapper represents - * @param services The ServiceRegistry the Node can use to access services - * @param resolver Image resolver to use to retrieve icons - */ - public AVMTemplateNode(NodeRef nodeRef, ServiceRegistry services, TemplateImageResolver resolver) - { - if (nodeRef == null) - { - throw new IllegalArgumentException("NodeRef must be supplied."); - } - - if (services == null) - { - throw new IllegalArgumentException("The ServiceRegistry must be supplied."); - } - - this.nodeRef = nodeRef; - Pair pair = AVMNodeConverter.ToAVMVersionPath(nodeRef); - this.services = services; - this.imageResolver = resolver; - init(pair.getFirst(), pair.getSecond(), null); - } - - /** - * Constructor - * - * @param path AVM path to the node - * @param version Version number for avm path - * @param services The ServiceRegistry the Node can use to access services - * @param resolver Image resolver to use to retrieve icons - */ - public AVMTemplateNode(String path, int version, ServiceRegistry services, TemplateImageResolver resolver) - { - if (path == null) - { - throw new IllegalArgumentException("Path must be supplied."); - } - - if (services == null) - { - throw new IllegalArgumentException("The ServiceRegistry must be supplied."); - } - - this.nodeRef = AVMNodeConverter.ToNodeRef(version, path); - this.services = services; - this.imageResolver = resolver; - init(version, path, null); - } - - /** - * Constructor - * - * @param descriptor AVMNodeDescriptior - * @param services - * @param resolver - */ - public AVMTemplateNode(AVMNodeDescriptor descriptor, ServiceRegistry services, TemplateImageResolver resolver) - { - if (descriptor == null) - { - throw new IllegalArgumentException("AVMNodeDescriptor must be supplied."); - } - - if (services == null) - { - throw new IllegalArgumentException("The ServiceRegistry must be supplied."); - } - - this.version = -1; - this.path = descriptor.getPath(); - this.nodeRef = AVMNodeConverter.ToNodeRef(this.version, this.path); - this.services = services; - this.imageResolver = resolver; - init(this.version, this.path, descriptor); - } - - private void init(int version, String path, AVMNodeDescriptor descriptor) - { - this.version = version; - this.path = path; - this.properties = new QNameMap(this); - if (descriptor == null) - { - descriptor = this.services.getAVMService().lookup(version, path, true); - if (descriptor == null) - { - throw new IllegalArgumentException("Invalid node specified: " + nodeRef.toString()); - } - } - this.avmRef = descriptor; - this.deleted = descriptor.isDeleted(); - } - - - // ------------------------------------------------------------------------------ - // AVM Node API - - /** - * @return ID for the AVM path - the path. - */ - public String getId() - { - return this.path; - } - - /** - * @return the path for this AVM node. - */ - public String getPath() - { - return this.path; - } - - /** - * @return the version part of the AVM path. - */ - public int getVersion() - { - return this.version; - } - - /** - * @return file/folder name of the AVM path. - */ - public String getName() - { - if (this.name == null) - { - this.name = AVMNodeConverter.SplitBase(this.path)[1]; - } - return this.name; - } - - /** - * @return AVM path to the parent node - */ - public String getParentPath() - { - return AVMNodeConverter.SplitBase(this.path)[0]; - } - - /** - * @see org.alfresco.repo.template.TemplateNodeRef#getNodeRef() - */ - public NodeRef getNodeRef() - { - return this.nodeRef; - } - - /** - * @see org.alfresco.repo.template.TemplateNodeRef#getType() - */ - public QName getType() - { - if (this.type == null) - { - if (this.deleted == false) - { - this.type = this.services.getNodeService().getType(this.nodeRef); - } - else - { - this.type = this.avmRef.isDeletedDirectory() ? WCMModel.TYPE_AVM_FOLDER : WCMModel.TYPE_AVM_CONTENT; - } - } - - return type; - } - - /** - * @return true if the item is a deleted node, false otherwise - */ - public boolean getIsDeleted() - { - return this.avmRef.isDeleted(); - } - - /** - * @return true if the node is currently locked - */ - public boolean getIsLocked() - { - String currentUser = AuthenticationUtil.getFullyAuthenticatedUser(); - LockState lockStatus = this.services.getAVMLockingService().getLockState( - getWebProject(), path.substring(path.indexOf("/")), currentUser); - return lockStatus != LockState.NO_LOCK; - } - - /** - * @return true if this node is locked and the current user is the lock owner - */ - public boolean getIsLockOwner() - { - String currentUser = AuthenticationUtil.getFullyAuthenticatedUser(); - LockState lockStatus = this.services.getAVMLockingService().getLockState( - getWebProject(), path.substring(path.indexOf("/")), currentUser); - return lockStatus == LockState.LOCK_OWNER; - } - - /** - * @return true if this user can perform operations on the node when locked. - * This is true if the item is either unlocked, or locked and the current user is the lock owner, - * or locked and the current user has Content Manager role in the associated web project. - */ - public boolean getHasLockAccess() - { - return this.services.getAVMLockingService().hasAccess( - getWebProject(), path, this.services.getAuthenticationService().getCurrentUserName()); - } - - - // ------------------------------------------------------------------------------ - // TemplateProperties API - - /** - * @return the immediate parent in the node path (null if root of store) - */ - public TemplateProperties getParent() - { - if (this.parent == null) - { - String parentPath = this.getParentPath(); - if (parentPath != null) - { - this.parent = new AVMTemplateNode(parentPath, this.version, this.services, this.imageResolver); - } - } - return this.parent; - } - - /** - * @return true if this Node is a container (i.e. a folder) - */ - @Override - public boolean getIsContainer() - { - return this.avmRef.isDirectory() || this.avmRef.isDeletedDirectory(); - } - - /** - * @return true if this Node is a document (i.e. a file) - */ - @Override - public boolean getIsDocument() - { - return this.avmRef.isFile() || this.avmRef.isDeletedFile(); - } - - /** - * @see org.alfresco.repo.template.TemplateProperties#getChildren() - */ - public List getChildren() - { - if (this.children == null) - { - // use the NodeService so appropriate permission checks are performed - List childRefs = this.services.getNodeService().getChildAssocs(this.nodeRef); - this.children = new ArrayList(childRefs.size()); - for (ChildAssociationRef ref : childRefs) - { - // create our Node representation from the NodeRef - AVMTemplateNode child = new AVMTemplateNode(ref.getChildRef(), this.services, this.imageResolver); - this.children.add(child); - } - } - - return this.children; - } - - /** - * @see org.alfresco.repo.template.TemplateProperties#getProperties() - */ - @SuppressWarnings("unchecked") - public Map getProperties() - { - if (!this.propsRetrieved) - { - if (!this.deleted) - { - Map props = this.services.getAVMService().getNodeProperties(this.version, this.path); - for (QName qname: props.keySet()) - { - PropertyDefinition propertyDefinition = services.getDictionaryService().getProperty(qname); - QName currentPropertyType = DataTypeDefinition.ANY; - if (null != propertyDefinition) - { - currentPropertyType = propertyDefinition.getDataType().getName(); - } - Serializable propValue = props.get(qname).getValue(currentPropertyType); - if (propValue instanceof NodeRef) - { - // NodeRef object properties are converted to new TemplateNode objects - // so they can be used as objects within a template - NodeRef nodeRef = (NodeRef)propValue; - if (StoreRef.PROTOCOL_AVM.equals(nodeRef.getStoreRef().getProtocol())) - { - propValue = new AVMTemplateNode(nodeRef, this.services, this.imageResolver); - } - else - { - propValue = new TemplateNode(nodeRef, this.services, this.imageResolver); - } - } - else if (propValue instanceof ContentData) - { - // ContentData object properties are converted to TemplateContentData objects - // so the content and other properties of those objects can be accessed - propValue = new TemplateContentData((ContentData)propValue, qname); - } - this.properties.put(qname.toString(), propValue); - } - } - - // AVM node properties not available in usual getProperties() call - this.properties.put("name", this.avmRef.getName()); - this.properties.put("created", new Date(this.avmRef.getCreateDate())); - this.properties.put("modified", new Date(this.avmRef.getModDate())); - this.properties.put("creator", this.avmRef.getCreator()); - this.properties.put("modifier", this.avmRef.getLastModifier()); - - this.propsRetrieved = true; - } - - return this.properties; - } - - /** - * @return The list of aspects applied to this node - */ - @Override - public Set getAspects() - { - if (this.aspects == null) - { - this.aspects = this.services.getAVMService().getAspects(this.version, this.path); - } - - return this.aspects; - } - - - // ------------------------------------------------------------------------------ - // Content API - - /** - * @return the content String for this node from the default content property - * (@see ContentModel.PROP_CONTENT) - */ - public String getContent() - { - ContentReader reader = this.services.getAVMService().getContentReader(this.version, this.path); - - return (reader != null && reader.exists()) ? reader.getContentString() : ""; - } - - /** - * @return For a content document, this method returns the URL to the content stream for - * the default content property (@see ContentModel.PROP_CONTENT) - *

- * For a container node, this method return the URL to browse to the folder in the web-client - */ - public String getUrl() - { - if (getIsDocument() == true) - { - return MessageFormat.format(CONTENT_GET_URL, new Object[] { - getNodeRef().getStoreRef().getProtocol(), - getNodeRef().getStoreRef().getIdentifier(), - getNodeRef().getId(), - URLEncoder.encode(getName()) } ); - } - else - { - return MessageFormat.format(FOLDER_BROWSE_URL, new Object[] { - getNodeRef().getStoreRef().getProtocol(), - getNodeRef().getStoreRef().getIdentifier(), - getNodeRef().getId() } ); - } - } - - /** - * @return For a content document, this method returns the download URL to the content for - * the default content property (@see ContentModel.PROP_CONTENT) - *

- * For a container node, this method returns an empty string - */ - public String getDownloadUrl() - { - if (getIsDocument() == true) - { - return MessageFormat.format(CONTENT_DOWNLOAD_URL, new Object[] { - getNodeRef().getStoreRef().getProtocol(), - getNodeRef().getStoreRef().getIdentifier(), - getNodeRef().getId(), - URLEncoder.encode(getName()) } ); - } - else - { - return ""; - } - } - - /** - * @return The mimetype encoding for content attached to the node from the default content property - * (@see ContentModel.PROP_CONTENT) - */ - public String getMimetype() - { - if (getIsContainer()) - { - return null; - } - return this.services.getAVMService().getContentDataForRead(this.avmRef).getMimetype(); - } - - /** - * @return The display label of the mimetype encoding for content attached to the node from the default - * content property (@see ContentModel.PROP_CONTENT) - */ - public String getDisplayMimetype() - { - if (getIsContainer()) - { - return null; - } - final String mimetype = this.services.getAVMService().getContentDataForRead(this.avmRef).getMimetype(); - return services.getMimetypeService().getDisplaysByMimetype().get(mimetype); - } - - /** - * @return The character encoding for content attached to the node from the default content property - * (@see ContentModel.PROP_CONTENT) - */ - public String getEncoding() - { - if (getIsContainer()) - { - return null; - } - return this.services.getAVMService().getContentDataForRead(this.avmRef).getEncoding(); - } - - /** - * @return The size in bytes of the content attached to the node from the default content property - * (@see ContentModel.PROP_CONTENT) - */ - public long getSize() - { - if (getIsContainer()) - { - return -1; - } - return this.services.getAVMService().getContentDataForRead(this.avmRef).getSize(); - } - - // ------------------------------------------------------------------------------ - // Node Helper API - - /** - * @return FreeMarker NodeModel for the XML content of this node, or null if no parsable XML found - */ - public NodeModel getXmlNodeModel() - { - try - { - return NodeModel.parse(new InputSource(new StringReader(getContent()))); - } - catch (Throwable err) - { - if (logger.isDebugEnabled()) - logger.debug(err.getMessage(), err); - - return null; - } - } - - /** - * @return Display path to this node - the path built of 'cm:name' attribute values. - */ - @Override - public String getDisplayPath() - { - return this.path; - } - - - public NamespacePrefixResolver getNamespacePrefixResolver() - { - return this.services.getNamespaceService(); - } - - - // ------------------------------------------------------------------------------ - // Private helpers - - /** - * @return the WebProject identifier for the current path - */ - private String getWebProject() - { - String webProject = this.path.substring(0, this.path.indexOf(':')); - int index = webProject.indexOf("--"); - if (index != -1) - { - webProject = webProject.substring(0, index); - } - return webProject; - } -} diff --git a/source/java/org/alfresco/repo/template/AVMTemplateStore.java b/source/java/org/alfresco/repo/template/AVMTemplateStore.java deleted file mode 100644 index 1156c66780..0000000000 --- a/source/java/org/alfresco/repo/template/AVMTemplateStore.java +++ /dev/null @@ -1,182 +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 . - */ -package org.alfresco.repo.template; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.jscript.ScriptNode; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMStoreDescriptor; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.repository.TemplateImageResolver; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.ResultSetRow; -import org.alfresco.service.cmr.search.SearchService; - -/** - * Representation of an AVM Store for the template model. Accessed via the AVM helper object - * and is responsible for returning AVMTemplateNode objects via various mechanisms. - * - * @author Kevin Roast - */ -public class AVMTemplateStore -{ - private ServiceRegistry services; - private AVMStoreDescriptor descriptor; - private TemplateImageResolver resolver; - - /** - * Constructor - * - * @param services - * @param resolver - * @param store Store descriptor this object represents - */ - public AVMTemplateStore(ServiceRegistry services, TemplateImageResolver resolver, AVMStoreDescriptor store) - { - this.descriptor = store; - this.services = services; - this.resolver = resolver; - } - - /** - * @return Store name - */ - public String getName() - { - return this.descriptor.getName(); - } - - /** - * @return Store name - */ - public String getId() - { - return this.descriptor.getName(); - } - - /** - * @return User who created the store - */ - public String getCreator() - { - return this.descriptor.getCreator(); - } - - /** - * @return Creation date of the store - */ - public Date getCreatedDate() - { - return new Date(this.descriptor.getCreateDate()); - } - - /** - * @return the root node of all webapps in the store - */ - public AVMTemplateNode getLookupRoot() - { - AVMTemplateNode rootNode = null; - String rootPath = this.descriptor.getName() + ':' + AVM.getWebappsFolderPath(); - AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, rootPath); - if (nodeDesc != null) - { - rootNode = new AVMTemplateNode(rootPath, -1, this.services, this.resolver); - } - return rootNode; - } - - /** - * Lookup a node in the store, the path is assumed to be related to the webapps folder root. - * Therefore a valid path would be "/ROOT/WEB-INF/lib/web.xml". - * - * @param path Relative to the webapps folder root path for this store. - * - * @return node if found, null otherwise. - */ - public AVMTemplateNode lookupNode(String path) - { - AVMTemplateNode node = null; - if (path != null && path.length() != 0) - { - if (path.charAt(0) != '/') - { - path = '/' + path; - } - path = this.descriptor.getName() + ':' + AVM.getWebappsFolderPath() + path; - AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, path); - if (nodeDesc != null) - { - node = new AVMTemplateNode(path, -1, this.services, this.resolver); - } - } - return node; - } - - /** - * Perform a lucene query against this store. - * - * @param query Lucene - * - * @return list of AVM node objects as results - empty list if no results found - */ - public List luceneSearch(String query) - { - List nodes = null; - - // perform the search against the repo - ResultSet results = null; - try - { - results = this.services.getSearchService().query( - new StoreRef(StoreRef.PROTOCOL_AVM, this.descriptor.getName()), - SearchService.LANGUAGE_LUCENE, - query); - - if (results.length() != 0) - { - nodes = new ArrayList(results.length()); - for (ResultSetRow row : results) - { - NodeRef nodeRef = row.getNodeRef(); - nodes.add(new AVMTemplateNode(nodeRef, this.services, this.resolver)); - } - } - } - catch (Throwable err) - { - throw new AlfrescoRuntimeException("Failed to execute search: " + query, err); - } - finally - { - if (results != null) - { - results.close(); - } - } - - return (nodes != null ? nodes : (List)Collections.emptyList()); - } -} diff --git a/source/java/org/alfresco/repo/template/FreeMarkerProcessor.java b/source/java/org/alfresco/repo/template/FreeMarkerProcessor.java index 1d31aefbc9..d048ca26b8 100644 --- a/source/java/org/alfresco/repo/template/FreeMarkerProcessor.java +++ b/source/java/org/alfresco/repo/template/FreeMarkerProcessor.java @@ -30,7 +30,6 @@ import org.alfresco.processor.ProcessorExtension; import org.alfresco.repo.processor.BaseProcessor; import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.TemplateException; import org.alfresco.service.cmr.repository.TemplateImageResolver; import org.alfresco.service.cmr.repository.TemplateProcessor; @@ -408,14 +407,7 @@ public class FreeMarkerProcessor extends BaseProcessor implements TemplateProces if (value instanceof NodeRef) { NodeRef ref = (NodeRef)value; - if (StoreRef.PROTOCOL_AVM.equals(ref.getStoreRef().getProtocol())) - { - return new AVMTemplateNode((NodeRef)value, this.services, imageResolver); - } - else - { - return new TemplateNode((NodeRef)value, this.services, imageResolver); - } + return new TemplateNode((NodeRef)value, this.services, imageResolver); } else if (value instanceof AssociationRef) diff --git a/source/java/org/alfresco/repo/template/Workflow.java b/source/java/org/alfresco/repo/template/Workflow.java index cc75783077..df07b92f19 100644 --- a/source/java/org/alfresco/repo/template/Workflow.java +++ b/source/java/org/alfresco/repo/template/Workflow.java @@ -27,7 +27,6 @@ import java.util.Map; import org.alfresco.model.ApplicationModel; import org.alfresco.model.ContentModel; -import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.forms.processor.workflow.ExtendedFieldBuilder; import org.alfresco.repo.workflow.WorkflowModel; import org.alfresco.service.ServiceRegistry; @@ -263,27 +262,17 @@ public class Workflow extends BaseTemplateProcessorExtension for(NodeRef nodeRef : contents) { - if (nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) - { - Pair vp = AVMNodeConverter.ToAVMVersionPath(nodeRef); - resources.add(new AVMTemplateNode( - vp.getSecond(), vp.getFirst(), this.services, this.resolver)); - - } - else - { - QName type = nodeService.getType(nodeRef); + QName type = nodeService.getType(nodeRef); - // make sure the type is defined in the data dictionary - if (ddService.getType(type) != null) + // make sure the type is defined in the data dictionary + if (ddService.getType(type) != null) + { + // look for content nodes or links to content + // NOTE: folders within workflow packages are ignored for now + if (ddService.isSubClass(type, ContentModel.TYPE_CONTENT) || + ApplicationModel.TYPE_FILELINK.equals(type)) { - // look for content nodes or links to content - // NOTE: folders within workflow packages are ignored for now - if (ddService.isSubClass(type, ContentModel.TYPE_CONTENT) || - ApplicationModel.TYPE_FILELINK.equals(type)) - { - resources.add(new TemplateNode(nodeRef, this.services, this.resolver)); - } + resources.add(new TemplateNode(nodeRef, this.services, this.resolver)); } } } diff --git a/source/java/org/alfresco/repo/tenant/MultiTNodeServiceInterceptor.java b/source/java/org/alfresco/repo/tenant/MultiTNodeServiceInterceptor.java index 189a783a93..0f15f78416 100644 --- a/source/java/org/alfresco/repo/tenant/MultiTNodeServiceInterceptor.java +++ b/source/java/org/alfresco/repo/tenant/MultiTNodeServiceInterceptor.java @@ -223,7 +223,7 @@ public class MultiTNodeServiceInterceptor extends DelegatingIntroductionIntercep StoreRef storeRef = ref; try { - if (tenantService.isEnabled() && (! storeRef.getProtocol().equals(StoreRef.PROTOCOL_AVM))) + if (tenantService.isEnabled()) { // MT: return tenant stores only (although for super System return all stores - as used by // ConfigurationChecker, IndexRecovery, IndexBackup etc) diff --git a/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java b/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java index b7bf480f0d..ee9fda9439 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java @@ -30,15 +30,10 @@ import java.util.Map; import org.alfresco.model.ContentModel; import org.alfresco.repo.admin.BaseInterpreter; -import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authority.AuthorityDAO; import org.alfresco.repo.tenant.TenantService; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.avmsync.AVMDifference; -import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.dictionary.AspectDefinition; import org.alfresco.service.cmr.dictionary.ClassDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; @@ -65,7 +60,6 @@ import org.alfresco.service.cmr.workflow.WorkflowTransition; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.GUID; import org.springframework.context.ApplicationEvent; import org.springframework.core.io.ClassPathResource; import org.springframework.extensions.surf.util.I18NUtil; @@ -82,8 +76,6 @@ public class WorkflowInterpreter extends BaseInterpreter private NamespaceService namespaceService; private NodeService nodeService; private AuthorityDAO authorityDAO; - private AVMService avmService; - private AVMSyncService avmSyncService; private PersonService personService; private FileFolderService fileFolderService; private TenantService tenantService; @@ -104,20 +96,12 @@ public class WorkflowInterpreter extends BaseInterpreter private Map vars = new HashMap(); - - - /* (non-Javadoc) - * @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onBootstrap(org.springframework.getContext().ApplicationEvent) - */ @Override protected void onBootstrap(ApplicationEvent event) { //NOOP } - /* (non-Javadoc) - * @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onShutdown(org.springframework.getContext().ApplicationEvent) - */ @Override protected void onShutdown(ApplicationEvent event) { @@ -156,22 +140,6 @@ public class WorkflowInterpreter extends BaseInterpreter this.dictionaryService = dictionaryService; } - /** - * @param avmService The AVM Service - */ - public void setAVMService(AVMService avmService) - { - this.avmService = avmService; - } - - /** - * @param avmSyncService The AVM Sync Service - */ - public void setAVMSyncService(AVMSyncService avmSyncService) - { - this.avmSyncService = avmSyncService; - } - /** * @param namespaceService namespaceService */ @@ -1183,47 +1151,6 @@ public class WorkflowInterpreter extends BaseInterpreter } out.println("set var " + qname + " = " + vars.get(qname)); } - else if (command[2].equals("avmpackage")) - { - // lookup source folder of changes - AVMNodeDescriptor avmSource = avmService.lookup(-1, command[3]); - if (avmSource == null || !avmSource.isDirectory()) - { - return command[3] + " must refer to a directory."; - } - - // create container for avm workflow packages - String packagesPath = "workflow-system:/packages"; - AVMNodeDescriptor packagesDesc = avmService.lookup(-1, packagesPath); - if (packagesDesc == null) - { - avmService.createStore("workflow-system"); - avmService.createDirectory("workflow-system:/", "packages"); - } - - // create package (layered to target, if target is specified) - String packageName = GUID.generate(); - String avmSourceIndirection = avmSource.getIndirection(); - if (avmSourceIndirection != null) - { - avmService.createLayeredDirectory(avmSourceIndirection, packagesPath, packageName); - List diff = avmSyncService.compare(-1, avmSource.getPath(), -1, packagesPath + "/" + packageName, null); - avmSyncService.update(diff, null, true, true, false, false, null, null); - } - else - { - // copy source folder to package folder - avmService.copy(-1, avmSource.getPath(), packagesPath, packageName); - } - - // convert package to workflow package - AVMNodeDescriptor packageDesc = avmService.lookup(-1, packagesPath + "/" + packageName); - NodeRef packageNodeRef = workflowService.createPackage(AVMNodeConverter.ToNodeRef(-1, packageDesc.getPath())); - nodeService.setProperty(packageNodeRef, WorkflowModel.PROP_IS_SYSTEM_PACKAGE, true); - QName qname = QName.createQName(command[1], namespaceService); - vars.put(qname, packageNodeRef); - out.println("set var " + qname + " = " + vars.get(qname)); - } else if (command[2].equals("package")) { QName qname = QName.createQName(command[1], namespaceService); diff --git a/source/java/org/alfresco/repo/workflow/WorkflowServiceImpl.java b/source/java/org/alfresco/repo/workflow/WorkflowServiceImpl.java index 979ebedd59..f5b95261ae 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowServiceImpl.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowServiceImpl.java @@ -32,10 +32,6 @@ import java.util.Map; import java.util.Set; import org.alfresco.model.ContentModel; -import org.alfresco.model.WCMModel; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.service.cmr.avmsync.AVMDifference; -import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentReader; @@ -83,7 +79,6 @@ public class WorkflowServiceImpl implements WorkflowService private WorkflowPackageComponent workflowPackageComponent; private NodeService nodeService; private ContentService contentService; - private AVMSyncService avmSyncService; private DictionaryService dictionaryService; private NodeService protectedNodeService; private WorkflowNotificationUtils workflowNotificationUtils; @@ -158,16 +153,6 @@ public class WorkflowServiceImpl implements WorkflowService this.contentService = contentService; } - /** - * Set the avm sync service - * - * @param avmSyncService - */ - public void setAvmSyncService(AVMSyncService avmSyncService) - { - this.avmSyncService = avmSyncService; - } - /** * Set the dictionary service * @@ -1347,14 +1332,7 @@ public class WorkflowServiceImpl implements WorkflowService public List getPackageContents(NodeRef packageRef) { - if (packageRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) - { - return getAvmPackageContents(packageRef); - } - else - { - return getRepositoryPackageContents(packageRef); - } + return getRepositoryPackageContents(packageRef); } /** @@ -1429,34 +1407,6 @@ public class WorkflowServiceImpl implements WorkflowService return true; } - /** - * @param contents - * @param workflowPackage - */ - private List getAvmPackageContents(NodeRef workflowPackage) - { - List contents = new ArrayList(); - if (protectedNodeService.exists(workflowPackage)) - { - final NodeRef stagingNodeRef = (NodeRef) protectedNodeService.getProperty(workflowPackage, - WCMModel.PROP_AVM_DIR_INDIRECTION); - final String stagingAvmPath = AVMNodeConverter.ToAVMVersionPath(stagingNodeRef).getSecond(); - final String packageAvmPath = AVMNodeConverter.ToAVMVersionPath(workflowPackage).getSecond(); - if (logger.isDebugEnabled()) - logger.debug("comparing " + packageAvmPath + " with " + stagingAvmPath); - for (AVMDifference d : avmSyncService.compare(-1, packageAvmPath, -1, stagingAvmPath, null, true)) - { - if (logger.isDebugEnabled()) - logger.debug("got difference " + d); - if (d.getDifferenceCode() == AVMDifference.NEWER || d.getDifferenceCode() == AVMDifference.CONFLICT) - { - contents.add(AVMNodeConverter.ToNodeRef(d.getSourceVersion(), d.getSourcePath())); - } - } - } - return contents; - } - /** * Determines if the given user is a member of the pooled actors assigned to the task * diff --git a/source/java/org/alfresco/repo/workflow/jscript/JscriptWorkflowTask.java b/source/java/org/alfresco/repo/workflow/jscript/JscriptWorkflowTask.java index 653f6ab3d0..c05a1df003 100644 --- a/source/java/org/alfresco/repo/workflow/jscript/JscriptWorkflowTask.java +++ b/source/java/org/alfresco/repo/workflow/jscript/JscriptWorkflowTask.java @@ -232,7 +232,7 @@ public class JscriptWorkflowTask extends BaseScopableProcessorExtension implemen Collection allowedTypes = getAllowedPackageResourceTypes(); for (NodeRef node : contents) { - if (isAvmResource(node, allowedTypes)) + if (isValidResource(node, allowedTypes)) { ScriptNode scriptNode = new ScriptNode(node, serviceRegistry, getScope()); resources.add(scriptNode); @@ -250,10 +250,8 @@ public class JscriptWorkflowTask extends BaseScopableProcessorExtension implemen return allowedTypes; } - private boolean isAvmResource(NodeRef node, Collection allowedTypes) + private boolean isValidResource(NodeRef node, Collection allowedTypes) { - if(isAvmNode(node)) - return true; if (nodeService.exists(node)) { //Check if the node is one of the allowedTypes. @@ -262,11 +260,6 @@ public class JscriptWorkflowTask extends BaseScopableProcessorExtension implemen return false; } - private boolean isAvmNode(NodeRef node) - { - return StoreRef.PROTOCOL_AVM.equals(node.getStoreRef().getProtocol()); - } - private static class DefaultNamespaceProvider implements NamespacePrefixResolverProvider { private static final long serialVersionUID = -7015209142379905617L; diff --git a/source/java/org/alfresco/sandbox/SandboxConstants.java b/source/java/org/alfresco/sandbox/SandboxConstants.java deleted file mode 100644 index 05c76d977b..0000000000 --- a/source/java/org/alfresco/sandbox/SandboxConstants.java +++ /dev/null @@ -1,33 +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 . - */ -/*----------------------------------------------------------------------------- -* Author Jon Cox -* File SandboxConstants.java -*----------------------------------------------------------------------------*/ - -package org.alfresco.sandbox; - -/** - * WCM sandbox constants - * - * @deprecated refer to org.alfresco.wcm.sandbox.SandboxConstants - */ -public class SandboxConstants extends org.alfresco.wcm.sandbox.SandboxConstants -{ -} diff --git a/source/java/org/alfresco/service/ServiceRegistry.java b/source/java/org/alfresco/service/ServiceRegistry.java index b6ca6afacb..c6171f3726 100644 --- a/source/java/org/alfresco/service/ServiceRegistry.java +++ b/source/java/org/alfresco/service/ServiceRegistry.java @@ -21,7 +21,6 @@ package org.alfresco.service; import java.util.Collection; import org.alfresco.api.AlfrescoPublicApi; -import org.alfresco.mbeans.VirtServerRegistry; import org.alfresco.opencmis.dictionary.CMISDictionaryService; import org.alfresco.opencmis.search.CMISQueryService; import org.alfresco.repo.admin.SysAdminParams; @@ -34,10 +33,6 @@ import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.admin.RepoAdminService; import org.alfresco.service.cmr.attributes.AttributeService; import org.alfresco.service.cmr.audit.AuditService; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.avm.deploy.DeploymentService; -import org.alfresco.service.cmr.avm.locking.AVMLockingService; -import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.blog.BlogService; import org.alfresco.service.cmr.calendar.CalendarService; import org.alfresco.service.cmr.coci.CheckOutCheckInService; @@ -79,10 +74,6 @@ import org.alfresco.service.descriptor.DescriptorService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; -import org.alfresco.wcm.asset.AssetService; -import org.alfresco.wcm.preview.PreviewURIService; -import org.alfresco.wcm.sandbox.SandboxService; -import org.alfresco.wcm.webproject.WebProjectService; /** @@ -147,19 +138,6 @@ public interface ServiceRegistry static final QName CALENDAR_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CalendarService"); static final QName NOTIFICATION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "NotificationService"); - // WCM / AVM - static final QName AVM_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AVMService"); - static final QName AVM_LOCKING_AWARE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AVMLockingAwareService"); - static final QName AVM_SYNC_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AVMSyncService"); - static final QName CROSS_REPO_COPY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CrossRepositoryCopyService"); - static final QName AVM_LOCKING_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AVMLockingService"); - static final QName VIRT_SERVER_REGISTRY = QName.createQName(NamespaceService.ALFRESCO_URI, "VirtServerRegistry"); - static final QName DEPLOYMENT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "DeploymentService"); - static final QName WEBPROJECT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "WebProjectService"); - static final QName SANDBOX_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "SandboxService"); - static final QName ASSET_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AssetService"); - static final QName PREVIEW_URI_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "WCMPreviewURIService"); - // CMIS static final QName CMIS_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CMISService"); static final QName CMIS_DICTIONARY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CMISDictionaryService"); @@ -370,27 +348,6 @@ public interface ServiceRegistry @NotAuditable AuditService getAuditService(); - /** - * Get the AVMService. - * @return The AVM service (or null if one is not provided); - */ - @NotAuditable - AVMService getAVMService(); - - /** - * Get the AVMLockingAwareService. - * @return The AVM locking aware service (or null if one is not provided); - */ - @NotAuditable - AVMService getAVMLockingAwareService(); - - /** - * Get the AVM Sync Service. - * @return The AVM Sync Service. - */ - @NotAuditable - AVMSyncService getAVMSyncService(); - /** * Get the ownable service (or null if one is not provided) * @return @@ -400,140 +357,72 @@ public interface ServiceRegistry /** * Get the person service (or null if one is not provided) - * @return */ @NotAuditable PersonService getPersonService(); /** * Get the site service (or null if one is not provided) - * @return */ @NotAuditable SiteService getSiteService(); - /** - * Get the cross repository copy service (or null if one is not provided) - * @return - */ - @NotAuditable - CrossRepositoryCopyService getCrossRepositoryCopyService(); - /** * Get the attribute service (or null if one is not provided) - * @return */ @NotAuditable AttributeService getAttributeService(); - /** - * Get the AVM locking service (or null if one is not provided) - * @return - */ - @NotAuditable - AVMLockingService getAVMLockingService(); - - /** - * Get the Virtualisation Server registry service bean - * @return - */ - @NotAuditable - VirtServerRegistry getVirtServerRegistry(); - /** * Get the Multilingual Content Service - * @return */ @NotAuditable MultilingualContentService getMultilingualContentService(); /** * Get the Edition Service - * @return */ @NotAuditable EditionService getEditionService(); /** * Get the Thumbnail Service - * @return */ @NotAuditable ThumbnailService getThumbnailService(); /** * Get the Tagging Service - * @return */ @NotAuditable TaggingService getTaggingService(); - /** - * Get the WCM Deployment Service - * @return the deployment service (or null, if one is not provided) - */ - @NotAuditable - DeploymentService getDeploymentService(); - - /** - * Get the WCM WebProject Service - * @return - */ - @NotAuditable - WebProjectService getWebProjectService(); - - /** - * Get the WCM Sandbox Service - * @return - */ - @NotAuditable - SandboxService getSandboxService(); - - /** - * Get the WCM Asset Service - * @return - */ - @NotAuditable - AssetService getAssetService(); - - /** - * Get the WCM Preview URI Service - * @return - */ - @NotAuditable - PreviewURIService getPreviewURIService(); - /** * Get the form service (or null if one is not provided) - * @return */ @NotAuditable FormService getFormService(); /** * Get the rendition service (or null if one is not provided) - * @return */ @NotAuditable RenditionService getRenditionService(); /** * Get the rating service (or null if one is not provided) - * @return */ @NotAuditable RatingService getRatingService(); /** * Get the node locator service (or null if one is not provided) - * @return */ @NotAuditable NodeLocatorService getNodeLocatorService(); /** * Get the blog service (or null if one is not provided) - * @return * * @since 4.0 */ @@ -542,7 +431,6 @@ public interface ServiceRegistry /** * Get the calendar service (or null if one is not provided) - * @return * * @since 4.0 */ diff --git a/source/java/org/alfresco/service/cmr/avm/AVMBadArgumentException.java b/source/java/org/alfresco/service/cmr/avm/AVMBadArgumentException.java deleted file mode 100644 index 357b26fa34..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/AVMBadArgumentException.java +++ /dev/null @@ -1,70 +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 . */ - -package org.alfresco.service.cmr.avm; - - -/** - * This is thrown when bad or illegal arguments are passed. - * @author britt - */ -public class AVMBadArgumentException extends AVMException -{ - private static final long serialVersionUID = -3651428546518806565L; - - /** - * @param msgId - */ - public AVMBadArgumentException(String msgId) - { - super(msgId); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param msgParams - */ - public AVMBadArgumentException(String msgId, Object[] msgParams) - { - super(msgId, msgParams); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param cause - */ - public AVMBadArgumentException(String msgId, Throwable cause) - { - super(msgId, cause); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param msgParams - * @param cause - */ - public AVMBadArgumentException(String msgId, Object[] msgParams, - Throwable cause) - { - super(msgId, msgParams, cause); - // TODO Auto-generated constructor stub - } -} diff --git a/source/java/org/alfresco/service/cmr/avm/AVMCycleException.java b/source/java/org/alfresco/service/cmr/avm/AVMCycleException.java deleted file mode 100644 index f69ab72f4a..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/AVMCycleException.java +++ /dev/null @@ -1,69 +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 . */ - -package org.alfresco.service.cmr.avm; - - -/** - * This is thrown when a cycle is detected during lookup. - * @author britt - */ -public class AVMCycleException extends AVMException -{ - private static final long serialVersionUID = -7390775107865356648L; - - /** - * @param msgId - */ - public AVMCycleException(String msgId) - { - super(msgId); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param msgParams - */ - public AVMCycleException(String msgId, Object[] msgParams) - { - super(msgId, msgParams); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param cause - */ - public AVMCycleException(String msgId, Throwable cause) - { - super(msgId, cause); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param msgParams - * @param cause - */ - public AVMCycleException(String msgId, Object[] msgParams, Throwable cause) - { - super(msgId, msgParams, cause); - // TODO Auto-generated constructor stub - } -} diff --git a/source/java/org/alfresco/service/cmr/avm/AVMException.java b/source/java/org/alfresco/service/cmr/avm/AVMException.java deleted file mode 100644 index b0666f047d..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/AVMException.java +++ /dev/null @@ -1,66 +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 . */ - -package org.alfresco.service.cmr.avm; - -import org.alfresco.error.AlfrescoRuntimeException; - -/** - * Class for generic AVM Exceptions. - * @author britt - */ -public class AVMException extends AlfrescoRuntimeException -{ - private static final long serialVersionUID = -4894449240293309025L; - - /** - * @param msgId - */ - public AVMException(String msgId) - { - super(msgId); - } - - /** - * @param msgId - * @param msgParams - */ - public AVMException(String msgId, Object[] msgParams) - { - super(msgId, msgParams); - } - - /** - * @param msgId - * @param cause - */ - public AVMException(String msgId, Throwable cause) - { - super(msgId, cause); - } - - /** - * @param msgId - * @param msgParams - * @param cause - */ - public AVMException(String msgId, Object[] msgParams, Throwable cause) - { - super(msgId, msgParams, cause); - } -} diff --git a/source/java/org/alfresco/service/cmr/avm/AVMExistsException.java b/source/java/org/alfresco/service/cmr/avm/AVMExistsException.java deleted file mode 100644 index 5684935079..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/AVMExistsException.java +++ /dev/null @@ -1,69 +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 . */ - -package org.alfresco.service.cmr.avm; - - -/** - * This is thrown when a node exists and shouldn't. - * @author britt - */ -public class AVMExistsException extends AVMException -{ - private static final long serialVersionUID = -5079803858722700975L; - - /** - * @param msgId - */ - public AVMExistsException(String msgId) - { - super(msgId); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param msgParams - */ - public AVMExistsException(String msgId, Object[] msgParams) - { - super(msgId, msgParams); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param cause - */ - public AVMExistsException(String msgId, Throwable cause) - { - super(msgId, cause); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param msgParams - * @param cause - */ - public AVMExistsException(String msgId, Object[] msgParams, Throwable cause) - { - super(msgId, msgParams, cause); - // TODO Auto-generated constructor stub - } -} diff --git a/source/java/org/alfresco/service/cmr/avm/AVMNodeDescriptor.java b/source/java/org/alfresco/service/cmr/avm/AVMNodeDescriptor.java deleted file mode 100644 index 4d43a80276..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/AVMNodeDescriptor.java +++ /dev/null @@ -1,529 +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 . */ - -package org.alfresco.service.cmr.avm; - -import java.io.Serializable; - -import org.alfresco.repo.avm.AVMNodeType; - -/** - * This class describes an AVM node object. - * It serves a similar purpose to the data structure - * returned by the stat() system call in UNIX. - * - * @author britt - */ -public class AVMNodeDescriptor implements Serializable -{ - private static final long serialVersionUID = -7959606980486852184L; - - /** - * The path that this was looked up with. - */ - private String fPath; - - /** - * The base name of the path. - */ - private String fName; - - /** - * The type of this node. AVMNodeType constants. - */ - private int fType; - - /** - * The Owner. - */ - private String fOwner; - - /** - * The Creator. - */ - private String fCreator; - - /** - * The last modifier. - */ - private String fLastModifier; - - /** - * The Create date. - */ - private long fCreateDate; - - /** - * The Modification date. - */ - private long fModDate; - - /** - * The Access date. - */ - private long fAccessDate; - - /** - * The object id. - */ - private long fID; - - /** - * The version number. - */ - private int fVersionID; - - /** - * The indirection if this is a layer. - */ - private String fIndirection; - - /** - * The indirection version if this is a layer. - */ - private int fIndirectionVersion; - - /** - * Is this a primary indirection node. - */ - private boolean fIsPrimary; - - /** - * The layer id or -1 if this is not a layered node. - */ - private long fLayerID; - - /** - * The length, if this is a file or -1 otherwise. - */ - private long fLength; - - /** - * The opacity for layered directories. - */ - private boolean fOpacity; - - /** - * The type of node that this is a deleted node for. - * Only for DeletedNode. - */ - private int fDeletedType; - - /** - * The GUID for the node. - */ - private String fGuid; - - /** - * Make one up. - * @param path The looked up path. - * @param type The type of the node. - * @param creator The creator of the node. - * @param owner The owner of the node. - * @param lastModifier The last modifier of the node. - * @param createDate The creation date. - * @param modDate The modification date. - * @param accessDate The access date. - * @param id The object id. - * @param versionID The version id. - * @param guid The GUID. - * @param indirection The indirection. - * @param indirectionVersion The indirection version. - * @param isPrimary Whether this is a primary indirection. - * @param layerID The layer id. - * @param length The file length. - * @param deletedType The type of node that was deleted. - */ - public AVMNodeDescriptor(String path, - String name, - int type, - String creator, - String owner, - String lastModifier, - long createDate, - long modDate, - long accessDate, - long id, - String guid, - int versionID, - String indirection, - int indirectionVersion, - boolean isPrimary, - long layerID, - boolean opacity, - long length, - int deletedType) - { - fPath = path; - fName = name; - fType = type; - fCreator = creator; - fOwner = owner; - fLastModifier = lastModifier; - fCreateDate = createDate; - fModDate = modDate; - fAccessDate = accessDate; - fID = id; - fGuid = guid; - fVersionID = versionID; - fIndirection = indirection; - fIndirectionVersion = indirectionVersion; - fIsPrimary = isPrimary; - fLayerID = layerID; - fLength = length; - fOpacity = opacity; - fDeletedType = deletedType; - } - - /** - * Get the last access date in java milliseconds. - * @return The last access date. - */ - public long getAccessDate() - { - return fAccessDate; - } - - /** - * Get the creation date in java milliseconds. - * @return The creation date. - */ - public long getCreateDate() - { - return fCreateDate; - } - - /** - * Get the user who created this. - * @return The creator. - */ - public String getCreator() - { - return fCreator; - } - - /** - * Get the indirection path if this is layered or null. - * @return The indirection path or null. - */ - public String getIndirection() - { - return fIndirection; - } - - /** - * Get the indirection version. - * @return The indirection version. - */ - public int getIndirectionVersion() - { - return fIndirectionVersion; - } - - /** - * Is this a primary indirection node. Will always - * be false for non-layered nodes. - * @return Whether this is a primary indirection node. - */ - public boolean isPrimary() - { - return fIsPrimary; - } - - /** - * Determines whether this node corresponds to - * either a plain or layered file. - *

- * NOTE: A deleted file node is not considered a file - * (i.e.: isFile() returns false when isDeleted() returns true). - * Therefore, use isDeletedFile() to determine if a deleted node - * was a file, not isFile(). - * - * @return true if AVMNodeDescriptor is a plain or layered file, - * otherwise false. - */ - public boolean isFile() - { - return ( fType == AVMNodeType.PLAIN_FILE || - fType == AVMNodeType.LAYERED_FILE - ); - } - - /** - * Determines whether this node corresponds to - * a plain (non-layered) file. - * - * @return true if AVMNodeDescriptor is a plain file, otherwise false. - */ - public boolean isPlainFile() - { - return (fType == AVMNodeType.PLAIN_FILE); - } - - /** - * Determines whether this node corresponds to - * a layered file. - * - * @return true if AVMNodeDescriptor is a layered file, - * otherwise false. - */ - public boolean isLayeredFile() - { - return (fType == AVMNodeType.LAYERED_FILE); - } - - /** - * Determines whether this node corresponds to - * either a plain or layered directory. - *

- * NOTE: A deleted directory node is not considered a directory - * (i.e.: isDirectory() returns false when isDeleted() returns true). - * Therefore, use isDeletedDirectory() to determine if a deleted node - * was a directory, not isDirectory(). - * - * @return true if AVMNodeDescriptor is a plain or layered directory, - * otherwise false. - */ - public boolean isDirectory() - { - return ( fType == AVMNodeType.PLAIN_DIRECTORY || - fType == AVMNodeType.LAYERED_DIRECTORY - ); - } - - /** - * Determines whether this node corresponds to - * a plain (non-layered) directory. - * - * @return true if AVMNodeDescriptor is a plain directory, otherwise false. - */ - public boolean isPlainDirectory() - { - return (fType == AVMNodeType.PLAIN_DIRECTORY ); - } - - /** - * Determines whether this node corresponds to - * a layered directory. - * - * @return true if AVMNodeDescriptor is a layered directory, - * otherwise false. - */ - public boolean isLayeredDirectory() - { - return (fType == AVMNodeType.LAYERED_DIRECTORY ); - } - - /** - * Is this a deleted node. - * @return Whether this node is a deleted node. - */ - public boolean isDeleted() - { - return fType == AVMNodeType.DELETED_NODE; - } - - /** - * Get the user who last modified this node. - * @return Who last modified this node. - */ - public String getLastModifier() - { - return fLastModifier; - } - - /** - * Get the layer id of this node. - * @return The layer id if there is one or -1. - */ - public long getLayerID() - { - return fLayerID; - } - - /** - * Get the modification date of this node. - * @return The modification date. - */ - public long getModDate() - { - return fModDate; - } - - /** - * Get the owner of this node. - * @return The owner of this node. - */ - public String getOwner() - { - return fOwner; - } - - /** - * Get the path that this node was looked up by. - * - * The format is the full store reference. Consisting of the store + ":" + path - * e.g. 79170e-675e-4b35-b1b1-3aee463c170b:/avm/ibatis/.svn/tmp/text-base - * @return The full path of this AVM node. - */ - public String getPath() - { - return fPath; - } - - /** - * Get the type of this node. AVMNodeType constants. - * @return The type node. - */ - public int getType() - { - return fType; - } - - /** - * Get the version id of this node. - * @return The version id of this node. - */ - public int getVersionID() - { - return fVersionID; - } - - /** - * Get the object id. - * @return The object id. - */ - public long getId() - { - return fID; - } - - /** - * Get the file length if applicable. - * @return The file length. - */ - public long getLength() - { - return fLength; - } - - /** - * Get the name of the node. - */ - public String getName() - { - return fName; - } - - /** - * @return the opacity - */ - public boolean getOpacity() - { - return fOpacity; - } - - /** - * Get a debuggable string representation of this. - * @return A string representation of this. - */ - @Override - public String toString() - { - switch (fType) - { - case AVMNodeType.PLAIN_FILE : - return "[PF:" + fID + ":" + fName + ", " + fVersionID + "]"; - case AVMNodeType.PLAIN_DIRECTORY : - return "[PD:" + fID + ":" + fName + ", " + fVersionID + "]"; - case AVMNodeType.LAYERED_FILE : - return "[LF:" + fID + ":" + fIndirection + ", " + fVersionID + "]"; - case AVMNodeType.LAYERED_DIRECTORY : - return "[LD:" + fID + ":" + fIndirection + ", " + fVersionID + "]"; - case AVMNodeType.DELETED_NODE : - return "[DN:" + fID + ", " + fVersionID + "]"; - default : - throw new AVMException("Internal Error."); - } - } - - /** - * Equals override. - * @param obj - * @return Equality. - */ - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (!(obj instanceof AVMNodeDescriptor)) - { - return false; - } - return fID == ((AVMNodeDescriptor)obj).fID; - } - - /** - * Hashcode override. - * @return The objid as hashcode. - */ - @Override - public int hashCode() - { - return (int)fID; - } - - /** - * Get the type of node that a deleted node is standing in for. - */ - public int getDeletedType() - { - return fDeletedType; - } - - /** - * Is this a deleted directory? - */ - public boolean isDeletedDirectory() - { - return fType == AVMNodeType.DELETED_NODE && - (fDeletedType == AVMNodeType.LAYERED_DIRECTORY || - fDeletedType == AVMNodeType.PLAIN_DIRECTORY); - } - - /** - * Is this a deleted file? - */ - public boolean isDeletedFile() - { - return fType == AVMNodeType.DELETED_NODE && - (fDeletedType == AVMNodeType.LAYERED_FILE || - fDeletedType == AVMNodeType.PLAIN_FILE); - } - - /** - * Get the GUID for the node. - */ - public String getGuid() - { - return fGuid; - } -} diff --git a/source/java/org/alfresco/service/cmr/avm/AVMNotFoundException.java b/source/java/org/alfresco/service/cmr/avm/AVMNotFoundException.java deleted file mode 100644 index 05485c2724..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/AVMNotFoundException.java +++ /dev/null @@ -1,69 +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 . */ - -package org.alfresco.service.cmr.avm; - - -/** - * This is the exception thrown when a node is not found. - * @author britt - */ -public class AVMNotFoundException extends AVMException -{ - private static final long serialVersionUID = -8131080195448129281L; - - /** - * @param msgId - * @param msgParams - * @param cause - */ - public AVMNotFoundException(String msgId, Object[] msgParams, Throwable cause) - { - super(msgId, msgParams, cause); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param msgParams - */ - public AVMNotFoundException(String msgId, Object[] msgParams) - { - super(msgId, msgParams); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param cause - */ - public AVMNotFoundException(String msgId, Throwable cause) - { - super(msgId, cause); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - */ - public AVMNotFoundException(String msgId) - { - super(msgId); - // TODO Auto-generated constructor stub - } -} diff --git a/source/java/org/alfresco/service/cmr/avm/AVMReadOnlyException.java b/source/java/org/alfresco/service/cmr/avm/AVMReadOnlyException.java deleted file mode 100644 index 5935fa00e1..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/AVMReadOnlyException.java +++ /dev/null @@ -1,65 +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 . - */ -package org.alfresco.service.cmr.avm; - -/** - * A Debugging exception. - * @author britt - */ -public class AVMReadOnlyException extends AVMException -{ - private static final long serialVersionUID = 5074287797390504317L; - - /** - * @param msgId - */ - public AVMReadOnlyException(String msgId) - { - super(msgId); - } - - /** - * @param msgId - * @param msgParams - */ - public AVMReadOnlyException(String msgId, Object[] msgParams) - { - super(msgId, msgParams); - } - - /** - * @param msgId - * @param cause - */ - public AVMReadOnlyException(String msgId, Throwable cause) - { - super(msgId, cause); - } - - /** - * @param msgId - * @param msgParams - * @param cause - */ - public AVMReadOnlyException(String msgId, Object[] msgParams, - Throwable cause) - { - super(msgId, msgParams, cause); - } -} diff --git a/source/java/org/alfresco/service/cmr/avm/AVMService.java b/source/java/org/alfresco/service/cmr/avm/AVMService.java deleted file mode 100644 index bb81583a57..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/AVMService.java +++ /dev/null @@ -1,1403 +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 . - */ - -package org.alfresco.service.cmr.avm; - -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.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; - -/** - * Service interface for the Alfresco Versioning Model (AVM).
- * For the remote API, see: {@link org.alfresco.service.cmr.remote.AVMRemote AVMRemote}. - *

- * - * Because the AVM is a - * - * versioning repository, - * fully explicit references to the nodes within it consist of an - * absolute AVM path, and a version ID. Absolute AVM paths are of - * the form:  <store-name>:<store-relative-path>. - *

- * For example:  mystore:/www/avm_webapps/ROOT/x/y/z.html - *

- * Within AVMService, whenever an API takes a path - * and a name, the path is the parent - * directory in which the name appears. - * Whenever just a path is needed by an API, it is an absolute - * path to a file or directory. - *

- * The special version ID -1 (negative one) - * refers to the latest read/write version at the given absolute AVM path. - * Non-negative version ID values refer to read-only snapshots of a store. - * For this reason, the version ID -1 - * is implicit for all write operations. Sometimes, - * -1 is referred to as the - * HEAD version (a term that should be - * already be familiar to users of other versioning systems like - * CVS - * and SVN). - *

- * Snapshots can be created explicitly via a call to - * {@link #createSnapshot(String store, String tag, String description) createSnapshot}, - * or implicitly by various APIs in this interface and in - * {@link org.alfresco.service.cmr.avmsync.AVMSyncService AVMSyncService}. - * Although a new snapshot of a store will have version a ID one higher - * than the previous snapshot in that store, the history of an AMV store - * does not necessarily contain a continuous range of version ID values, - * because {@link #purgeVersion(int version, String name) purgeVersion} - * may have been called. Regardless of whether - * {@link #purgeVersion(int version, String name) purgeVersion} - * has been called, the AVM never recycles version ID values - * within a store. - * - * @author britt - */ -public interface AVMService -{ - /** - * Get an InputStream for reading the contents of a - * file identified by its version ID and AVM path. - * This method can be used for either plain or layered files. - * - * @param version The version ID to look in. - * @param path The absolute path to the file. - * @return An InputStream for the designated file. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public InputStream getFileInputStream(int version, String path); - - /** - * Get an InputStream for reading the contents of a - * file node identified by its descriptor. - * This method can be used for either plain or layered files. - * - * @param desc The descriptor. - * @return An InputStream. - * @throws AVMNotFoundException - */ - public InputStream getFileInputStream(AVMNodeDescriptor desc); - - /** - * Get an output stream to write to a file - * identified by an AVM path. This file must already exist. - * This method can be used for either plain or layered files. - * - * To create a plain file, see: - * {@link #createFile(String path, String name) createFile}. - * To create a layered file, see: - * {@link #createLayeredFile(String targetPath, String parent, String name) createLayeredFile}. - * - * @param path The absolute path to the file. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public OutputStream getFileOutputStream(String path); - - - /** - * Get a non-recursive listing of a directory - * identified by its version ID and path. - * If path does not refer to a directory - * node, AVMWrongTypeException is thrown. - * - * @param version The version ID to look in. - * @param path The absolute AVM path to the file. - * @return A Map of names to descriptors. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public SortedMap getDirectoryListing(int version, String path); - - /** - * Get a non-recursive listing of nodes contained by a directory identified - * by its version ID and path, but exclude all nodes that are only - * contained "indirectly" via layering. - *

- * If this function is called on a "plain" (non-layered) directory, - * it is equivalent to - * {@link #getDirectoryListing(int version, String path) getDirectoryListing}. - * - * @param version The version to look up. - * @param path The full path to get listing for. - * @return A Map of names to descriptors. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public SortedMap - getDirectoryListingDirect(int version, String path); - - /** - * Get a non-recursive directory listing of a directory node - * identified by a node descriptor. - * - * @param dir The directory node descriptor. - * @return A sorted Map of names to node descriptors. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public SortedMap getDirectoryListing(AVMNodeDescriptor dir); - - /** - * Get a non-recursive directory listing of a directory node - * identified by a node descriptor. Only return children matching the given pattern. - * '*' match any number of characters - equivalent to SQL '%' - * '?' match a single character - equivalent to SQL '_' - * '\' escape - valid sequences "\\", "\*" and "\?" - * - * @param dir The directory node descriptor. - * @param childPattern - * @return A sorted Map of names to node descriptors. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public SortedMap getDirectoryListing(AVMNodeDescriptor dir, String childNamePattern); - - /** - * Non-recursively get the names of nodes that have been deleted in - * a directory identified by a version ID and a path - * - * @param version The version to look under. - * @param path The path of the directory. - * @return A List of names. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public List getDeleted(int version, String path); - - - /** - * Create a new "plain" (non-layered) file within a path. - * This function fails if the file already exists, - * or if the directory identified by path - * does not exist. - * - * @param path The path of the directory containing the created file. - * @param name The name of the new file - * @throws AVMNotFound - * @throws AVMExists - * @throws AVMWrongType - * @return An opaque handle to a server side output stream. - */ - public OutputStream createFile(String path, String name); - - /** - * Create a new directory. - * If path is within a layer, the new directory will be a layered directory; - * otherwise, the new directory will be a plain directory. - * - * @param path The simple absolute path to the parent. - * @param name The name to give the directory. - * @throws AVMNotFound - * @throws AVMExists - * @throws AVMWrongType - */ - public void createDirectory(String path, String name); - - /** - * Create a new layered file. - *

- * Note: the target of the indirection does not need to exist at - * the time the layered file node is created. - * - * @param targetPath The absolute path of the underlying file being pointed at - * @param parent The absolute path of the directory containing layered file to be created - * @param name The name of the layered file to be created - * @throws AVMNotFound - * @throws AVMExists - * @throws AVMWrongType - * - * @deprecated - */ - public void createLayeredFile(String targetPath, String parent, String name); - - - /** - * Create a new layered directory. In whatever context this is created, this - * will be a layered directory that has a primary indirection. - *

- * Note: a "primary" indirection is one in which the target is explicitly set; - * "non-primary" indirect nodes compute their effective target dynamically - * on the basis of their relative position to the closest "primary" - * indirect node that contains them. Therefore, changing the target of a - * "primary" layered directory node immediately alters the indirection - * targets computed by the "non-primary" layered nodes it contains. - *

- * Note: the target of the indirection does not need to exist at - * the time the layered directory node is created. - * - * @param targetPath The absolute path to the underlying directory that - * the layered directory being created will point at. - * @param parent The absolute path to directory containing the layered directory being created. - * @param name The name of the layered directory being created - * @throws AVMNotFound - * @throws AVMExists - * @throws AVMWrongType - */ - public void createLayeredDirectory(String targetPath, String parent, String name); - - - /** - * Retarget a layered directory. - * Change the target pointed to by a layered directory node. - * This has the side effect of making the layered directory - * a primary indirection if the layered directory's indirection - * was "non-primary". - * - * @param path Path to the layered directory. - * @param target The new indirection target of the layered directory - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public void retargetLayeredDirectory(String path, String target); - - - /** - * Create a new AVMStore. - * All stores are top level objects within the AVM repository. - * The AVM is a forest of versioned trees; each versioned - * tree is contained within a AVM store with a unique - * name. If a store is removed via - * {@link purgeStore(String name) purgeStore}, the name of - * the deleted store can be reused in a later call to - * {@link createStore(String name) createStore}. - *

- * The store name must be non-null, cannot be the empty string, - * and must not contain characters that are illegal in - * normal file names. - * - * @param name The name of the new AVMStore. - * @throws AVMExistsException - */ - public void createStore(String name); - - /** - * Create a new AVMStore with store properties (equivalent to createStore + setProperties) - * - * @param name The name of the new AVMStore. - * @param props A Map of the properties to set. - * @throws AVMExistsException - * @since 3.2 - */ - public void createStore(String name, Map props); - - - /** - * Create a branch from a given version and path. As a side effect, - * an automatic snapshot is taken of the store that contains the - * node that is being branched from. - * - * @param version The version number from which to make the branch. - * @param srcPath The path to the node to branch from. - * @param dstPath The path to the directory to contain the new branch. - * @param name The name to give the new branch. - * @throws AVMNotFoundException - * @throws AVMExistsException - * @throws AVMWrongTypeException - */ - public void createBranch(int version, String srcPath, String dstPath, String name); - - - /** - * Remove a file or directory from its parent directory. - * In a layered context, the newly deleted node will hide - * a file of the same name in the corresponding layer below. - *

- * If instead you want to make the file in the lower layer visible - * via transparency, see: - * {@link uncover(String dirPath, String name) uncover}. - * If you want to perform a removal and an uncover - * operation atomically, see: - * {@link #makeTransparent(String dirPath, String name) makeTransparent}. - * - * - *

- * Caution: this removes directories even if they are not empty. - * - *

- * Note: developers of records management systems must also - * be aware that the AVMNode corresponding to the - * parent directory and name - * provided might still be accessible via different - * path lookups after this function has completed; - * this because branching and versioning operations create - * manifestations of nodes in a manner that is similar - * to a UNIX hard link. If you need to discover every - * possible path that could retrieve the associated AVMNode, see: - * {@link #getPaths(AVMNodeDescriptor desc) getPaths}, - * {@link #getHeadPaths(AVMNodeDescriptor desc) getHeadPaths}, and - * {@link #getPathsInStoreHead(AVMNodeDescriptor desc) getPathsInStoreHead}. - * - * @param parent The absolute path to the parent directory. - * @param name The name of the child to remove. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public void removeNode(String parent, String name); - - - - /** - * Rename a file or directory. - * There are a number of things to note about the - * interaction of rename and layering: - *

- *

    - *
  • If you rename a layered directory into a non layered context, - * the layered directory continues to point to the same place - * it did before it was renamed, and automatically becomes a - * primary indirection node. - *
  • - * - *
  • If a plain directory is renamed into a layered context it - * remains a plain directory, thus acting as an opaque node - * in its new layered home. - *
  • - * - *
  • Renaming a layered node into a layered node leaves the renamed - * node pointing to the same place it did before the rename and - * makes it automatically a primary indirection node. - *
  • - * - *
  • After a layered node or directory is renamed, - * the directory that contained it acquires a - * "deleted" node in its place; therefore, - * if a layer beneath it contains a file or directory - * with the same name as the "deleted" node, it - * will not be visible via transparency - * (unless an {@link uncover(String dirPath, String name) uncover} - * operation is performed afterwards). - *
  • - *
- *

- * - * Note: if instead you want to rename an AVM store, see - * {@link #renameStore(String sourceName, String destName) renameStore}. - * - * @param srcParent The absolute path to the parent directory. - * @param srcName The name of the node in the src directory. - * @param dstParent The absolute path to the destination directory. - * @param dstName The name that the node will have in the destination directory. - * @throws AVMNotFoundException - * @throws AVMExistsException - */ - public void rename(String srcParent, String srcName, String dstParent, String dstName); - - - /** - * If a layered directory dirPath - * has a deleted entry of the given name, - * remove that name from the deleted list, - * so that if a layer below it contains an entry - * of this name, it can be seen via transparency - * from dirPath. - *

- * Note: if you are looking for an atomic operation - * that first deletes an object, then performs - * an "uncover" operation to make it transparent, see - * {@link #makeTransparent(String dirPath, String name) makeTransparent}. - * - * @param dirPath The path to the layered directory. - * @param name The name to uncover. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public void uncover(String dirPath, String name); - - - /** - * Gets the ID that the next snapshotted version of a store - * will have. - * - *

- * Note: unless the operations that require this value - * to be valid are performed within a transaction, - * this value can become "stale". - * - * @param storeName The name of the AVMStore. - * @return The next version ID of the AVMStore. - * @throws AVMNotFoundException - */ - public int getNextVersionID(String storeName); - - - /** - * Get the latest snapshot ID of a store. - * Note: All stores have at least one snapshot ID: 0; - * this is the "empty" snapshot taken when - * the store is first created. - * - * @param storeName The store name. - * @return The ID of the latest extant version of the store. - * @throws AVMNotFoundException - */ - public int getLatestSnapshotID(String storeName); - - - /** - * Snapshot the given AVMStore. - * When files have been modified since the previous snapshot, - * a new snapshot version is created; otherwise, no extra - * snapshot is actually taken. - *

- * When no snapshot is actually taken, but either 'tag' - * or 'store' are non-null, they will override the value for - * the last snapshot (i.e.: the old values will be discarded); - * however, if both 'tag' and 'description' are null then - * invoking createSnapshot when no files have been modified - * becomes a true no-op. - * - * @param store The name of the AVMStore to snapshot. - * @param tag The short description. - * @param description The thick description. - * @return A Map of all implicitly or explicitly snapshotted stores to last - * version id. - * @throws AVMNotFoundException - */ - public Map createSnapshot(String store, String tag, String description); - - - /** - * Get the set of versions in an AVMStore. The version ID values - * within this list will always be may appear out of order, - * and may contain missing values (due to the possibility that - * {@link #purgeStore(String name) purgeStore} operations have - * been performed). - * - * Because the number of versions that a store can contain - * may become large, this call can be a resource-intensive, - * and may even causing Out of Memory exceptions. - * - * @param name The name of the AVMStore. - * @return A Set of version descriptors. - * @throws AVMNotFoundException - */ - public List getStoreVersions(String name); - - - /** - * Get AVMStore version descriptors by creation date. Either - * from or to can be null but not both. - *

- *

    - *
  • - * If from is null, all versions earlier than - * to will be returned. - *
  • - * - *
  • - * If to is null, all versions later than - * from will be returned. - *
  • - *
- *

- * - * The order of the values returned is not guaranteed, nor are the version - * IDs necessarily free of "missing" values (due to the possibility that - * {@link #purgeStore(String name) purgeStore} operations have - * been performed). - * - *

- * Note: for portability, all dates are stored as 64-bit longs, with a - * time resolution of one millisecond. Therefore, aliasing/wrapping - * are not a concern unless you need to plan 292.4 million years ahead. - * If so, please contact your system administrator. - * - * @param name The name of the AVMStore. - * @param from Earliest date of version to include. - * @param to Latest date of version to include. - * @return The Set of version descriptors that match. - * @throws AVMNotFoundException - */ - public List getStoreVersions(String name, Date from, Date to); - - /** - * Get the descriptors of all AVMStores in the repository. - * - * @return A List of all AVMStores. - */ - public List getStores(); - - - /** - * Get a descriptor for an AVMStore. - * @param name The AVMStore's name. - * @return A Descriptor, or null if not found. - */ - public AVMStoreDescriptor getStore(String name); - - - /** - * A convenience method for getting the specified - * root directory of an AVMStore (e.g.: "mysite:/"). - * - * @param version The version to look up. - * @param name The name of the AVMStore. - * @return A descriptor for the specified root. - * @throws AVMNotFoundException - */ - public AVMNodeDescriptor getStoreRoot(int version, String name); - - - /** - * Lookup a node identified by version ID and path. - * - * @param version The version ID to look under. - * @param path The simple absolute path to the parent directory. - * @return An AVMNodeDescriptor, or null if the node does not exist. - */ - public AVMNodeDescriptor lookup(int version, String path); - - /** - * Lookup a node identified by version ID and path; optionally, - * if the node is deleted, its descriptor can still - * be retrieved. - * - * @param version The version ID to look under. - * @param path The simple absolute path to the parent directory. - * @param includeDeleted Whether to allow a deleted node to be retrieved - * @return An AVMNodeDescriptor, or null if the version does not exist. - */ - public AVMNodeDescriptor lookup(int version, String path, boolean includeDeleted); - - /** - * Lookup a node identified by the directory node that contains it, and its name. - * - * @param dir The descriptor for the directory node. - * @param name The name to lookup. - * @return The descriptor for the child. - * @throws AVMWrongTypeException If dir does not refer to a directory. - */ - public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name); - - - /** - * Lookup a node identified by the directory that contains it, and its name; - * optionally, the lookup can retrive the descriptor of a node even if - * it has been deleted from its containing directory. - * - * @param dir The descriptor for the directory node. - * @param name The name to lookup. - * @param includeDeleted Whether to allow a deleted node to be retrieved via the lookup - * @return The descriptor for the child, null if the child doesn't exist. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name, boolean includeDeleted); - - /** - * Get a single valid path to a given node. - * @param desc The descriptor of the node to which a version and path will be fetched. - * @return version and path. - * @throws AVMNotFoundException - */ - public Pair getAPath(AVMNodeDescriptor desc); - - - /** - * Get the indirection path for a node in a layered context - * whether that indirection path is primary or non-primary - * (or seen via transparency). - * - * If you call getIndirectionPath on a layered node, - * you'll fetch its explicitly set target; if you call - * this function on a non-primary indirection node or a - * node seen via transparency, you'll get back the path - * to the corresponding node in the underlying target. - *

- * For example, if "mysite--alice:/www" is a layered - * directory that targets "mysite:/www", and "mysite--alice" - * contains no content directly, then if the path - * path "mysite:/www/avm_webapps/ROOT/x/y/z" is valid, - * calling getIndirectionPath on - * "mysite--alice:/www/avm_webapps/ROOT/x/y/z" will yield - * "mysite:/www/avm_webapps/ROOT/x/y/z". - * - * @param version The version number to get. - * @param path The path to the node of interest. - * @return The indirection path, or null if the path is not in a layered context. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public String getIndirectionPath(int version, String path); - - - /** - * Purge an AVMStore. - * This completely removes an AVMStore. - *

- * Note: while the store being purged disappears from view - * immediately, any nodes that become unreachable as a result - * are deleted asynchronously. - * - * @param name The name of the AVMStore. - * @throws AVMNotFoundException - */ - public void purgeStore(String name); - - /** - * Purge a version from an AVMStore. - * Deletes everything that lives in the given version only. - * - * @param version The version to purge. - * @param name The name of the AVMStore from which to purge it. - * @throws AVMNotFoundException If name or version - * do not exist. - */ - public void purgeVersion(int version, String name); - - - /** - * Make a directory into a primary indirection node. - * @param path The full path. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public void makePrimary(String path); - - - /** - * Get a list of up to count nodes in the history chain of a node. - * The initial element of the list returned will be desc - * (as long as the count is non-zero). - * - * @param desc The descriptor for a node to find ancestors for. - * @param count maximum number of ancestors to return in the list - * (the value -1 means - * "no limit -- return them all") - * @return A List of ancestors starting with the most recent. - * @throws AVMNotFoundException - */ - public List getHistory(AVMNodeDescriptor desc, int count); - - /** - * Set the opacity of a layered directory. - * An opaque layered directory hides the contents of its indirection. - * - * @param path The path to the layered directory. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public void setOpacity(String path, boolean opacity); - - /** - * Get the common ancestor of two nodes if a common ancestor exists. - * This function is useful for detecting and merging conflicts. - * - * @param left The first node. - * @param right The second node. - * @return The common ancestor. There are four possible results. Null means - * that there is no common ancestor. Left returned means that left is strictly - * an ancestor of right. Right returned means that right is strictly an - * ancestor of left. Any other non null return is the common ancestor and - * indicates that left and right are in conflict. - * @throws AVMNotFoundException - */ - public AVMNodeDescriptor getCommonAncestor(AVMNodeDescriptor left, - AVMNodeDescriptor right); - - /** - * Get layering information about a path. - * The LayeringDescriptor returned can be used to determine - * whether a node is in the background (and if so, which - * AVM store contains it directly), or if it is directly - * contained by the AVM store referenced by path. - * - * - * @param version The version to look under. - * @param path The absolute AVM path. - * @return A LayeringDescriptor. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public LayeringDescriptor getLayeringInfo(int version, String path); - - /** - * Set a property on a node. - * - * @param path The path to the node to set the property on. - * @param name The QName of the property. - * @param value The property to set. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - 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 properties to set. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public void setNodeProperties(String path, Map properties); - - /** - * Get a property of a node by QName. - * - * @param version The version to look under. - * @param path The path to the node. - * @param name The QName. - * @return The PropertyValue or null if it doesn't exist. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public PropertyValue getNodeProperty(int version, String path, QName name); - - /** - * Get all the properties associated with a node that is identified - * by a version ID and a path. - * - * @param version The version to look under. - * @param path The path to the node. - * @return A Map of QNames to PropertyValues. - * @throws AVMNotFoundException - */ - public Map getNodeProperties(int version, String path); - - - /** - * Delete a property. - *

- * Note: to remove an apsect, see: {@link #removeAspect(String path, QName aspectName) removeAspect} - * - * @param path The path to the node. - * @param name The QName of the property to delete. - * @throws AVMNotFoundException - */ - public void deleteNodeProperty(String path, QName name); - - /** - * Delete all the properties attached to an AVM node. - *

- * Note: to remove an apsect, see: {@link #removeAspect(String path, QName aspectName) removeAspect} - * - * @param path The path to the node. - * @throws AVMNotFoundException - */ - public void deleteNodeProperties(String path); - - /** - * Set a property on a store. If the property exists it will be overwritten. - * - * @param store The store to set the property on. - * @param name The name of the property. - * @param value The value of the property. - * @throws AVMNotFoundException (if store does not exist) - */ - public void setStoreProperty(String store, QName name, PropertyValue value); - - /** - * Set a group of properties on a store. Existing properties will be overwritten. - * - * @param store The name of the store. - * @param props A Map of the properties to set. - * @throws AVMNotFoundException (if store does not exist) - */ - public void setStoreProperties(String store, Map props); - - /** - * Get a property from a store. - * - * @param store The name of the store. - * @param name The name of the property. - * @return A PropertyValue or null if non-existent. - * @throws AVMNotFoundException (if store does not exist) - */ - public PropertyValue getStoreProperty(String store, QName name); - - /** - * Get all the properties associated with a store. - * - * @param store The name of the store. - * @return A Map of the stores properties. - * @throws AVMNotFoundException (if store does not exist) - */ - public Map getStoreProperties(String store); - - /** - * Queries a given store for properties with keys that match a given pattern. - * - * @param store The name of the store. - * @param keyPattern The sql 'like' pattern, inserted into a QName. - * @return A Map of the matching key value pairs. - * - * @deprecated - */ - public Map queryStorePropertyKey(String store, QName keyPattern); - - - /** - * Delete a property on a store by name. - *

- * Note: to remove an apsect, see: {@link #removeAspect(String path, QName aspectName) removeAspect} - * - * @param store The name of the store. - * @param name The name of the property to delete. - * @throws AVMNotFoundException - */ - public void deleteStoreProperty(String store, QName name); - - - /** - * Add an aspect to an AVM node. - * - * @param path The path to the node. - * @param aspectName The QName of the aspect. - * @throws AVMNotFoundException - * @throws AVMExistsException - */ - public void addAspect(String path, QName aspectName); - - /** - * Get all the aspects on an AVM node. - * - * @param version The version to look under. - * @param path The path to the node. - * @return A Set of the QNames of the aspects. - * @throws AVMNotFoundException - */ - public Set getAspects(int version, String path); - - - /** - * Remove an aspect and its properties from a node. - * - * @param path The path to the node. - * @param aspectName The name of the aspect. - * @throws AVMNotFoundException - */ - public void removeAspect(String path, QName aspectName); - - /** - * Determines whether a node has a particular aspect. - * - * @param version The version to look under. - * @param path The path to the node. - * @param aspectName The aspect name to check. - * @return Whether the given node has the given aspect. - * @throws AVMNotFoundException - */ - public boolean hasAspect(int version, String path, QName aspectName); - - - /** - * Rename a store. - * - * @param sourceName The original name. - * @param destName The new name. - * @throws AVMNotFoundException - * @throws AVMExistsException - */ - public void renameStore(String sourceName, String destName); - - /** - * 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 node to revert. - * @param toRevertTo The descriptor of the version to revert to. - * @throws AVMNotFoundException - */ - public void revert(String path, AVMNodeDescriptor toRevertTo); - - - /** - * Set the GUID on a node. The GUID of a node uniquely identifies - * the state of a node, i.e. its content, metadata, and aspects. - * @param path The path to the node. - * @param guid The GUID to set. - */ - public void setGuid(String path, String guid); - - /** - * Set the mime type. - * @param path The path of the file. - * @param mimeType The mime type. - */ - public void setMimeType(String path, String mimeType); - - /** - * Set the encoding. - * @param path The path of the file. - * @param encoding The encoding. - */ - public void setEncoding(String path, String encoding); - - /** - * Queries all AVM stores for properties with keys that match a given pattern. - * - * @param keyPattern The sql 'like' pattern, inserted into a QName. - * @return A Map of store names to Maps of property key value pairs that match - * the pattern. - * - * @deprecated - */ - public Map> - queryStoresPropertyKeys(QName keyPattern); - - //------------------------------------------------------------------------- - // NOTE: The functions below should probably be included in AVMRemote - // but currently are not: - //------------------------------------------------------------------------- - - /** - * Create a new directory with aspects and properties. - * If path is within a layer, the new directory will be a layered directory; - * otherwise, the new directory will be a plain directory. - * - * @param path The simple absolute path to the parent. - * @param name The name to give the directory. - * @param aspects A list of aspects to add. - * @param properties A Map of properties to add. - * @throws AVMNotFound - * @throws AVMExists - * @throws AVMWrongType - */ - - public void createDirectory(String path, String name, List aspects, Map properties); - /** - * Create a new "plain" (non-layered) file. - * Guarantees that the entire contents of the - * input stream will be loaded atomically. - * The directory identified by path must already exist. - * - * @param path The path of the directory containing the created file. - * @param name The name of the new file - * @param in An input stream with data for the file. - * @throws AVMNotFound - * @throws AVMExists - * @throws AVMWrongType - */ - public void createFile(String path, String name, InputStream in); - - - /** - * Create a new "plain" (non-layered) file with aspects and properties. - * Guarantees that the entire contents of the - * input stream will be loaded atomically. - * The directory identified by path must already exist. - * - * @param path The path of the directory containing the created file. - * @param name The name of the new file - * @param in An input stream with data for the file. - * @param aspect A list of aspects to give the file. - * @param properties A map of properties to give the file. - * @throws AVMNotFound - * @throws AVMExists - * @throws AVMWrongType - */ - public void createFile(String path, String name, InputStream in, List aspects, Map properties); - - /** - * Get a non-recursive directory listing of a directory identified - * by a node descriptor; optionally, deleted nodes can be included - * in this listing. - * - * @param dir The directory node descriptor. - * @param includeDeleted Whether to include deleted nodes. - * @return A Map of names to node descriptors. - * @throws AVMNotFoundException If the descriptor is stale. - * @throws AVMWrongTypeException If the descriptor does not point at a directory. - */ - public SortedMap getDirectoryListing(AVMNodeDescriptor dir, - boolean includeDeleted); - - /** - * A convenience method to get a non-recursive directory listing - * as an Array from a directory identified by a node descriptor; - * optionally, deleted nodes can be included in this listing. - * - * This function is identical to - * {@link getDirectoryListing(AVMNodeDescriptor dir,boolean includeDeleted) getDirectoryListing} - * except that it returns an array. - * - * @param dir The descriptor pointing at the directory to list. - * @param includeDeleted Whether include deleted nodes - * @return An array of AVMNodeDescriptors. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public AVMNodeDescriptor [] getDirectoryListingArray(AVMNodeDescriptor dir, - boolean includeDeleted); - - /** - * Get a non-recursive listing of nodes contained directly, - * but exclude all nodes that are only contained "indirectly" - * (i.e.: via layering). This function is identical to - * {@link #getDirectoryListingDirect(int version, String path) getDirectoryListingDirect} - * but it has the option of including deleted nodes in the listing. - * - * @param version The version to look up. - * @param path The absolute AVM directory path to get a listing for. - * @param includeDeleted Whether to include deleted nodes. - * @return A Map of names to descriptors. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public SortedMap - getDirectoryListingDirect(int version, String path, boolean includeDeleted); - - - /** - * A convenience method to get a directory listing - * as an Array of AVMNodeDescriptors; this function - * is otherwise equivalent to - * {@link #getDirectoryListing(int version, String path, boolean includeDeleted) getDirectoryListing} - * - * @param version The version to look under. - * @param path The path to the directory to be listed. - * @param includeDeleted Whether to include deleted nodes - * @return An array of AVMNodeDescriptors. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public AVMNodeDescriptor [] getDirectoryListingArray(int version, String path, - boolean includeDeleted); - - /** - * Get a non-recursive listing of all the nodes contained by a directory - * identified by an AVMNodeDescriptor, excluding those that are only - * present "indirectly" via layering; optionally, deleted nodes that - * are directly contained can be included this listing. - * - * @param dir The directory descriptor. - * @param includeDeleted Whether to include directly contained deleted nodes - * @return A Map of Strings to descriptors. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public SortedMap - getDirectoryListingDirect(AVMNodeDescriptor dir, boolean includeDeleted); - - - /** - * Get a non-recursive listing of a directory node identified by its - * version ID and path; optionally, deleted notes can be included in - * this listing. - *

- * If instead, you wish to obtain a list of only - * the deleted nodes within a directory, see: - * {@link #getDeleted(int version, String path) getDeleted}. - * - * @param version The version ID to look in. - * @param path The absolute AVM path to the file. - * @param includeDeleted Whether to include deleted nodes - * @return A Map of names to descriptors. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public SortedMap getDirectoryListing(int version, String path, - boolean includeDeleted); - - /** - * A convenience method that removes a node specified by an AVM path. - * It merely parses an absolute path into a parent directory and a child - * name, then calls {@link #removeNode(parent, name) removeNode}. - * - * @param path The full path to the node to remove. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public void removeNode(String path); - - /** - * Atomically delete name within dirPath - * and {@link uncover(String dirPath, String name) uncover} - * it so whatever is underneath can be seen via transparency. - * If name corresponds to a deletion already, - * then the deletion step is skipped, and the "uncover" - * operation is performed. - * - * @param dirPath The path to the layered directory. - * @param name The name of the item this method will - * {@link org.alfresco.service.cmr.avmsync.AVMSyncService#flatten(String layerPath, String underlyingPath) flatten} - * - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public void makeTransparent(String dirPath, String name); - - /** - * Low-level internal function:   - * Retrieve the reserved "system" store. - * This method isn't currently used, - * but may be in some future release. - * - * @return The descriptor. - */ - public AVMStoreDescriptor getSystemStore(); - - /** - * Set all metadata on a node from another node. Aspects, properties, ACLs. - * - * @param path The path to the node to set. - * @param from The descriptor for the node to get metadata from. - * @throws AVMNotFoundException - */ - public void setMetaDataFrom(String path, AVMNodeDescriptor from); - - /** - * Low-level internal function:   Insert a node - * into a parent directly. Caution: this is not something - * one ordinary applications should do, but it is used - * internally by the AVMSyncService.update() method. - * This function may disappear from the public interface. - * - * @param parentPath The path to the parent directory. - * @param name The name to give the node. - * @param toLink A descriptor for the node to insert. - * @throws AVMNotFoundException - */ - public void link(String parentPath, String name, AVMNodeDescriptor toLink); - - /** - * Low-level internal function:   replace a node - * in a parent directly. Caution: this is not something - * one ordinary applications should do, but it is used - * internally by the AVMSyncService.update() method. - * This function may disappear from the public interface. - * - * @param parentPath The path to the parent directory. - * @param name The name to give the node. - * @param toLink A descriptor for the node to insert. - * @throws AVMNotFoundException - */ - public void updateLink(String parentPath, String name, AVMNodeDescriptor toLink); - - /** - * Low-level internal function:   Force a copy on write - * write event on the given node. This function is not usually - * needed, and may be removed from the public interface. - * - * @param path The path to force. - * @throws AVMNotFoundException - */ - public AVMNodeDescriptor forceCopy(String path); - - /** - * Perform a non-virtual (heavy-weight), and potentially recursive - * copy of the source into the destination directory. - * All node properties, access control lists (ACLs), - * and aspects are copied. - * - * @param srcVersion The version of the source. - * @param srcPath The path of the source directory. - * @param dstPath The directory containing the destination directory. - * @param name The name of the destination within dstPath. - * @throws AVMNotFoundException - */ - public void copy(int srcVersion, String srcPath, String dstPath, String name); - - - /** - * Get a list of all paths that a given node has. - * This can be an extremely expensive operation due to the large number - * of paths to an AVMNodeDescriptor that can be generated - * via branching and versioning. For example, if an asset - * is present in the initial version of a store, and - * that store has been versioned 10,000 times, - * there are a minimum of 10,000 paths that lead to it. - * The effect of branching is multiplicative. - *

- * Note: paths that only access desc - * via transparency are not returned by this function; - * only "direct" containment relationships are considered. - *

- * For those concerned with records management applications, - * it's worth noting that once every path to an asset has - * been deleted, the system will purge it entirely in an - * asynchronous manner. - * - * @param desc The node descriptor to get paths for. - * @return A List of version, path Pairs. - * @throws AVMNotFoundException - */ - public List> getPaths(AVMNodeDescriptor desc); - - /** - * Get all paths that a given node has that are in the - * HEAD version ( -1 ). - * This can be an expensive operation but less so than getPaths(). - * - * @param desc The node descriptor to get paths for. - * @return A List of version, path Pairs. - * @throws AVMNotFoundException - */ - public List> getHeadPaths(AVMNodeDescriptor desc); - - /** - * Get all paths to a node starting at the - * HEAD version ( -1 ) - * of a store. This can be an expensive operation but less so than getHeadPaths(). - * - * @param desc The node descriptor. - * @param store The store. - * @return A List of all paths meeting the criteria. - * @throws AVMNotFoundException - */ - public List> getPathsInStoreHead(AVMNodeDescriptor desc, String store); - - /** - * Get all paths to a given node in a single store in a single non-head version. - * @param desc The node descriptor. - * @param store The name of the store. - * @param version The version. - * @return A List of AVM paths. - */ - public List getPathsInStoreVersion(AVMNodeDescriptor desc, String store, int version); - - /** - * Get all the properties associated with a node identified by a descriptor. - * @param desc The node descriptor - * @return A Map of the properties. - * @throws AVMNotFoundException - */ - public Map getNodeProperties(AVMNodeDescriptor desc); - - /** - * Get all the aspects from a node descriptor. - * @param desc The node descriptor. - * @return The Set of Aspects. - */ - public Set getAspects(AVMNodeDescriptor desc); - - - - - - //------------------------------------------------------------------------- - // NOTE: The functions from here down will never be part of AVMRemote - //------------------------------------------------------------------------- - - /** - * Low-level internal function:   Fetch a content reader for a file node. - * - * This function is similar to - * {@link getFileInputStream(int version, String path) getFileInputStream}; - * however, it can be used to fetch either InputStream or a - * random-access nio channel. - * - * @param version The version ID of the file. - * @param path The absolute AVM path to the file. - * @return A ContentReader. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public ContentReader getContentReader(int version, String path); - - /** - * Low-level internal function:   Fetch a ContentWriter to a file node. - * - * @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. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public ContentWriter getContentWriter(String path, boolean update); - - /** - * Low-level internal function:   Get the ContentData for - * a node in a read context. Only applies to a file. - * - * @param version The version to look under. - * @param path The path to the node. - * @return The ContentData object. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public ContentData getContentDataForRead(int version, String path); - - /** - * Get ContentData using only a node descriptor. - * @param desc The node descriptor. - * @return The ContentData - * @throws AVMNotFoundException - */ - public ContentData getContentDataForRead(AVMNodeDescriptor desc); - - - /** - * Low-level internal function:   Get the ContentData for - * a node in a write context. - * - * @param path The path to the node. - * @return The ContentData object. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public ContentData getContentDataForWrite(String path); - - /** - * Low-level internal function:   Set the content data on a file. - * - * @param path The path to the file. - * @param data The ContentData to set. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public void setContentData(String path, ContentData data); - - /** - * Get all versions from the last down to and including the one specified - * Returned in descending version id. - * @param name - * @param version - * @return list of version descriptors - */ - public List getStoreVersionsFrom(String name, int version); - - /** - * Get all versions from the first up to and including the one specified - * Returned in ascending version id order. - * @param name - * @param version - * @return list of version descriptors - */ - public List getStoreVersionsTo(String name, int version); - - /** - * Get all versions from an including startVersion up to but NOT including endVersion - * @param name - * @param startVersion - * @param endVersion - * @return list of version descriptors - */ - public List getStoreVersionsBetween(String name, int startVersion, int endVersion); - -} diff --git a/source/java/org/alfresco/service/cmr/avm/AVMStoreDescriptor.java b/source/java/org/alfresco/service/cmr/avm/AVMStoreDescriptor.java deleted file mode 100644 index a935e72ad5..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/AVMStoreDescriptor.java +++ /dev/null @@ -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 . */ - -package org.alfresco.service.cmr.avm; - -import java.io.Serializable; -import java.util.Date; - -import org.springframework.extensions.surf.util.ISO8601DateFormat; - -/** - * A value class for Data about an AVMStore. - * @author britt - */ -public class AVMStoreDescriptor implements Serializable -{ - private static final long serialVersionUID = -4401863082685362175L; - - /** - * The object id. - */ - private long fID; - - /** - * The name. - */ - private String fName; - - /** - * The creator. - */ - private String fCreator; - - /** - * The create date. - */ - private long fCreateDate; - - public AVMStoreDescriptor(long id, - String name, - String creator, - long createDate) - { - fID = id; - fName = name; - fCreator = creator; - fCreateDate = createDate; - } - - /** - * @return the fCreateDate - */ - public long getCreateDate() - { - return fCreateDate; - } - - /** - * @return the fCreator - */ - public String getCreator() - { - return fCreator; - } - - /** - * @return the fName - */ - public String getName() - { - return fName; - } - - /** - * Get the object id. - * @return The object id. - */ - public long getId() - { - return fID; - } - - public String toString() - { - return "[" + fID + ":"+fName + ":" + fCreator + ":" + ISO8601DateFormat.format(new Date(fCreateDate)) + "]"; - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (!(obj instanceof AVMStoreDescriptor)) - { - return false; - } - return fID == ((AVMStoreDescriptor)obj).fID; - } - - @Override - public int hashCode() - { - return (int)fID; - } -} diff --git a/source/java/org/alfresco/service/cmr/avm/AVMWrongTypeException.java b/source/java/org/alfresco/service/cmr/avm/AVMWrongTypeException.java deleted file mode 100644 index cece71fab9..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/AVMWrongTypeException.java +++ /dev/null @@ -1,70 +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 . */ - -package org.alfresco.service.cmr.avm; - - -/** - * Thrown when an object of the wrong type is looked up. - * @author britt - */ -public class AVMWrongTypeException extends AVMException -{ - private static final long serialVersionUID = -8799318236851345536L; - - /** - * @param msgId - */ - public AVMWrongTypeException(String msgId) - { - super(msgId); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param msgParams - */ - public AVMWrongTypeException(String msgId, Object[] msgParams) - { - super(msgId, msgParams); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param cause - */ - public AVMWrongTypeException(String msgId, Throwable cause) - { - super(msgId, cause); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param msgParams - * @param cause - */ - public AVMWrongTypeException(String msgId, Object[] msgParams, - Throwable cause) - { - super(msgId, msgParams, cause); - // TODO Auto-generated constructor stub - } -} diff --git a/source/java/org/alfresco/service/cmr/avm/LayeringDescriptor.java b/source/java/org/alfresco/service/cmr/avm/LayeringDescriptor.java deleted file mode 100644 index b59645988a..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/LayeringDescriptor.java +++ /dev/null @@ -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 . */ - -package org.alfresco.service.cmr.avm; - -import java.io.Serializable; - - -/** - * A value class containing information about the layering state of a looked up - * node. - * @author britt - */ -public class LayeringDescriptor implements Serializable -{ - private static final long serialVersionUID = -6911813236493434123L; - - /** - * Whether the node is a background node. - */ - private boolean fIsBackground; - - /** - * The store descriptor for the top level lookup. - */ - private AVMStoreDescriptor fContainingStore; - - /** - * The store descriptor for the layer on which the node was finally found. - */ - private AVMStoreDescriptor fFinalStore; - - /** - * Make one up. - * @param isBackground - * @param containingStore - * @param finalStore - */ - public LayeringDescriptor(boolean isBackground, - AVMStoreDescriptor containingStore, - AVMStoreDescriptor finalStore) - { - fIsBackground = isBackground; - fContainingStore = containingStore; - fFinalStore = finalStore; - } - - /** - * Get the store that the original path is in. - * @return An AVMStoreDescriptor. - */ - public AVMStoreDescriptor getPathAVMStore() - { - return fContainingStore; - } - - /** - * Get the store that the final node was in. - * @return An AVMStoreDescriptor. - */ - public AVMStoreDescriptor getNativeAVMStore() - { - return fFinalStore; - } - - /** - * Is the node a background node. - * @return Whether the node is a background node. - */ - public boolean isBackground() - { - return fIsBackground; - } -} diff --git a/source/java/org/alfresco/service/cmr/avm/VersionDescriptor.java b/source/java/org/alfresco/service/cmr/avm/VersionDescriptor.java deleted file mode 100644 index f096ebf28e..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/VersionDescriptor.java +++ /dev/null @@ -1,156 +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 . */ - -package org.alfresco.service.cmr.avm; - -import java.io.Serializable; -import java.util.Date; - -import org.springframework.extensions.surf.util.ISO8601DateFormat; - -/** - * All the information about a particular version. - * @author britt - */ -public class VersionDescriptor implements Serializable -{ - private static final long serialVersionUID = 9045221398461856268L; - - /** - * The name of the store this version belongs to. - */ - private String fAVMStoreName; - - /** - * The version id. - */ - private int fVersionID; - - /** - * The creator of this version. - */ - private String fCreator; - - /** - * The date of this version's creation. - */ - private long fCreateDate; - - /** - * The short description. - */ - private String fTag; - - /** - * The long description. - */ - private String fDescription; - - /** - * New one up. - * @param storeName The store name. - * @param versionID The version id. - * @param creator The creator. - * @param createDate The create date. - */ - public VersionDescriptor(String storeName, - int versionID, - String creator, - long createDate, - String tag, - String description) - { - fAVMStoreName = storeName; - fVersionID = versionID; - fCreator = creator; - fCreateDate = createDate; - fTag = tag; - fDescription = description; - } - - /** - * Get the store name. - * @return The store name. - */ - public String getAVMStoreName() - { - return fAVMStoreName; - } - - /** - * Get the version ID - * @return The version ID - */ - public int getVersionID() - { - return fVersionID; - } - - /** - * Get the creator of this version. - * @return The creator. - */ - public String getCreator() - { - return fCreator; - } - - /** - * Get the creation date. - * @return The creation date. - */ - public long getCreateDate() - { - return fCreateDate; - } - - /** - * Get the short description. - * @return The short description. - */ - public String getTag() - { - return fTag; - } - - /** - * Get the long description. - * @return - */ - public String getDescription() - { - return fDescription; - } - - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("["); - builder.append(fAVMStoreName); - builder.append(":"); - builder.append("" + fVersionID); - builder.append(":"); - builder.append(fCreator); - builder.append(":"); - builder.append(ISO8601DateFormat.format(new Date(fCreateDate))); - builder.append(":"); - builder.append(fTag); - builder.append("]"); - return builder.toString(); - } -} diff --git a/source/java/org/alfresco/service/cmr/avm/deploy/DeploymentCallback.java b/source/java/org/alfresco/service/cmr/avm/deploy/DeploymentCallback.java deleted file mode 100644 index ffae6d7de2..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/deploy/DeploymentCallback.java +++ /dev/null @@ -1,35 +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 . - */ - -package org.alfresco.service.cmr.avm.deploy; - -/** - * Callback interface for deployments. - * @author britt - */ -public interface DeploymentCallback -{ - /** - * Called each time something happens during deployment. - * This is called synchronously by the deployer and should - * therefore be handled rapidly, if possible. - * @param event The event that occurred. - */ - public void eventOccurred(DeploymentEvent event); -} diff --git a/source/java/org/alfresco/service/cmr/avm/deploy/DeploymentEvent.java b/source/java/org/alfresco/service/cmr/avm/deploy/DeploymentEvent.java deleted file mode 100644 index ff6012c8ff..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/deploy/DeploymentEvent.java +++ /dev/null @@ -1,142 +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 . - */ - -package org.alfresco.service.cmr.avm.deploy; - -import java.io.Serializable; - -import org.alfresco.util.Pair; - -/** - * Interface for Deployment Events. - * @author britt - */ -public class DeploymentEvent implements Serializable -{ - private static final long serialVersionUID = 2696116904379321786L; - - /** - * The type of the event. - * @author britt - */ - public static enum Type implements Serializable - { - CREATED, // Copied a source node that did not exist on the destination. - UPDATED, // Overwrote the destination. - DELETED, // Deleted the destination node. - START, // A Deployment has begun. - END, // A Deployment has ended. - FAILED // A Deployment failed. - }; - - private Type fType; - - private Pair fSource; - - private String fDestination; - - private String fMessage; - - public DeploymentEvent(Type type, Pair source, String destination) - { - fType = type; - fSource = source; - fDestination = destination; - } - - public DeploymentEvent(Type type, Pair source, String destination, String message) - { - this(type, source, destination); - - fMessage = message; - } - - /** - * Get the type of the event. - * @return The type. - */ - public Type getType() - { - return fType; - } - - /** - * Get the source node version and path. - * @return - */ - public Pair getSource() - { - return fSource; - } - - /** - * Get the destination path. - * @return - */ - public String getDestination() - { - return fDestination; - } - - /** - * Get the message. - * @return - */ - public String getMessage() - { - return fMessage; - } - - /** - * Get a String representation. - */ - public String toString() - { - String str = fType + ": " + fSource + " -> " + fDestination; - - if (fMessage != null) - { - str = str + " (" + fMessage + ")"; - } - - return str; - } - - /** - * - */ - public int hashCode() - { - return (fType.toString() + fDestination).hashCode(); - } - - public boolean equals(Object obj) - { - if(obj instanceof DeploymentEvent) - { - DeploymentEvent other = (DeploymentEvent)obj; - if(this.getType() == other.getType() && this.getDestination().equals(other.getDestination())) - { - // objects are equal - return true; - } - } - return false; - } -} diff --git a/source/java/org/alfresco/service/cmr/avm/deploy/DeploymentReport.java b/source/java/org/alfresco/service/cmr/avm/deploy/DeploymentReport.java deleted file mode 100644 index 8010bbf841..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/deploy/DeploymentReport.java +++ /dev/null @@ -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 . - */ - -package org.alfresco.service.cmr.avm.deploy; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * A value class that contains the results of a deployment run. - * @author britt - */ -public class DeploymentReport implements Serializable, Iterable -{ - private static final long serialVersionUID = 5528250199836250533L; - - private List fEvents; - - public DeploymentReport() - { - fEvents = new ArrayList(); - } - - /** - * Get a String representation. - */ - public String toString() - { - StringBuilder builder = new StringBuilder(); - for (DeploymentEvent event : fEvents) - { - builder.append(event.toString()); - builder.append('\n'); - } - return builder.toString(); - } - - /** - * Add an event. - * @param event - */ - public void add(DeploymentEvent event) - { - fEvents.add(event); - } - - /* (non-Javadoc) - * @see java.lang.Iterable#iterator() - */ - public Iterator iterator() - { - return fEvents.iterator(); - } - - public List getEvents() - { - return fEvents; - } - -} diff --git a/source/java/org/alfresco/service/cmr/avm/deploy/DeploymentReportCallback.java b/source/java/org/alfresco/service/cmr/avm/deploy/DeploymentReportCallback.java deleted file mode 100644 index 2d63c8435e..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/deploy/DeploymentReportCallback.java +++ /dev/null @@ -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 . - */ - -package org.alfresco.service.cmr.avm.deploy; - -public class DeploymentReportCallback implements DeploymentCallback -{ - private DeploymentReport report; - - public DeploymentReportCallback(DeploymentReport report ) - { - this.report = report; - } - - /** - * Called each time something happens during deployment. - * This is called synchronously by the deployer and should - * therefore be handled rapidly, if possible. - * @param event The event that occurred. - */ - public void eventOccurred(DeploymentEvent event){ - report.add(event); - } -} diff --git a/source/java/org/alfresco/service/cmr/avm/deploy/DeploymentService.java b/source/java/org/alfresco/service/cmr/avm/deploy/DeploymentService.java deleted file mode 100644 index 7078884e43..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/deploy/DeploymentService.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2005-2011 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 . - */ -package org.alfresco.service.cmr.avm.deploy; - -import java.util.Set; -import java.util.List; - -import org.alfresco.service.cmr.action.ActionService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.NameMatcher; -import org.alfresco.service.Auditable; -import org.alfresco.service.NotAuditable; - -/** - * A service to handle WCM AVM repository to remote AVM repository deployment. - * @author britt - */ -public interface DeploymentService -{ - /** - * Deploys the differences between what is is the local source path - * and a destination machine's path. - * @param version The local version. - * @param srcPath The local path. - * @param hostName The remote hostname. - * @param port The remote rmi registry port. - * @param userName The username for authentication. - * @param password The password for authentication. - * @param dstPath The destination path corresponding to source path. - * @param createDst Flag for whether a missing destination should be created. - * @param dontDelete Don't delete assets at the destination. - * @param dontDo If this is set then this is a dry run. - * @param callback A possibly null callback. - */ - @Auditable - public void deployDifference(int version, String srcPath, - String hostName, - int port, - String userName, - String password, - String dstPath, - NameMatcher matcher, - boolean createDst, - boolean dontDelete, - boolean dontDo, - List callback); - - /** - * Get A reference to an ActionService instance on a remote Alfresco Server. - * @param hostName - * @param port - * @param userName - * @param password - * @return - */ - @NotAuditable - public ActionService getRemoteActionService(String hostName, int port, - String userName, String password); - - /** - * Deploy to a filesystem on another machine. - * @param version The version to deploy from. - * @param srcPath The path to deploy from. - * @param adapterName The name of the transport adapter to connect to the remote system. - * The value "default" means use the traditional RMI used for versions of Alfresco prior to 3.0 - * @param hostName The hostname of the filesystem receiver. - * @param port The port to connect to. - * @param userName The username for authentication of the target - * @param password The password for authentication of the target - * @param dstTarget The target on the deployment receiver. - * @param createDst Flag for whether a missing destination should be created. - * @param dontDelete Don't delete deleted nodes from destination. - * @param dontDo If this is set, this is a dry run. - * @param callback A possibly null callback. - */ - @Auditable - public void deployDifferenceFS(int version, - String srcPath, - String adapterName, - String hostName, - int port, - String userName, - String password, - String dstTarget, - NameMatcher matcher, - boolean createDst, - boolean dontDelete, - boolean dontDo, - List callback); - - /** - * Get the names of the transport adapters. - * - * @return the adapters - */ - @NotAuditable - public Set getAdapterNames(); - - /* - * @param webProjectRef Web project reference. - * */ - @NotAuditable - public List findLiveDeploymentServers(NodeRef webProjectRef); - - - /* - * @param webProjectRef Web project reference. - * @param availableOnly find available servers only. - * */ - @NotAuditable - public List findTestDeploymentServers(NodeRef webProjectRef, boolean availableOnly); -} diff --git a/source/java/org/alfresco/service/cmr/avm/deploy/package-info.java b/source/java/org/alfresco/service/cmr/avm/deploy/package-info.java deleted file mode 100644 index 5b1d76565b..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/deploy/package-info.java +++ /dev/null @@ -1,25 +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 . - */ -/** - * Provides the public interface for the WCM deployment service. - */ -@PackageMarker -package org.alfresco.service.cmr.avm.deploy; -import org.alfresco.util.PackageMarker; - diff --git a/source/java/org/alfresco/service/cmr/avm/locking/AVMLockingException.java b/source/java/org/alfresco/service/cmr/avm/locking/AVMLockingException.java deleted file mode 100644 index 60957876d4..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/locking/AVMLockingException.java +++ /dev/null @@ -1,41 +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 . - */ -package org.alfresco.service.cmr.avm.locking; - -import org.alfresco.service.cmr.avm.AVMException; - -/** - * Exception thrown when a lock is denied. - * - * @author Derek Hulley - */ -public class AVMLockingException extends AVMException -{ - private static final long serialVersionUID = -8446855530834146895L; - - public AVMLockingException(String msgId, Object ... msgParams) - { - super(msgId, msgParams); - } - - public AVMLockingException(Throwable cause, String msgId, Object ... msgParams) - { - super(msgId, msgParams, cause); - } -} diff --git a/source/java/org/alfresco/service/cmr/avm/locking/AVMLockingService.java b/source/java/org/alfresco/service/cmr/avm/locking/AVMLockingService.java deleted file mode 100644 index 22d21c9595..0000000000 --- a/source/java/org/alfresco/service/cmr/avm/locking/AVMLockingService.java +++ /dev/null @@ -1,171 +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 . - */ -package org.alfresco.service.cmr.avm.locking; - -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Service to handle AVM locking. - * - * Note that this service is a low-level service and does no "self-permissioning" - * e.g. checking ownership of locks. - * - * @author Derek Hulley, janv - */ -public interface AVMLockingService -{ - /** - * Creates a lock of the given type on a path within an AVM store. - * - * @param avmStore the name of the AVM store - * @param path the relative path of the lock - * @param lockOwner the user taking the lock - * @param lockData additional data to append to the lock - */ - public void lock(String avmStore, String path, String lockOwner, Map lockData); - - /** - * Modify a lock if it exists or do nothing if it doesn't. The user supplied must - * already hold the lock if it exists. - * - * @param avmStore the name of the AVM store - * @param path the relative path of the lock - * @param lockOwner the user taking the lock and who must also own the existing lock - * @param newAvmStore the name of the new AVM store - * @param newPath the new relative path of the lock - * @param lockData the new additional data to append to the lock - * @return true if the lock was modified or false if no lock existed - */ - public boolean modifyLock( - String avmStore, String path, String lockOwner, - String newAvmStore, String newPath, - Map lockData); - - /** - * Get the current holder of a lock on AVM store path - * - * @param avmStore the name of the AVM store - * @param path the relative path of the lock - * @return Returns the user holding the lock or null - */ - public String getLockOwner(String avmStore, String path); - - /** - * Enumeration of the state of a lock's with respect to a specific user. - * - * @author Derek Hulley - * @since 3.4 - */ - public static enum LockState - { - /** - * The user holds the lock - */ - LOCK_OWNER, - /** - * Another user holds the lock - */ - LOCK_NOT_OWNER, - /** - * There is currently no lock - */ - NO_LOCK; - } - - /** - * Get the state of a lock with respect to a given AVM store, path and user - * - * @param avmStore the name of the AVM store - * @param path the relative path of the lock - * @param lockOwner the user who might own the lock - * @return the state of the lock with respect to the given user - */ - public LockState getLockState(String avmStore, String path, String lockOwner); - - /** - * Get the data associated with a lock - * - * @param avmStore the name of the AVM store - * @param path the relative path of the lock - * @return the state of the lock with respect to the given user - */ - public Map getLockData(String avmStore, String path); - - /** - * Remove a lock. - * - * @param webProject the name of the web project - * @param path the relative path of the lock - */ - public void removeLock(String avmStore, String path); - - /** - * Remove all locks for a specific AVM store - * - * @param avmStore the name of the AVM store - */ - public void removeLocks(String avmStore); - - /** - * Remove all locks for a specific AVM store that start with a given directory path - * that also optionally match a map of lock data entries. - * - * @param avmStore the name of the AVM store - * @param dirPath optional - start with given directory path or null to match all - * @param lockDataToMatch optional - lock data to match (note: all entries must match) or null/empty to match all - */ - public void removeLocks(String avmStore, String dirPath, final Map lockDataToMatch); - - /** - * Remove all locks for a specific AVM store - * that also optionally match a map of lock data entries. - * - * @param avmStore the name of the AVM store - * @param lockDataToMatch optional - lock data to match (note: all entries must match) or null/empty to match all - */ - public void removeLocks(String avmStore, final Map lockDataToMatch); - - /** - * Is the user allowed to do anything to the given asset, other than read? - * - * @param webProject the name of the WCM project - * @param path the relative path of the lock - * @param lockOwner the user to check - * @return true if the user has access - * (either holds the lock or there is no lock, etc) - * - * @deprecated This will move into a WCMLockingService - */ - public boolean hasAccess(String webProject, String avmPath, String lockOwner); - - /** - * Is the user allowed to do anything to the given asset, other than read? - * - * @param webProject the name of the WCM project - * @param path the relative path of the lock - * @param lockOwner the user to check - * @return true if the user has access - * (either holds the lock or there is no lock, etc) - * - * @deprecated This will move into a WCMLockingService - */ - public boolean hasAccess(NodeRef webProject, String avmPath, String lockOwner); -} diff --git a/source/java/org/alfresco/service/cmr/avmsync/AVMDifference.java b/source/java/org/alfresco/service/cmr/avmsync/AVMDifference.java deleted file mode 100644 index 461d4a7bd2..0000000000 --- a/source/java/org/alfresco/service/cmr/avmsync/AVMDifference.java +++ /dev/null @@ -1,214 +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 . */ - -package org.alfresco.service.cmr.avmsync; - -import java.io.Serializable; - -/** - * Represents the difference between corresponding nodes in parallel avm node trees. It it indicates for the difference - * whether the source is older, newer, or in conflict with the destination. - * - * @author britt - */ -public class AVMDifference implements Serializable, Comparable -{ - private static final long serialVersionUID = -589722861571724954L; - - public static final int NEWER = 0; - - public static final int OLDER = 1; - - public static final int CONFLICT = 2; - - public static final int DIRECTORY = 3; - - public static final int SAME = 4; - - /** - * Version number of the source node. - */ - private int fSourceVersion; - - /** - * Path of the source node. - */ - private String fSourcePath; - - /** - * Version number of the destination node. - */ - private int fDestVersion; - - /** - * Path of the destination node. - */ - private String fDestPath; - - /** - * The difference code. - */ - private int fDiffCode; - - /** - * Make one up. - * - * @param srcVersion - * The source version. - * @param srcPath - * the source path. - * @param dstVersion - * The destination version. - * @param dstPath - * The destination path. - * @param diffCode - * The difference code, NEWER, OLDER, CONFLICT - */ - public AVMDifference(int srcVersion, String srcPath, int dstVersion, String dstPath, int diffCode) - { - fSourceVersion = srcVersion; - fSourcePath = srcPath; - fDestVersion = dstVersion; - fDestPath = dstPath; - fDiffCode = diffCode; - } - - /** - * Get the source version number. - * - * @return The source version number. - */ - public int getSourceVersion() - { - return fSourceVersion; - } - - /** - * Get the source path. - * - * @return The source path. - */ - public String getSourcePath() - { - return fSourcePath; - } - - /** - * Get the destination version number. - * - * @return The destination version number. - */ - public int getDestinationVersion() - { - return fDestVersion; - } - - /** - * Get the destination path. - * - * @return The destination path. - */ - public String getDestinationPath() - { - return fDestPath; - } - - /** - * Get the difference code, NEWER, OLDER, CONFLICT. - * - * @return The difference code. - */ - public int getDifferenceCode() - { - return fDiffCode; - } - - /** - * Check for improperly initialized instances. - * - * @return Whether source and destination are non null. - */ - public boolean isValid() - { - return fSourcePath != null && fDestPath != null; - } - - /** - * Get as String. - * - * @return A String representation of this. - */ - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append(fSourcePath); - builder.append("["); - builder.append(fSourceVersion); - builder.append("] "); - switch (fDiffCode) - { - case SAME: - builder.append("= "); - break; - case NEWER: - builder.append("> "); - break; - case OLDER: - builder.append("< "); - break; - case CONFLICT: - builder.append("<> "); - break; - case DIRECTORY: - builder.append("| "); - break; - default: - builder.append("? "); - } - builder.append(fDestPath); - builder.append("["); - builder.append(fDestVersion); - builder.append("]"); - return builder.toString(); - } - - public int compareTo(AVMDifference other) - { - return this.getOrderValue() - other.getOrderValue(); - } - - public int getOrderValue() - { - switch (fDiffCode) - { - case CONFLICT: - return 0; - case NEWER: - return 1; - case OLDER: - return 2; - case DIRECTORY: - return 3; - case SAME: - return 4; - default: - return 100; - } - } -} diff --git a/source/java/org/alfresco/service/cmr/avmsync/AVMSyncException.java b/source/java/org/alfresco/service/cmr/avmsync/AVMSyncException.java deleted file mode 100644 index 00db857c89..0000000000 --- a/source/java/org/alfresco/service/cmr/avmsync/AVMSyncException.java +++ /dev/null @@ -1,71 +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 . */ - -package org.alfresco.service.cmr.avmsync; - -import org.alfresco.error.AlfrescoRuntimeException; - -/** - * Exception for tree to tree synchronization problems. - * @author britt - */ -public class AVMSyncException extends AlfrescoRuntimeException -{ - private static final long serialVersionUID = 1075466935333921588L; - - /** - * @param msgId - */ - public AVMSyncException(String msgId) - { - super(msgId); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param msgParams - */ - public AVMSyncException(String msgId, Object[] msgParams) - { - super(msgId, msgParams); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param cause - */ - public AVMSyncException(String msgId, Throwable cause) - { - super(msgId, cause); - // TODO Auto-generated constructor stub - } - - /** - * @param msgId - * @param msgParams - * @param cause - */ - public AVMSyncException(String msgId, Object[] msgParams, Throwable cause) - { - super(msgId, msgParams, cause); - // TODO Auto-generated constructor stub - } - -} diff --git a/source/java/org/alfresco/service/cmr/avmsync/AVMSyncService.java b/source/java/org/alfresco/service/cmr/avmsync/AVMSyncService.java deleted file mode 100644 index 66c6c31f1c..0000000000 --- a/source/java/org/alfresco/service/cmr/avmsync/AVMSyncService.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2005-2012 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 . */ - -package org.alfresco.service.cmr.avmsync; - -import java.util.List; - -import org.alfresco.util.NameMatcher; - -/** - * This service handles comparisons and synchronizations between - * corresponding avm node trees. - * @author britt - */ -public interface AVMSyncService -{ - /** - * Get a difference list between two corresponding node trees. - * @param srcVersion The version id for the source tree. - * @param srcPath The avm path to the source tree. - * @param dstVersion The version id for the destination tree. - * @param dstPath The avm path to the destination tree. - * @param excluder A NameMatcher used to exclude files from consideration. - * @return A List of AVMDifference structs which can be used for - * the update operation. - */ - public List compare(int srcVersion, String srcPath, - int dstVersion, String dstPath, - NameMatcher excluder); - - /** - * Get a difference list between two corresponding node trees - * - * Note: new/modified directories can be optionally expanded to include new/modified children - */ - public List compare(int srcVersion, String srcPath, - int dstVersion, String dstPath, - NameMatcher excluder, - boolean expandDirs); - - /** - * Updates the destination nodes in the AVMDifferences - * with the source nodes. Normally any conflicts or cases in - * which the source of an AVMDifference is older than the destination - * will cause the transaction to roll back. - * @param diffList A List of AVMDifference structs. - * @param ignoreConflicts If this is true the update will skip those - * AVMDifferences which are in conflict with - * the destination. - * @param ignoreOlder If this is true the update will skip those - * AVMDifferences which have the source older than the destination. - * @param overrideConflicts If this is true the update will override conflicting - * AVMDifferences and replace the destination with the conflicting source. - * @param overrideOlder If this is true the update will override AVMDifferences - * in which the source is older than the destination and overwrite the destination. - * @param tag Short comment. - * @param description Full update blurb. - */ - public void update(List diffList, NameMatcher excluder, boolean ignoreConflicts, boolean ignoreOlder, - boolean overrideConflicts, boolean overrideOlder, String tag, String description); - - /** - * Flattens a layer so that all all nodes under and including - * layerPath become translucent to any nodes in the - * corresponding location under and including underlyingPath - * that are the same version. - * @param layerPath The overlying layer path. - * @param underlyingPath The underlying path. - */ - public void flatten(String layerPath, String underlyingPath); - - /** - * Takes a layer, deletes it and recreates it pointing at the same underlying - * node. Any changes in the layer are lost (except to history if the layer has been - * snapshotted.) - * @param layerPath - */ - public void resetLayer(String layerPath); -} diff --git a/source/java/org/alfresco/service/cmr/remote/AVMRemote.java b/source/java/org/alfresco/service/cmr/remote/AVMRemote.java deleted file mode 100644 index 620841103e..0000000000 --- a/source/java/org/alfresco/service/cmr/remote/AVMRemote.java +++ /dev/null @@ -1,999 +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 . - */ - -package org.alfresco.service.cmr.remote; - -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.service.cmr.avm.AVMExistsException; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMNotFoundException; -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.namespace.QName; -import org.alfresco.util.Pair; - -/** - * Remote interface for Alfresco Versioning Model (AVM).
- * For the in-process API, see: - * {@link org.alfresco.service.cmr.avm.AVMService AVMService}. - *

- * - * Because the AVM is a - * - * versioning repository, - * fully explicit references to the nodes within it consist of an - * absolute AVM path, and a version ID. Absolute AVM paths are of - * the form:  <store-name>:<store-relative-path>. - *

- * For example:  mystore:/www/avm_webapps/ROOT/x/y/z.html - *

- * Within AVMService, whenever an API takes a path - * and a name, the path is the parent - * directory in which the name appears. - * Whenever just a path is needed by an API, it is an absolute - * path to a file or directory. - *

- * The special version ID -1 (negative one) - * refers to the latest read/write version at the given absolute AVM path. - * Non-negative version ID values refer to read-only snapshots of a store. - * For this reason, the version ID -1 - * is implicit for all write operations. Sometimes, - * -1 is referred to as the - * HEAD version (a term that should be - * already be familiar to users of other versioning systems like - * CVS - * and SVN). - *

- * Snapshots can be created explicitly via a call to - * {@link #createSnapshot(String store, String tag, String description) createSnapshot}, - * or implicitly by various APIs in this interface and in - * {@link org.alfresco.service.cmr.avmsync.AVMSyncService AVMSyncService}. - * Although a new snapshot of a store will have version a ID one higher - * than the previous snapshot in that store, the history of an AMV store - * does not necessarily contain a continuous range of version ID values, - * because {@link #purgeVersion(int version, String name) purgeVersion} - * may have been called. Regardless of whether - * {@link #purgeVersion(int version, String name) purgeVersion} - * has been called, the AVM never recycles version ID values - * within a store. - * - * @author britt - */ -public interface AVMRemote -{ - /** - * Get an InputStream for reading the contents of a - * file identified by its version ID and AVM path. - * This method can be used for either plain or layered files. - * - * @param version The version ID to look in. - * @param path The absolute path to the file. - * @return An InputStream for the designated file. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public InputStream getFileInputStream(int version, String path); - - /** - * Get an InputStream for reading the contents of a - * file node identified by its descriptor. - * This method can be used for either plain or layered files. - * - * @param desc The descriptor. - * @return An InputStream. - * @throws AVMNotFoundException - */ - public InputStream getFileInputStream(AVMNodeDescriptor desc); - - /** - * Get an output stream to write to a file - * identified by an AVM path. This file must already exist. - * This method can be used for either plain or layered files. - * - * To create a plain file, see: - * {@link #createFile(String path, String name) createFile}. - * To create a layered file, see: - * {@link #createLayeredFile(String targetPath, String parent, String name) createLayeredFile}. - * - * @param path The absolute path to the file. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public OutputStream getFileOutputStream(String path); - - - /** - * Get a non-recursive listing of a directory - * identified by its version ID and path. - * If path does not refer to a directory - * node, AVMWrongTypeException is thrown. - * - * @param version The version ID to look in. - * @param path The absolute AVM path to the file. - * @return A Map of names to descriptors. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public SortedMap getDirectoryListing(int version, String path); - - /** - * Get a non-recursive listing of nodes contained by a directory identified - * by its version ID and path, but exclude all nodes that are only - * contained "indirectly" via layering. - *

- * If this function is called on a "plain" (non-layered) directory, - * it is equivalent to - * {@link #getDirectoryListing(int version, String path) getDirectoryListing}. - * - * @param version The version to look up. - * @param path The full path to get listing for. - * @return A Map of names to descriptors. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public SortedMap - getDirectoryListingDirect(int version, String path); - - /** - * Get a non-recursive directory listing of a directory node - * identified by a node descriptor. - * - * @param dir The directory node descriptor. - * @return A sorted Map of names to node descriptors. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public SortedMap getDirectoryListing(AVMNodeDescriptor dir); - - /** - * Non-recursively get the names of nodes that have been deleted in - * a directory identified by a version ID and a path - * - * @param version The version to look under. - * @param path The path of the directory. - * @return A List of names. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public List getDeleted(int version, String path); - - - /** - * Create a new "plain" (non-layered) file within a path. - * This function fails if the file already exists, - * or if the directory identified by path - * does not exist. - * - * @param path The path of the directory containing the created file. - * @param name The name of the new file - * @throws AVMNotFound - * @throws AVMExists - * @throws AVMWrongType - * @return An opaque handle to a server side output stream. - */ - public OutputStream createFile(String path, String name); - - /** - * Create a new directory. - * If path is within a layer, the new directory will be a layered directory; - * otherwise, the new directory will be a plain directory. - * - * @param path The simple absolute path to the parent. - * @param name The name to give the directory. - * @throws AVMNotFound - * @throws AVMExists - * @throws AVMWrongType - */ - public void createDirectory(String path, String name); - - /** - * Create a new layered file. - *

- * Note: the target of the indirection does not need to exist at - * the time the layered file node is created. - * - * @param targetPath The absolute path of the underlying file being pointed at - * @param parent The absolute path of the directory containing layered file to be created - * @param name The name of the layered file to be created - * @throws AVMNotFound - * @throws AVMExists - * @throws AVMWrongType - * - * @deprecated - */ - public void createLayeredFile(String targetPath, String parent, String name); - - - /** - * Create a new layered directory. In whatever context this is created, this - * will be a layered directory that has a primary indirection. - *

- * Note: a "primary" indirection is one in which the target is explicitly set; - * "non-primary" indirect nodes compute their effective target dynamically - * on the basis of their relative position to the closest "primary" - * indirect node that contains them. Therefore, changing the target of a - * "primary" layered directory node immediately alters the indirection - * targets computed by the "non-primary" layered nodes it contains. - *

- * Note: the target of the indirection does not need to exist at - * the time the layered directory node is created. - * - * @param targetPath The absolute path to the underlying directory that - * the layered directory being created will point at. - * @param parent The absolute path to directory containing the layered directory being created. - * @param name The name of the layered directory being created - * @throws AVMNotFound - * @throws AVMExists - * @throws AVMWrongType - */ - public void createLayeredDirectory(String targetPath, String parent, String name); - - - /** - * Retarget a layered directory. - * Change the target pointed to by a layered directory node. - * This has the side effect of making the layered directory - * a primary indirection if the layered directory's indirection - * was "non-primary". - * - * @param path Path to the layered directory. - * @param target The new indirection target of the layered directory - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public void retargetLayeredDirectory(String path, String target); - - - /** - * Create a new AVMStore. - * All stores are top level objects within the AVM repository. - * The AVM is a forest of versioned trees; each versioned - * tree is contained within a AVM store with a unique - * name. If a store is removed via - * {@link purgeStore(String name) purgeStore}, the name of - * the deleted store can be reused in a later call to - * {@link createStore(String name) createStore}. - *

- * The store name must be non-null, cannot be the empty string, - * and must not contain characters that are illegal in - * normal file names. - * - * @param name The name of the new AVMStore. - * @throws AVMExistsException - */ - public void createStore(String name); - - - /** - * Create a branch from a given version and path. As a side effect, - * an automatic snapshot is taken of the store that contains the - * node that is being branched from. - * - * @param version The version number from which to make the branch. - * @param srcPath The path to the node to branch from. - * @param dstPath The path to the directory to contain the new branch. - * @param name The name to give the new branch. - * @throws AVMNotFoundException - * @throws AVMExistsException - * @throws AVMWrongTypeException - */ - public void createBranch(int version, String srcPath, String dstPath, String name); - - - /** - * Remove a file or directory from its parent directory. - * In a layered context, the newly deleted node will hide - * a file of the same name in the corresponding layer below. - *

- * If instead you want to make the file in the lower layer visible - * via transparency, see: - * {@link uncover(String dirPath, String name) uncover}. - * If you want to perform a removal and an uncover - * operation atomically, see: - * {@link #makeTransparent(String dirPath, String name) makeTransparent}. - * - * - *

- * Caution: this removes directories even if they are not empty. - * - *

- * Note: developers of records management systems must also - * be aware that the AVMNode corresponding to the - * parent directory and name - * provided might still be accessible via different - * path lookups after this function has completed; - * this because branching and versioning operations create - * manifestations of nodes in a manner that is similar - * to a UNIX hard link. If you need to discover every - * possible path that could retrieve the associated AVMNode, see: - * {@link #getPaths(AVMNodeDescriptor desc) getPaths}, - * {@link #getHeadPaths(AVMNodeDescriptor desc) getHeadPaths}, and - * {@link #getPathsInStoreHead(AVMNodeDescriptor desc) getPathsInStoreHead}. - * - * @param parent The absolute path to the parent directory. - * @param name The name of the child to remove. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public void removeNode(String parent, String name); - - - - /** - * Rename a file or directory. - * There are a number of things to note about the - * interaction of rename and layering: - *

- *

    - *
  • If you rename a layered directory into a non layered context, - * the layered directory continues to point to the same place - * it did before it was renamed, and automatically becomes a - * primary indirection node. - *
  • - * - *
  • If a plain directory is renamed into a layered context it - * remains a plain directory, thus acting as an opaque node - * in its new layered home. - *
  • - * - *
  • Renaming a layered node into a layered node leaves the renamed - * node pointing to the same place it did before the rename and - * makes it automatically a primary indirection node. - *
  • - * - *
  • After a layered node or directory is renamed, - * the directory that contained it acquires a - * "deleted" node in its place; therefore, - * if a layer beneath it contains a file or directory - * with the same name as the "deleted" node, it - * will not be visible via transparency - * (unless an {@link uncover(String dirPath, String name) uncover} - * operation is performed afterwards). - *
  • - *
- *

- * - * Note: if instead you want to rename an AVM store, see - * {@link #renameStore(String sourceName, String destName) renameStore}. - * - * @param srcParent The absolute path to the parent directory. - * @param srcName The name of the node in the src directory. - * @param dstParent The absolute path to the destination directory. - * @param dstName The name that the node will have in the destination directory. - * @throws AVMNotFoundException - * @throws AVMExistsException - */ - public void rename(String srcParent, String srcName, String dstParent, String dstName); - - - /** - * If a layered directory dirPath - * has a deleted entry of the given name, - * remove that name from the deleted list, - * so that if a layer below it contains an entry - * of this name, it can be seen via transparency - * from dirPath. - *

- * Note: if you are looking for an atomic operation - * that first deletes an object, then performs - * an "uncover" operation to make it transparent, see - * {@link #makeTransparent(String dirPath, String name) makeTransparent}. - * - * @param dirPath The path to the layered directory. - * @param name The name to uncover. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public void uncover(String dirPath, String name); - - - /** - * Gets the ID that the next snapshotted version of a store - * will have. - * - *

- * Note: unless the operations that require this value - * to be valid are performed within a transaction, - * this value can become "stale". - * - * @param storeName The name of the AVMStore. - * @return The next version ID of the AVMStore. - * @throws AVMNotFoundException - */ - public int getNextVersionID(String storeName); - - - /** - * Get the latest snapshot ID of a store. - * Note: All stores have at least one snapshot ID: 0; - * this is the "empty" snapshot taken when - * the store is first created. - * - * @param storeName The store name. - * @return The ID of the latest extant version of the store. - * @throws AVMNotFoundException - */ - public int getLatestSnapshotID(String storeName); - - - /** - * Snapshot the given AVMStore. - * When files have been modified since the previous snapshot, - * a new snapshot version is created; otherwise, no extra - * snapshot is actually taken. - *

- * When no snapshot is actually taken, but either 'tag' - * or 'store' are non-null, they will override the value for - * the last snapshot (i.e.: the old values will be discarded); - * however, if both 'tag' and 'description' are null then - * invoking createSnapshot when no files have been modified - * becomes a true no-op. - * - * @param store The name of the AVMStore to snapshot. - * @param tag The short description. - * @param description The thick description. - * @return A Map of all implicitly or explicitly snapshotted stores to last - * version id. - * @throws AVMNotFoundException - */ - public Map createSnapshot(String store, String tag, String description); - - - /** - * Get the set of versions in an AVMStore. The version ID values - * within this list will always be may appear out of order, - * and may contain missing values (due to the possibility that - * {@link #purgeStore(String name) purgeStore} operations have - * been performed). - * - * Because the number of versions that a store can contain - * may become large, this call can be a resource-intensive, - * and may even causing Out of Memory exceptions. - * - * @param name The name of the AVMStore. - * @return A Set of version descriptors. - * @throws AVMNotFoundException - */ - public List getStoreVersions(String name); - - - /** - * Get AVMStore version descriptors by creation date. Either - * from or to can be null but not both. - *

- *

    - *
  • - * If from is null, all versions earlier than - * to will be returned. - *
  • - * - *
  • - * If to is null, all versions later than - * from will be returned. - *
  • - *
- *

- * - * The order of the values returned is not guaranteed, nor are the version - * IDs necessarily free of "missing" values (due to the possibility that - * {@link #purgeStore(String name) purgeStore} operations have - * been performed). - * - *

- * Note: for portability, all dates are stored as 64-bit longs, with a - * time resolution of one millisecond. Therefore, aliasing/wrapping - * are not a concern unless you need to plan 292.4 million years ahead. - * If so, please contact your system administrator. - * - * @param name The name of the AVMStore. - * @param from Earliest date of version to include. - * @param to Latest date of version to include. - * @return The Set of version descriptors that match. - * @throws AVMNotFoundException - */ - public List getStoreVersions(String name, Date from, Date to); - - /** - * Get the descriptors of all AVMStores in the repository. - * - * @return A List of all AVMStores. - */ - public List getStores(); - - - /** - * Get a descriptor for an AVMStore. - * @param name The AVMStore's name. - * @return A Descriptor, or null if not found. - */ - public AVMStoreDescriptor getStore(String name); - - - /** - * A convenience method for getting the specified - * root directory of an AVMStore (e.g.: "mysite:/"). - * - * @param version The version to look up. - * @param name The name of the AVMStore. - * @return A descriptor for the specified root. - * @throws AVMNotFoundException - */ - public AVMNodeDescriptor getStoreRoot(int version, String name); - - - /** - * Lookup a node identified by version ID and path. - * - * @param version The version ID to look under. - * @param path The simple absolute path to the parent directory. - * @return An AVMNodeDescriptor, or null if the node does not exist. - */ - public AVMNodeDescriptor lookup(int version, String path); - - /** - * Lookup a node identified by version ID and path; optionally, - * if the node is deleted, its descriptor can still - * be retrieved. - * - * @param version The version ID to look under. - * @param path The simple absolute path to the parent directory. - * @param includeDeleted Whether to allow a deleted node to be retrieved - * @return An AVMNodeDescriptor, or null if the version does not exist. - */ - public AVMNodeDescriptor lookup(int version, String path, boolean includeDeleted); - - /** - * Lookup a node identified by the directory node that contains it, and its name. - * - * @param dir The descriptor for the directory node. - * @param name The name to lookup. - * @return The descriptor for the child. - * @throws AVMWrongTypeException If dir does not refer to a directory. - */ - public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name); - - - /** - * Lookup a node identified by the directory that contains it, and its name; - * optionally, the lookup can retrive the descriptor of a node even if - * it has been deleted from its containing directory. - * - * @param dir The descriptor for the directory node. - * @param name The name to lookup. - * @param includeDeleted Whether to allow a deleted node to be retrieved via the lookup - * @return The descriptor for the child, null if the child doesn't exist. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name, boolean includeDeleted); - - /** - * Get a single valid path to a given node. - * @param desc The descriptor of the node to which a version and path will be fetched. - * @return version and path. - * @throws AVMNotFoundException - */ - public Pair getAPath(AVMNodeDescriptor desc); - - - /** - * Get the indirection path for a node in a layered context - * whether that indirection path is primary or non-primary - * (or seen via transparency). - * - * If you call getIndirectionPath on a layered node, - * you'll fetch its explicitly set target; if you call - * this function on a non-primary indirection node or a - * node seen via transparency, you'll get back the path - * to the corresponding node in the underlying target. - *

- * For example, if "mysite--alice:/www" is a layered - * directory that targets "mysite:/www", and "mysite--alice" - * contains no content directly, then if the path - * path "mysite:/www/avm_webapps/ROOT/x/y/z" is valid, - * calling getIndirectionPath on - * "mysite--alice:/www/avm_webapps/ROOT/x/y/z" will yield - * "mysite:/www/avm_webapps/ROOT/x/y/z". - * - * @param version The version number to get. - * @param path The path to the node of interest. - * @return The indirection path, or null if the path is not in a layered context. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public String getIndirectionPath(int version, String path); - - - /** - * Purge an AVMStore. - * This completely removes an AVMStore. - *

- * Note: while the store being purged disappears from view - * immediately, any nodes that become unreachable as a result - * are deleted asynchronously. - * - * @param name The name of the AVMStore. - * @throws AVMNotFoundException - */ - public void purgeStore(String name); - - /** - * Purge a version from an AVMStore. - * Deletes everything that lives in the given version only. - * - * @param version The version to purge. - * @param name The name of the AVMStore from which to purge it. - * @throws AVMNotFoundException If name or version - * do not exist. - */ - public void purgeVersion(int version, String name); - - - /** - * Make a directory into a primary indirection node. - * @param path The full path. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public void makePrimary(String path); - - - /** - * Get a list of up to count nodes in the history chain of a node. - * The initial element of the list returned will be desc - * (as long as the count is non-zero). - * - * @param desc The descriptor for a node to find ancestors for. - * @param count maximum number of ancestors to return in the list - * (the value -1 means - * "no limit -- return them all") - * @return A List of ancestors starting with the most recent. - * @throws AVMNotFoundException - */ - public List getHistory(AVMNodeDescriptor desc, int count); - - /** - * Set the opacity of a layered directory. - * An opaque layered directory hides the contents of its indirection. - * - * @param path The path to the layered directory. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public void setOpacity(String path, boolean opacity); - - /** - * Get the common ancestor of two nodes if a common ancestor exists. - * This function is useful for detecting and merging conflicts. - * - * @param left The first node. - * @param right The second node. - * @return The common ancestor. There are four possible results. Null means - * that there is no common ancestor. Left returned means that left is strictly - * an ancestor of right. Right returned means that right is strictly an - * ancestor of left. Any other non null return is the common ancestor and - * indicates that left and right are in conflict. - * @throws AVMNotFoundException - */ - public AVMNodeDescriptor getCommonAncestor(AVMNodeDescriptor left, - AVMNodeDescriptor right); - - /** - * Get layering information about a path. - * The LayeringDescriptor returned can be used to determine - * whether a node is in the background (and if so, which - * AVM store contains it directly), or if it is directly - * contained by the AVM store referenced by path. - * - * - * @param version The version to look under. - * @param path The absolute AVM path. - * @return A LayeringDescriptor. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public LayeringDescriptor getLayeringInfo(int version, String path); - - /** - * Set a property on a node. - * - * @param path The path to the node to set the property on. - * @param name The QName of the property. - * @param value The property to set. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - 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 properties to set. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public void setNodeProperties(String path, Map properties); - - /** - * Get a property of a node by QName. - * - * @param version The version to look under. - * @param path The path to the node. - * @param name The QName. - * @return The PropertyValue or null if it doesn't exist. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public PropertyValue getNodeProperty(int version, String path, QName name); - - /** - * Get all the properties associated with a node that is identified - * by a version ID and a path. - * - * @param version The version to look under. - * @param path The path to the node. - * @return A Map of QNames to PropertyValues. - * @throws AVMNotFoundException - */ - public Map getNodeProperties(int version, String path); - - - /** - * Delete a property. - *

- * Note: to remove an apsect, see: {@link #removeAspect(String path, QName aspectName) removeAspect} - * - * @param path The path to the node. - * @param name The QName of the property to delete. - * @throws AVMNotFoundException - */ - public void deleteNodeProperty(String path, QName name); - - /** - * Delete all the properties attached to an AVM node. - *

- * Note: to remove an apsect, see: {@link #removeAspect(String path, QName aspectName) removeAspect} - * - * @param path The path to the node. - * @throws AVMNotFoundException - */ - public void deleteNodeProperties(String path); - - /** - * Set a property on a store. If the property exists it will be overwritten. - * - * @param store The store to set the property on. - * @param name The name of the property. - * @param value The value of the property. - * @throws AVMNotFoundException - */ - public void setStoreProperty(String store, QName name, PropertyValue value); - - /** - * Set a group of properties on a store. Existing properties will be overwritten. - * - * @param store The name of the store. - * @param props A Map of the properties to set. - * @throws AVMNotFoundException - */ - public void setStoreProperties(String store, Map props); - - /** - * Get a property from a store. - * - * @param store The name of the store. - * @param name The name of the property. - * @return A PropertyValue or null if non-existent. - * @throws AVMNotFoundException - */ - public PropertyValue getStoreProperty(String store, QName name); - - /** - * Get all the properties associated with a store. - * - * @param store The name of the store. - * @return A Map of the stores properties. - * @throws AVMNotFoundException - */ - public Map getStoreProperties(String store); - - /** - * Queries a given store for properties with keys that match a given pattern. - * - * @param store The name of the store. - * @param keyPattern The sql 'like' pattern, inserted into a QName. - * @return A Map of the matching key value pairs. - * - * @deprecated - */ - public Map queryStorePropertyKey(String store, QName keyPattern); - - - /** - * Queries a given store for properties with keys that match a given pattern. - * - * @param store The name of the store. - * @param keyPattern The sql 'like' pattern, inserted into a QName. - * @return A Map of the matching key value pairs. - * - * @deprecated - */ - public Map> queryStoresPropertyKey(QName keyPattern); - - - /** - * Delete a property on a store by name. - *

- * Note: to remove an apsect, see: {@link #removeAspect(String path, QName aspectName) removeAspect} - * - * @param store The name of the store. - * @param name The name of the property to delete. - * @throws AVMNotFoundException - */ - public void deleteStoreProperty(String store, QName name); - - - /** - * Add an aspect to an AVM node. - * - * @param path The path to the node. - * @param aspectName The QName of the aspect. - * @throws AVMNotFoundException - * @throws AVMExistsException - */ - public void addAspect(String path, QName aspectName); - - /** - * Get all the aspects on an AVM node. - * - * @param version The version to look under. - * @param path The path to the node. - * @return A Set of the QNames of the aspects. - * @throws AVMNotFoundException - */ - public Set getAspects(int version, String path); - - - /** - * Remove an aspect and its properties from a node. - * - * @param path The path to the node. - * @param aspectName The name of the aspect. - * @throws AVMNotFoundException - */ - public void removeAspect(String path, QName aspectName); - - /** - * Determines whether a node has a particular aspect. - * - * @param version The version to look under. - * @param path The path to the node. - * @param aspectName The aspect name to check. - * @return Whether the given node has the given aspect. - * @throws AVMNotFoundException - */ - public boolean hasAspect(int version, String path, QName aspectName); - - - /** - * Rename a store. - * - * @param sourceName The original name. - * @param destName The new name. - * @throws AVMNotFoundException - * @throws AVMExistsException - */ - public void renameStore(String sourceName, String destName); - - /** - * 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 node to revert. - * @param toRevertTo The descriptor of the version to revert to. - * @throws AVMNotFoundException - */ - public void revert(String path, AVMNodeDescriptor toRevertTo); - - - /** - * Set the GUID on a node. The GUID of a node uniquely identifies - * the state of a node, i.e. its content, metadata, and aspects. - * @param path The path to the node. - * @param guid The GUID to set. - */ - public void setGuid(String path, String guid); - - /** - * Set the mime type. - * @param path The path of the file. - * @param mimeType The mime type. - */ - public void setMimeType(String path, String mimeType); - - /** - * Set the encoding. - * @param path The path of the file. - * @param encoding The encoding. - */ - public void setEncoding(String path, String encoding); - - - // To be included in AVMRemote eventually (y/n) - // | - // V - // - // n public ContentReader getContentReader(int version, String path); - // n public ContentWriter getContentWriter(String path); - // n public ContentData getContentDataForRead(int version, String path); - // n public ContentData getContentDataForRead(AVMNodeDescriptor desc); - // n public ContentData getContentDataForWrite(String path); - // n public void setContentData(String path, ContentData data); - // y public SortedMap getDirectoryListing(int version, String path, - // boolean includeDeleted); - // y public SortedMap - // getDirectoryListingDirect(int version, String path, boolean includeDeleted); - // - // y public AVMNodeDescriptor [] getDirectoryListingArray(int version, String path, - // boolean includeDeleted); - // - // y public SortedMap getDirectoryListing(AVMNodeDescriptor dir, - // boolean includeDeleted); - // - // y public AVMNodeDescriptor [] getDirectoryListingArray(AVMNodeDescriptor dir, - // boolean includeDeleted); - // - // - // y public void createFile(String path, String name, InputStream in); - // y public void createFile(String path, String name, InputStream in, List aspects, Map properties); - // - // y public void createDirectory(String path, String name, List aspects, Map properties); - // y public void removeNode(String path); - // y public void makeTransparent(String dirPath, String name); - // y public AVMStoreDescriptor getSystemStore(); - // y public List> getPaths(AVMNodeDescriptor desc); - // y public List> getHeadPaths(AVMNodeDescriptor desc); - // y public List> getPathsInStoreHead(AVMNodeDescriptor desc, String store); - // y public List getPathsInStoreVersion(AVMNodeDescriptor desc, String store, int version); - // y public Map getNodeProperties(AVMNodeDescriptor desc); - // - // y public Map> - // queryStoresPropertyKeys(QName keyPattern); - // - // y public void setMetaDataFrom(String path, AVMNodeDescriptor from); - // y public Set getAspects(AVMNodeDescriptor desc); - // y public void link(String parentPath, String name, AVMNodeDescriptor toLink); - // y public AVMNodeDescriptor forceCopy(String path); - // y public void copy(int srcVersion, String srcPath, String dstPath, String name); - - -} diff --git a/source/java/org/alfresco/service/cmr/remote/AVMRemoteTransport.java b/source/java/org/alfresco/service/cmr/remote/AVMRemoteTransport.java deleted file mode 100644 index eed8f10588..0000000000 --- a/source/java/org/alfresco/service/cmr/remote/AVMRemoteTransport.java +++ /dev/null @@ -1,549 +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 . - */ -package org.alfresco.service.cmr.remote; - -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.AVMExistsException; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMNotFoundException; -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.namespace.QName; -import org.alfresco.util.Pair; - -/** - * This is the actual remote interface that is wrapped by - * RMI. - * @author britt - */ -public interface AVMRemoteTransport -{ - /** - * Get an input handle. A handle is an opaque reference - * to a server side input stream. - * @param version The version to look under. - * @param path The path to the file. - * @return A handle. - */ - public String getInputHandle(String ticket, int version, String path); - - /** - * Get an input handle from a descriptor. - * @param ticket The authentication ticket. - * @param desc The descriptor. - * @return An input handle. - */ - public String getInputHandle(String ticket, AVMNodeDescriptor desc); - - /** - * Read a chunk of data from a handle. - * @param handle The opaque input stream handle. - * @param count The number of bytes to try to read. - * @return An array of bytes. 0 length at eof. - */ - public byte[] readInput(String Ticket, String handle, int count); - - /** - * Close an input stream. Server side input streams are - * timer limited, ie, they will be automatically closed - * after a given idle time. However, be nice, and close - * handles when you're done. - * @param handle The opaque handle to the server side stream. - */ - public void closeInputHandle(String ticket, String handle); - - /** - * Get an opaque handle to a server side output stream. - * @param path The path to the existing file. - * @return An opaque handle. - */ - public String getOutputHandle(String ticket, String path); - - /** - * Write count bytes from buffer buff - * starting at offset offset in buff - * @param handle The opaque handle to the server side output stream. - * @param buff The data buffer. - * @param count The number of bytes to write. - */ - public void writeOutput(String ticket, String handle, byte [] buff, int count); - - /** - * Close the server side output stream designated by the handle. - * @param handle The handle to the server side output stream. - */ - public void closeOutputHandle(String ticket, String handle); - - /** - * Get a listing of a directories direct contents. - * @param version The version to look under. - * @param path The path to the directory. - * @return A sorted listing. - */ - public SortedMap - getDirectoryListingDirect(String ticket, int version, String path); - - /** - * Get a listing of a directory. - * @param version The version to look under. - * @param path The path to the directory. - * @return A sorted listing. - */ - public SortedMap - getDirectoryListing(String ticket, int version, String path); - - /** - * Get a directory listing from a node descriptor. - * @param dir The directory node descriptor. - * @return A sorted listing. - */ - public SortedMap - getDirectoryListing(String ticket, AVMNodeDescriptor dir); - - /** - * Get the names of nodes that have been deleted in a directory. - * @param version The version to look under. - * @param path The path to the directory. - * @return A list of deleted names. - */ - public List getDeleted(String ticket, int version, String path); - - /** - * Create a file and return a handle to an output stream. - * @param path The path to the file. - * @param name The name of the file to create. - * @return An opaque handle to a server side output stream. - */ - public String createFile(String ticket, String path, String name); - - /** - * Create a directory. - * @param path The path to the containing directory. - * @param name The name for the new directory. - */ - public void createDirectory(String ticket, String path, String name); - - /** - * Create a new layered file. - * @param targetPath The path that is targeted. - * @param parent The path to the parent directory. - * @param name The name for the new file. - */ - public void createLayeredFile(String ticket, String targetPath, String parent, String name); - - /** - * Create a layered directory. - * @param targetPath The path that is targeted. - * @param parent The parent directory. - * @param name The name of the new directory. - */ - public void createLayeredDirectory(String ticket, String targetPath, String parent, String name); - - /** - * Set a layered directory node to point at a different target. - * @param path The path to the layered directory node. - * @param target The new target. - */ - public void retargetLayeredDirectory(String ticket, String path, String target); - - /** - * Create a new AVMStore. - * @param name The name to give the new store. - */ - public void createStore(String ticket, String name); - - /** - * Create a new branch. - * @param version The version to look under for the source node. - * @param srcPath The path to the source node. - * @param dstPath The path to the destination directory. - * @param name The name of the new branch. - */ - public void createBranch(String ticket, int version, String srcPath, String dstPath, String name); - - /** - * Remove a node. - * @param parent The path to the parent directory. - * @param name The name of the node to remove. - */ - public void removeNode(String ticket, String parent, String name); - - /** - * Rename a node. - * @param srcParent The source directory path. - * @param srcName The source node name. - * @param dstParent The destination directory path. - * @param dstName The destination name for the node. - */ - public void rename(String ticket, String srcParent, String srcName, String dstParent, String dstName); - - /** - * Uncover a name in a layered directory. - * @param dirPath The path to the directory. - * @param name The name to uncover. - */ - public void uncover(String ticket, String dirPath, String name); - - /** - * Get the latest version id of the given AVMStore. - * @param storeName The name of the AVMStore. - * @return The latest version id. - */ - public int getNextVersionID(String ticket, String storeName); - - /** - * Get the id of the latest extant snpashot. - * @param storeName The name of the store. - * @return The id. - */ - public int getLatestSnapshotID(String ticket, String storeName); - - /** - * Snapshot an AVMStore. - * @param store The name of the AVMStore to snapshot. - * @return The map of explicitly and implicitly snapshotted stores. - */ - public Map createSnapshot(String ticket, String store, String label, String comment); - - /** - * Get a List of all versions in a given store. - * @param name The name of the store. - * @return A List of VersionDescriptors. - */ - public List getStoreVersions(String ticket, String name); - - /** - * Get AVMStore versions between given dates. - * @param name The name of the store. - * @param from The date from which (inclusive). - * @param to The date to which (inclusive). - * @return A List of VersionDescriptors. - */ - public List getStoreVersions(String ticket, String name, Date from, Date to); - - /** - * Get a list of all AVM stores. - * @return A List of AVMStoreDescriptors. - */ - public List getStores(String ticket); - - /** - * Get the descriptor for a given AVMStore. - * @param name The name of the store. - * @return An AVMStoreDescriptor. - */ - public AVMStoreDescriptor getStore(String ticket, String name); - - /** - * Get the specified root of the specified store. - * @param version The version number to fetch. - * @param name The name of the store. - * @return The AVMNodeDescriptor for the root. - */ - public AVMNodeDescriptor getStoreRoot(String ticket, int version, String name); - - /** - * Get a descriptor for the specified node. - * @param version The version to look under. - * @param path The path to the node. - * @return An AVMNodeDescriptor. - */ - public AVMNodeDescriptor lookup(String ticket, int version, String path); - - /** - * Lookup a node identified by version ID and path; optionally, - * if the node is deleted, its descriptor can still - * be retrieved. - * - * @param version The version ID to look under. - * @param path The simple absolute path to the parent directory. - * @param includeDeleted Whether to allow a deleted node to be retrieved - * @return An AVMNodeDescriptor, or null if the version does not exist. - */ - public AVMNodeDescriptor lookup(String ticket, int version, String path, boolean includeDeleted); - - - /** - * Get a descriptor for the specified node. - * @param dir The descriptor for the directory node. - * @param name The name of the node to lookup. - * @return An AVMNodeDescriptor. - */ - public AVMNodeDescriptor lookup(String ticket, AVMNodeDescriptor dir, String name); - - /** - * Lookup a node identified by the directory that contains it, and its name; - * optionally, the lookup can retrive the descriptor of a node even if - * it has been deleted from its containing directory. - * - * @param dir The descriptor for the directory node. - * @param name The name to lookup. - * @param includeDeleted Whether to allow a deleted node to be retrieved via the lookup - * @return The descriptor for the child, null if the child doesn't exist. - * @throws AVMNotFoundException - * @throws AVMWrongTypeException - */ - public AVMNodeDescriptor lookup(String ticket, AVMNodeDescriptor dir, String name, boolean includeDeleted); - - - /** - * Get the indirection path for a node. - * @param version The version to look under. - * @param path The path to the node. - * @return The indirection path/target. - */ - public String getIndirectionPath(String ticket, int version, String path); - - /** - * Purge an AVMStore. - * @param name The name of the store to purge. - */ - public void purgeStore(String ticket, String name); - - /** - * Purge a given version from a given store. - * @param version The version id. - * @param name The name of the store. - */ - public void purgeVersion(String ticket, int version, String name); - - /** - * Turn a directory into a primary indirection node. - * @param path The path to the directory. - */ - public void makePrimary(String ticket, String path); - - /** - * Get a list of ancestors of a node. - * @param desc The descriptor of the node whose history is to be fetched. - * @param count The maximum number of ancestors that will be returned. - * @return A List of descriptors for ancestors starting most recent first. - */ - public List getHistory(String ticket, AVMNodeDescriptor desc, int count); - - /** - * Turn on or off a directory's opacity. - * @param path The path to the directory. - * @param opacity Whether the directory should be opaque or not. - */ - public void setOpacity(String ticket, String path, boolean opacity); - - /** - * Get the most recent common ancestor of two nodes. - * @param left One node. - * @param right The other node. - * @return The common ancestor. - */ - public AVMNodeDescriptor getCommonAncestor(String ticket, AVMNodeDescriptor left, AVMNodeDescriptor right); - - /** - * Get layering information about a path. - * @param version The version to look under. - * @param path The path to the node. - * @return A LayeringDescriptor. - */ - public LayeringDescriptor getLayeringInfo(String ticket, int version, String path); - - /** - * 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 give the property. - */ - public void setNodeProperty(String ticket, String path, QName name, PropertyValue value); - - /** - * Set a group of properties on a node. - * @param path The path to the node. - * @param properties A Map of QNames to PropertyValues to set. - */ - public void setNodeProperties(String ticket, String path, Map properties); - - /** - * Get the value of a node property. - * @param version The version to look under. - * @param path The path to the node. - * @param name The name of the property. - * @return A PropertyValue. - */ - public PropertyValue getNodeProperty(String ticket, int version, String path, QName name); - - /** - * Get all properties of a node. - * @param version The version. - * @param path The path to the node. - * @return A Map of QNames to PropertyValues. - */ - public Map getNodeProperties(String ticket, int version, String path); - - /** - * Delete a property from a node. - * @param path The path to the node. - * @param name The name of the property. - */ - public void deleteNodeProperty(String ticket, String path, QName name); - - /** - * Delete all properties from a node. - * @param path The path to the node. - */ - public void deleteNodeProperties(String ticket, String path); - - /** - * Set a property on a store. - * @param store The name of the store. - * @param name The name of the property to set. - * @param value The value of the property to set. - */ - public void setStoreProperty(String ticket, String store, QName name, PropertyValue value); - - /** - * Set a group of properties on a store. - * @param store The name of the store. - * @param props A Map of QNames to PropertyValues to set. - */ - public void setStoreProperties(String ticket, String store, Map props); - - /** - * Get a property from a store. - * @param store The name of the store. - * @param name The name of the property. - * @return A PropertyValue. - */ - public PropertyValue getStoreProperty(String ticket, String store, QName name); - - /** - * Query a store for keys that match a pattern. - * @param store The store name. - * @param keyPattern The sql 'like' pattern. - * @return A Map of keys to values. - */ - public Map queryStorePropertyKey(String ticket, String store, QName keyPattern); - - /** - * Query all stores for keys that match a pattern. - * @param keyPattern The sql 'like' pattern. - * @return A Map of store names to Maps of matching keys to values. - */ - public Map> queryStoresPropertyKey(String ticket, QName keyPattern); - - /** - * Get all the properties on a store. - * @param store The name of the store. - * @return A Map of QNames to PropertyValues. - */ - public Map getStoreProperties(String ticket, String store); - - /** - * Delete a property from a store. - * @param store The name of the store. - * @param name The name of the property. - */ - public void deleteStoreProperty(String ticket, String store, QName name); - - /** - * Rename a store. - * @param ticket The authentication ticket. - * @param sourceName The original name. - * @param destName The new name. - */ - public void renameStore(String ticket, String sourceName, String destName); - /** - * Add an aspect to an AVM node. - * @param path The path to the node. - * @param aspectName The QName of the aspect. - * @throws AVMNotFoundException - * @throws AVMExistsException - */ - public void addAspect(String ticket, String path, QName aspectName); - - /** - * Get all the aspects on an AVM node. - * @param version The version to look under. - * @param path The path to the node. - * @return A List of the QNames of the aspects. - * @throws AVMNotFoundException - */ - public Set getAspects(String ticket, int version, String path); - - /** - * Remove an aspect and its properties from a node. - * @param path The path to the node. - * @param aspectName The name of the aspect. - * @throws AVMNotFoundException - */ - public void removeAspect(String ticket, String path, QName aspectName); - - /** - * Does a node have a particular aspect. - * @param version The version to look under. - * @param path The path to the node. - * @param aspectName The aspect name to check. - * @return Whether the given node has the given aspect. - * @throws AVMNotFoundException - */ - public boolean hasAspect(String ticket, int version, String path, QName aspectName); - - /** - * 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 node to revert. - * @param toRevertTo The descriptor of the version to revert to. - * @throws AVMNotFoundException - */ - public void revert(String ticket, String path, AVMNodeDescriptor toRevertTo); - - /** - * Get a version and path for a node. - * @param ticket The authentication ticket. - * @param desc The node descriptor for the node we want to get a path to. - * @return version and path. - */ - public Pair getAPath(String ticket, AVMNodeDescriptor desc); - - /** - * Set the GUID on a node. - * @param ticket The authentication ticket. - * @param path The path to the node. - * @param guid The GUID to set. - */ - public void setGuid(String ticket, String path, String guid); - - /** - * Set the mime type. - * @param path The path of the file. - * @param mimeType The mime type. - */ - public void setMimeType(String ticket, String path, String mimeType); - - /** - * Set the encoding. - * @param path The path of the file. - * @param encoding The encoding. - */ - public void setEncoding(String ticket, String path, String encoding); -} diff --git a/source/java/org/alfresco/service/cmr/remote/AVMSyncServiceTransport.java b/source/java/org/alfresco/service/cmr/remote/AVMSyncServiceTransport.java deleted file mode 100644 index c0526e8a91..0000000000 --- a/source/java/org/alfresco/service/cmr/remote/AVMSyncServiceTransport.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2005-2012 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 . - */ -package org.alfresco.service.cmr.remote; - -import java.util.List; - -import org.alfresco.service.cmr.avmsync.AVMDifference; -import org.alfresco.util.NameMatcher; - -/** - * A wrapper around AVMSyncService for remote access. - * @author britt - */ -public interface AVMSyncServiceTransport -{ - /** - * Get a difference list between two corresponding node trees. - * @param srcVersion The version id for the source tree. - * @param srcPath The avm path to the source tree. - * @param dstVersion The version id for the destination tree. - * @param dstPath The avm path to the destination tree. - * @return A List of AVMDifference structs which can be used for - * the update operation. - */ - public List compare(String ticket, - int srcVersion, String srcPath, - int dstVersion, String dstPath, - NameMatcher excluder); - - /** - * Get a difference list between two corresponding node trees. New/modified children in new/modified directories will be also included - * - * @param srcVersion The version id for the source tree. - * @param srcPath The avm path to the source tree. - * @param dstVersion The version id for the destination tree. - * @param dstPath The avm path to the destination tree. - * @param expandDirs {@link Boolean} value that determines whether new/modified children in new/modified directories be included into result - * @return A List of AVMDifference structs which can be used for - * the update operation. - */ - public List compare(String ticket, - int srcVersion, String srcPath, - int dstVersion, String dstPath, - NameMatcher excluder, boolean expandDirs); - - /** - * Updates the destination nodes in the AVMDifferences - * with the source nodes. Normally any conflicts or cases in - * which the source of an AVMDifference is older than the destination - * will cause the transaction to roll back. - * @param diffList A List of AVMDifference structs. - * @param excluder A NameMatcher to exclude undesired updates. - * @param ignoreConflicts If this is true the update will skip those - * AVMDifferences which are in conflict with - * the destination. - * @param ignoreOlder If this is true the update will skip those - * AVMDifferences which have the source older than the destination. - * @param overrideConflicts If this is true the update will override conflicting - * AVMDifferences and replace the destination with the conflicting source. - * @param overrideOlder If this is true the update will override AVMDifferences - * in which the source is older than the destination and overwrite the destination. - * @param tag Short comment. - * @param description Full update blurb. - */ - public void update(String ticket, List diffList, - NameMatcher excluder, boolean ignoreConflicts, boolean ignoreOlder, - boolean overrideConflicts, boolean overrideOlder, String tag, String description); - - /** - * Flattens a layer so that all all nodes under and including - * layerPath become translucent to any nodes in the - * corresponding location under and including underlyingPath - * that are the same version. - * @param layerPath The overlying layer path. - * @param underlyingPath The underlying path. - */ - public void flatten(String ticket, String layerPath, String underlyingPath); - - /** - * Takes a layer, deletes it and recreates it pointing at the same underlying - * node. Any changes in the layer are lost (except to history if the layer has been - * snapshotted.) - * @param layerPath - */ - public void resetLayer(String ticket, String layerPath); -} diff --git a/source/java/org/alfresco/service/cmr/view/AVMZipExporterService.java b/source/java/org/alfresco/service/cmr/view/AVMZipExporterService.java deleted file mode 100644 index f5e942dacc..0000000000 --- a/source/java/org/alfresco/service/cmr/view/AVMZipExporterService.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 . - */ -package org.alfresco.service.cmr.view; - -import java.io.File; -import java.io.IOException; -import java.util.zip.ZipException; -import java.util.zip.ZipOutputStream; - -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; - -/** - * Exporter which allows the saving of part of an AVM - * filesystem to a Zip file. - * - * @author Nick Burch - */ -public interface AVMZipExporterService -{ - /** - * Exports the given path and version as a zip file, stored - * in the specified file. - * - * @param output The File to store the Zip in - * @param path The AVM path to export - * @param version The AVM version IO - * @param recurse Should the export recurse into directories? - */ - public void export(File output, int version, String path, boolean recurse) - throws IOException, ZipException; - - /** - * Exports the given path and version into an already open - * Zip file. This method can be used to output multiple different - * AVM resources into one file. - * - * @param output The File to store the Zip in - * @param path The AVM path to export - * @param version The AVM version IO - * @param recurse Should the export recurse into directories? - */ - public void export(ZipOutputStream out, int version, String path, boolean recurse) - throws IOException, ZipException; - - /** - * Exports the given AVM node into an already open - * Zip file. This method can be used to output multiple different - * AVM resources into one file. - * - * @param output The File to store the Zip in - * @param node The AVM node to export - * @param recurse Should the export recurse into directories? - */ - public void export(ZipOutputStream out, AVMNodeDescriptor node, boolean recurse) - throws IOException, ZipException; -} diff --git a/source/java/org/alfresco/util/XMLUtil.java b/source/java/org/alfresco/util/XMLUtil.java index 683e356805..d72d496591 100644 --- a/source/java/org/alfresco/util/XMLUtil.java +++ b/source/java/org/alfresco/util/XMLUtil.java @@ -31,7 +31,6 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.alfresco.model.ContentModel; -import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.NodeRef; @@ -133,16 +132,6 @@ public class XMLUtil return XMLUtil.parse(in); } - /** utility function for parsing xml */ - public static Document parse(final int version, - final String path, - final AVMService avmService) - throws SAXException, - IOException - { - return XMLUtil.parse(avmService.getFileInputStream(version, path)); - } - /** utility function for parsing xml */ public static Document parse(final File source) throws SAXException, diff --git a/source/java/org/alfresco/wcm/actions/WCMSandboxRevertSnapshotAction.java b/source/java/org/alfresco/wcm/actions/WCMSandboxRevertSnapshotAction.java deleted file mode 100644 index 69985d9811..0000000000 --- a/source/java/org/alfresco/wcm/actions/WCMSandboxRevertSnapshotAction.java +++ /dev/null @@ -1,94 +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 . - */ -package org.alfresco.wcm.actions; - -import java.util.List; - -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.Pair; -import org.alfresco.wcm.sandbox.SandboxService; -import org.alfresco.wcm.util.WCMUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * WCM Revert Snapshot example action (supercedes AVMRevertStoreAction) - * - * Reverts (staging) sandbox to a specified snapshot version. - * - * @author janv - */ -public class WCMSandboxRevertSnapshotAction extends ActionExecuterAbstractBase -{ - private static Log logger = LogFactory.getLog(WCMSandboxRevertSnapshotAction.class); - - public static final String NAME = "wcm-revert-snapshot"; - public static final String PARAM_VERSION = "version"; - - /** - * The WCM SandboxService - */ - private SandboxService sbService; - - public void setSandboxService(SandboxService sbService) - { - this.sbService = sbService; - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - // All this does is an override submit from the older version - // to head of the store implied in the path. - Pair pathVersion = - AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef); - - if (pathVersion.getFirst() != -1) - { - logger.warn("Ignored version "+pathVersion.getFirst()+" for "+actionedUponNodeRef+" (will revert latest)"); - } - - int revertVersion = (Integer)action.getParameterValue(PARAM_VERSION); - String sbStoreId = WCMUtil.getSandboxStoreId(pathVersion.getSecond()); - - sbService.revertSnapshot(sbStoreId, revertVersion); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add( - new ParameterDefinitionImpl(PARAM_VERSION, - DataTypeDefinition.INT, - true, - getParamDisplayLabel(PARAM_VERSION))); - } -} diff --git a/source/java/org/alfresco/wcm/actions/WCMSandboxSubmitAction.java b/source/java/org/alfresco/wcm/actions/WCMSandboxSubmitAction.java deleted file mode 100644 index 80a2e7985f..0000000000 --- a/source/java/org/alfresco/wcm/actions/WCMSandboxSubmitAction.java +++ /dev/null @@ -1,95 +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 . - */ -package org.alfresco.wcm.actions; - -import java.util.List; - -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.wcm.sandbox.SandboxService; - -/** - * WCM Submit example action (supercedes SimpleAVMSubmitAction) - * - * Submit changed assets from a user sandbox to corresponding staging sandbox - either all or a list - * - * The actionedUponNodeRef is a dummy and can be null. - * - * @author janv - */ -public class WCMSandboxSubmitAction extends ActionExecuterAbstractBase -{ - public static String NAME = "wcm-submit"; - - public static final String PARAM_PATH_LIST = "path-list"; // list of paths (relative to sandbox store) - public static final String PARAM_SANDBOX_ID = "sandbox-id"; // sandbox store id - - /** - * The WCM SandboxService - */ - private SandboxService sbService; - - public void setSandboxService(SandboxService sbService) - { - this.sbService = sbService; - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("unchecked") - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - String sbStoreId = (String)action.getParameterValue(PARAM_SANDBOX_ID); - List relativePaths = (List)action.getParameterValue(PARAM_PATH_LIST); - - if ((relativePaths == null) || (relativePaths.size() == 0)) - { - sbService.submitAll(sbStoreId, "Submit Action", "Submit all changed items in sandbox: " + sbStoreId); - } - else - { - sbService.submitList(sbStoreId, relativePaths, "Submit Action", "Submit list of changed items in sandbox: " + sbStoreId); - } - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add( - new ParameterDefinitionImpl(PARAM_PATH_LIST, - DataTypeDefinition.ANY, - false, - getParamDisplayLabel(PARAM_PATH_LIST))); - - paramList.add( - new ParameterDefinitionImpl(PARAM_SANDBOX_ID, - DataTypeDefinition.TEXT, - true, - getParamDisplayLabel(PARAM_SANDBOX_ID))); - } -} diff --git a/source/java/org/alfresco/wcm/actions/WCMSandboxUndoAction.java b/source/java/org/alfresco/wcm/actions/WCMSandboxUndoAction.java deleted file mode 100644 index 7a10bf19f5..0000000000 --- a/source/java/org/alfresco/wcm/actions/WCMSandboxUndoAction.java +++ /dev/null @@ -1,95 +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 . - */ -package org.alfresco.wcm.actions; - -import java.util.List; - -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.wcm.sandbox.SandboxService; - -/** - * WCM Undo example action (supercedes AVMUndoSandboxListAction) - * - * Undo (ie. throw away) changed assets in a user sandbox - either all or a list - * - * The actionedUponNodeRef is a dummy and can be null. - * - * @author janv - */ -public class WCMSandboxUndoAction extends ActionExecuterAbstractBase -{ - public static final String NAME = "wcm-undo"; - - public static final String PARAM_PATH_LIST = "path-list"; // list of paths (relative to sandbox store) - public static final String PARAM_SANDBOX_ID = "sandbox-id"; // sandbox store id - - /** - * The WCM SandboxService - */ - private SandboxService sbService; - - public void setSandboxService(SandboxService sbService) - { - this.sbService = sbService; - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("unchecked") - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - String sbStoreId = (String)action.getParameterValue(PARAM_SANDBOX_ID); - List relativePaths = (List)action.getParameterValue(PARAM_PATH_LIST); - - if ((relativePaths == null) || (relativePaths.size() == 0)) - { - sbService.revertAll(sbStoreId); - } - else - { - sbService.revertList(sbStoreId, relativePaths); - } - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add( - new ParameterDefinitionImpl(PARAM_PATH_LIST, - DataTypeDefinition.ANY, - false, - getParamDisplayLabel(PARAM_PATH_LIST))); - - paramList.add( - new ParameterDefinitionImpl(PARAM_SANDBOX_ID, - DataTypeDefinition.TEXT, - true, - getParamDisplayLabel(PARAM_SANDBOX_ID))); - } -} diff --git a/source/java/org/alfresco/wcm/asset/AssetInfo.java b/source/java/org/alfresco/wcm/asset/AssetInfo.java deleted file mode 100644 index fbc37fa872..0000000000 --- a/source/java/org/alfresco/wcm/asset/AssetInfo.java +++ /dev/null @@ -1,59 +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 . - */ -package org.alfresco.wcm.asset; - -import java.util.Date; - -/** -* Provides basic information about a WCM asset -*/ -public interface AssetInfo -{ - public String getName(); - - public String getSandboxId(); - - public int getSandboxVersion(); - - public String getPath(); // full path, eg. include /www/avm_webapps/... - - public boolean isFile(); - - public boolean isFolder(); - - public boolean isDeleted(); - - public boolean isLocked(); // files only, false for folder - - public long getFileSize(); // files only, -1 for folder - - public String getLockOwner(); // files only, null if no lock (or folder) - - public String getCreator(); - - public Date getCreatedDate(); - - public String getModifier(); - - public Date getModifiedDate(); - - public String getAvmPath(); // absolute AVM path, eg. : - - public int getDiffCode(); // if applicable, eg. when getting list of changed assets (see AVMDifference for diff codes), else -1 -} diff --git a/source/java/org/alfresco/wcm/asset/AssetInfoImpl.java b/source/java/org/alfresco/wcm/asset/AssetInfoImpl.java deleted file mode 100644 index 3f910517e5..0000000000 --- a/source/java/org/alfresco/wcm/asset/AssetInfoImpl.java +++ /dev/null @@ -1,132 +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 . - */ -package org.alfresco.wcm.asset; - -import java.util.Date; - -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.wcm.util.WCMUtil; - -/** - * Provides information about a WCM asset - */ -public class AssetInfoImpl implements AssetInfo -{ - private AVMNodeDescriptor node; - private String lockOwner = null; // null if not locked - private int sandboxVersion = -1; - private int diffCode = -1; // if applicable, eg. when getting list of modified assets - - /* package */ AssetInfoImpl(int sandboxVersion, AVMNodeDescriptor node, String lockOwner) - { - this.sandboxVersion = sandboxVersion; - this.node = node; - this.lockOwner = lockOwner; - } - - public String getName() - { - return node.getName(); - } - - public String getSandboxId() - { - return WCMUtil.getSandboxStoreId(node.getPath()); - } - - public String getPath() - { - return WCMUtil.getStoreRelativePath(node.getPath()); - } - - public boolean isFile() - { - return (node.isFile() || node.isDeletedFile()); - } - - public boolean isFolder() - { - return (node.isDirectory() || node.isDeletedDirectory()); - } - - public boolean isDeleted() - { - return node.isDeleted(); - } - - public String getCreator() - { - return node.getCreator(); - } - - public Date getCreatedDate() - { - return new Date(node.getCreateDate()); - } - - public String getModifier() - { - return node.getLastModifier(); - } - - public Date getModifiedDate() - { - return new Date(node.getModDate()); - } - - public int getSandboxVersion() - { - return sandboxVersion; - } - - public boolean isLocked() - { - return (lockOwner != null); - } - - public long getFileSize() - { - return node.getLength(); - } - - public String getLockOwner() - { - return lockOwner; - } - - public AVMNodeDescriptor getAVMNodeDescriptor() - { - return node; - } - - public String getAvmPath() - { - return node.getPath(); - } - - public int getDiffCode() - { - return diffCode; - } - - public void setDiffCode(int diffCode) - { - this.diffCode = diffCode; - } -} diff --git a/source/java/org/alfresco/wcm/asset/AssetService.java b/source/java/org/alfresco/wcm/asset/AssetService.java deleted file mode 100644 index a03866dfc6..0000000000 --- a/source/java/org/alfresco/wcm/asset/AssetService.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright (C) 2005-2011 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 . - */ -package org.alfresco.wcm.asset; - -import java.io.File; -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.service.PublicService; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.Auditable; -import org.alfresco.service.NotAuditable; - -/** - * Asset Service fundamental API. - *

- * This service API is designed to support the public facing Asset APIs. - * - * @author janv - */ -public interface AssetService -{ - /** - * Create folder within given sandbox and webApp - */ - @NotAuditable - public void createFolderWebApp(String sbStoreId, String webApp, String parentFolderPathRelativeToWebApp, String name); - - /** - * Create folder within given sandbox - */ - @NotAuditable - public void createFolder(String sbStoreId, String parentFolderPath, String name, Map properties); - - /** - * Create (empty) file within given sandbox and webApp, return content writer for file contents - */ - @NotAuditable - public ContentWriter createFileWebApp(String sbStoreId, String webApp, String parentFolderPath, String name); - - /** - * Create (empty) file within given sandbox, return content writer for file contents - */ - @NotAuditable - public ContentWriter createFile(String sbStoreId, String parentFolderPath, String name, Map properties); - - /** - * Get asset (file or folder) for given sandbox, webApp and path (within webApp) - *

- * Returns null if the asset can not be found - */ - @NotAuditable - public AssetInfo getAssetWebApp(String sbStoreId, String webApp, String pathRelativeToWebApp); - - /** - * Get asset (file or folder) for given sandbox, webApp and path (within webApp), optionally include deleted assets - *

- * Returns null if the asset can not be found - */ - @NotAuditable - public AssetInfo getAssetWebApp(String sbStoreId, String webApp, String pathRelativeToWebApp, boolean includeDeleted); - - /** - * Get asset (file or folder) for given sandbox and path - *

- * Returns null if the asset can not be found - * - * @param sbStoreId sandbox store id - * @param path asset path (eg. /www/avm_webapps/ROOT/myFile) - * @return AssetInfo asset info - */ - @NotAuditable - public AssetInfo getAsset(String sbStoreId, String path); - - /** - * Get asset (file or folder) for given sandbox version and path, optionally include deleted assets - *

- * Returns null if the asset can not be found - */ - @NotAuditable - public AssetInfo getAsset(String sbStoreId, int version, String path, boolean includeDeleted); - - /** - * Get content writer for given file asset, to allow file contents to be written or updated - */ - @NotAuditable - public ContentWriter getContentWriter(AssetInfo fileAsset); - - /** - * Get content reader for given file asset, to allow file contents to be read - */ - @NotAuditable - public ContentReader getContentReader(AssetInfo fileAsset); - - /** - * Get asset properties - */ - @NotAuditable - public Map getAssetProperties(AssetInfo asset); - - /** - * Set asset properties (will replace all existing properties) - */ - @NotAuditable - public void setAssetProperties(AssetInfo asset, Map properties); - - /** - * Update asset properties (will replace given set of properties, if they already exist) - */ - @NotAuditable - public void updateAssetProperties(AssetInfo asset, Map properties); - - /** - * Apply aspect to asset, with given properties (can be null) - */ - @NotAuditable - public void addAspect(AssetInfo asset, QName aspectName, Map properties); - - /** - * Remove aspect from asset, and any related properties - */ - @NotAuditable - public void removeAspect(AssetInfo asset, QName aspectName); - - /** - * Get set of aspects applied to asset - */ - @NotAuditable - public Set getAspects(AssetInfo asset); - - /** - * True, if asset has given aspect applied - */ - @NotAuditable - public boolean hasAspect(AssetInfo asset, QName aspectName); - - /** - * List assets within given sandbox and webApp and path (within webApp), optionally include deleted - */ - @NotAuditable - public List listAssetsWebApp(String sbStoreId, String webApp, String parentFolderPathRelativeToWebApp, boolean includeDeleted); - - /** - * List assets within given sandbox and path, optionally include deleted - */ - @NotAuditable - public List listAssets(String sbStoreId, String parentFolderPath, boolean includeDeleted); - - /** - * List assets within given sandbox version and path, optionally include deleted - */ - @NotAuditable - public List listAssets(String sbStoreId, int version, String parentFolderPath, boolean includeDeleted); - - /** - * Delete asset - */ - @NotAuditable - public void deleteAsset(AssetInfo asset); - - /** - * Rename asset - */ - @NotAuditable - public AssetInfo renameAsset(AssetInfo asset, String newName); - - /** - * Copy asset(s) within sandbox - *

- * Note: folder asset will be recursively copied - * Note: file asset(s) must have content - */ - @NotAuditable - public AssetInfo copyAsset(AssetInfo asset, String parentFolderPath); - - // TODO - copy asset to different sandbox ? - - /** - * Move asset within sandbox - */ - @NotAuditable - public AssetInfo moveAsset(AssetInfo asset, String parentFolderPath); - - /** - * Bulk import assets into sandbox - */ - @NotAuditable - public void bulkImport(String sbStoreId, String parentFolderPath, File zipFile, boolean isHighByteZip); - - /** - * Runtime check to get lock (and owner) for asset - null if not locked - * - * @return String lock owner (null if path not locked) - */ - @NotAuditable - public String getLockOwner(AssetInfo fileAsset); - - /** - * Runtime check to check if the current user can perform (write) operations on the asset when locked - * - * @return boolean true if current user has write access - */ - @NotAuditable - public boolean hasLockAccess(AssetInfo fileAsset); -} diff --git a/source/java/org/alfresco/wcm/asset/AssetServiceImpl.java b/source/java/org/alfresco/wcm/asset/AssetServiceImpl.java deleted file mode 100644 index 059ebe18d6..0000000000 --- a/source/java/org/alfresco/wcm/asset/AssetServiceImpl.java +++ /dev/null @@ -1,695 +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 . - */ -package org.alfresco.wcm.asset; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.mbeans.VirtServerRegistry; -import org.alfresco.model.ApplicationModel; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.action.executer.ImporterActionExecuter; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.repo.avm.util.AVMUtil; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.repo.transaction.AlfrescoTransactionSupport; -import org.alfresco.repo.transaction.TransactionListenerAdapter; -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.model.FileExistsException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.TempFileProvider; -import org.alfresco.wcm.sandbox.SandboxConstants; -import org.alfresco.wcm.util.WCMUtil; -import org.apache.commons.compress.archivers.zip.ZipFile; -import org.springframework.extensions.surf.util.ParameterCheck; - -/** - * Asset Service fundamental API. - *

- * This service API is designed to support the public facing Asset APIs. - * - * @author janv - */ -public class AssetServiceImpl implements AssetService -{ - private static char PATH_SEPARATOR = '/'; - - private static final int BUFFER_SIZE = 16384; - - private AVMService avmService; - private AVMLockingService avmLockingService; - private NodeService avmNodeService; // AVM node service (ML-aware) - private VirtServerRegistry virtServerRegistry; - - public void setAvmService(AVMService avmService) - { - this.avmService = avmService; - } - - public void setAvmLockingService(AVMLockingService avmLockingService) - { - this.avmLockingService = avmLockingService; - } - - public void setNodeService(NodeService avmNodeService) - { - this.avmNodeService = avmNodeService; - } - - public void setVirtServerRegistry(VirtServerRegistry virtServerRegistry) - { - this.virtServerRegistry = virtServerRegistry; - } - - private void checkMandatoryPath(String path) - { - ParameterCheck.mandatoryString("path", path); - - if (path.indexOf(AVMUtil.AVM_STORE_SEPARATOR_CHAR) != -1) - { - throw new IllegalArgumentException("Unexpected path '"+path+"' - should not contain '"+WCMUtil.AVM_STORE_SEPARATOR+"'"); - } - } - - private boolean isWebProjectStagingSandbox(String sbStoreId) - { - PropertyValue propVal = avmService.getStoreProperty(sbStoreId, SandboxConstants.PROP_WEB_PROJECT_NODE_REF); - return ((propVal != null) && (WCMUtil.isStagingStore(sbStoreId))); - } - - public void createFolderWebApp(String sbStoreId, String webApp, String parentFolderPathRelativeToWebApp, String name) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("webApp", webApp); - checkMandatoryPath(parentFolderPathRelativeToWebApp); - ParameterCheck.mandatoryString("name", name); - - if (! isWebProjectStagingSandbox(sbStoreId)) - { - parentFolderPathRelativeToWebApp = AVMUtil.addLeadingSlash(parentFolderPathRelativeToWebApp); - - String avmParentPath = WCMUtil.buildStoreWebappPath(sbStoreId, webApp) + parentFolderPathRelativeToWebApp; - - createFolderAVM(avmParentPath, name, null); - } - else - { - throw new AccessDeniedException("Not allowed to write in: " + sbStoreId); - } - } - - public void createFolder(String sbStoreId, String parentFolderPath, String name, Map properties) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("parentFolderPath", parentFolderPath); - ParameterCheck.mandatoryString("name", name); - - String avmParentPath = AVMUtil.buildAVMPath(sbStoreId, parentFolderPath); - - createFolderAVM(avmParentPath, name, properties); - } - - private void createFolderAVM(String avmParentPath, String name, Map properties) - { - ParameterCheck.mandatoryString("avmParentPath", avmParentPath); - ParameterCheck.mandatoryString("name", name); - - String sbStoreId = WCMUtil.getSandboxStoreId(avmParentPath); - if (! isWebProjectStagingSandbox(sbStoreId)) - { - avmService.createDirectory(avmParentPath, name); - - String avmPath = avmParentPath + PATH_SEPARATOR + name; - - // for WCM Web Client (Alfresco Explorer) - avmService.addAspect(avmPath, ApplicationModel.ASPECT_UIFACETS); - - if ((properties != null) && (properties.size() > 0)) - { - setProperties(avmPath, properties); - } - } - else - { - throw new AccessDeniedException("Not allowed to write in: " + sbStoreId); - } - } - - public ContentWriter createFileWebApp(String sbStoreId, String webApp, String parentFolderPathRelativeToWebApp, String name) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("webApp", webApp); - ParameterCheck.mandatoryString("parentFolderPathRelativeToWebApp", parentFolderPathRelativeToWebApp); - ParameterCheck.mandatoryString("name", name); - - parentFolderPathRelativeToWebApp = AVMUtil.addLeadingSlash(parentFolderPathRelativeToWebApp); - - String avmParentPath = WCMUtil.buildStoreWebappPath(sbStoreId, webApp) + parentFolderPathRelativeToWebApp; - - createFileAVM(avmParentPath, name); - - String avmPath = avmParentPath + PATH_SEPARATOR + name; - - return avmService.getContentWriter(avmPath, true); - } - - public ContentWriter createFile(String sbStoreId, String parentFolderPath, String name, Map properties) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("parentFolderPath", parentFolderPath); - ParameterCheck.mandatoryString("name", name); - - String avmParentPath = AVMUtil.buildAVMPath(sbStoreId, parentFolderPath); - - createFileAVM(avmParentPath, name); - - String avmPath = avmParentPath + PATH_SEPARATOR + name; - - if ((properties != null) && (properties.size() > 0)) - { - setProperties(avmPath, properties); - } - - return avmService.getContentWriter(avmPath, true); - } - - private void createFileAVM(String avmParentPath, String name) - { - ParameterCheck.mandatoryString("avmParentPath", avmParentPath); - ParameterCheck.mandatoryString("name", name); - - String sbStoreId = WCMUtil.getSandboxStoreId(avmParentPath); - if (! isWebProjectStagingSandbox(sbStoreId)) - { - try - { - avmService.createFile(avmParentPath, name).close(); - } - catch (IOException e) - { - throw new AlfrescoRuntimeException("I/O Error.", e); - } - } - else - { - throw new AccessDeniedException("Not allowed to write in: " + sbStoreId); - } - } - - private void createFileAVM(String avmParentPath, String name, InputStream in) - { - ParameterCheck.mandatoryString("avmParentPath", avmParentPath); - - String sbStoreId = WCMUtil.getSandboxStoreId(avmParentPath); - if (! isWebProjectStagingSandbox(sbStoreId)) - { - avmService.createFile(avmParentPath, name, in, null, null); - } - else - { - throw new AccessDeniedException("Not allowed to write in: " + sbStoreId); - } - } - - public ContentWriter getContentWriter(AssetInfo asset) - { - ParameterCheck.mandatory("asset", asset); - - if (! isWebProjectStagingSandbox(asset.getSandboxId())) - { - return avmService.getContentWriter(asset.getAvmPath(), true); - } - else - { - throw new AccessDeniedException("Not allowed to write in: " + asset.getSandboxId()); - } - } - - public ContentReader getContentReader(AssetInfo asset) - { - ParameterCheck.mandatory("asset", asset); - - return avmService.getContentReader(asset.getSandboxVersion(), asset.getAvmPath()); - } - - public AssetInfo getAssetWebApp(String sbStoreId, String webApp, String pathRelativeToWebApp) - { - return getAssetWebApp(sbStoreId, webApp, pathRelativeToWebApp, false); - } - - public AssetInfo getAssetWebApp(String sbStoreId, String webApp, String pathRelativeToWebApp, boolean includeDeleted) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("webApp", webApp); - ParameterCheck.mandatoryString("pathRelativeToWebApp", pathRelativeToWebApp); - - pathRelativeToWebApp = AVMUtil.addLeadingSlash(pathRelativeToWebApp); - - String avmPath = WCMUtil.buildStoreWebappPath(sbStoreId, webApp) + pathRelativeToWebApp; - - return getAssetAVM(-1, avmPath, includeDeleted); - } - - public AssetInfo getAsset(String sbStoreId, String path) - { - return getAsset(sbStoreId, -1, path, false); - } - - public AssetInfo getAsset(String sbStoreId, int version, String path, boolean includeDeleted) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("path", path); - - String avmPath = AVMUtil.buildAVMPath(sbStoreId, path); - - return getAssetAVM(version, avmPath, includeDeleted); - } - - private AssetInfo getAssetAVM(int version, String avmPath, boolean includeDeleted) - { - ParameterCheck.mandatoryString("avmPath", avmPath); - - AVMNodeDescriptor node = avmService.lookup(version, avmPath, includeDeleted); - - AssetInfo asset = null; - - if (node != null) - { - String lockOwner = null; - if (avmLockingService != null) - { - String wpStoreId = WCMUtil.getWebProjectStoreIdFromPath(avmPath); - String[] parts = WCMUtil.splitPath(avmPath); - lockOwner = getLockOwner(wpStoreId, parts[1]); - } - - asset = new AssetInfoImpl(version, node, lockOwner); - } - - return asset; - } - - public String getLockOwner(AssetInfo asset) - { - ParameterCheck.mandatory("asset", asset); - - return getLockOwner(WCMUtil.getWebProjectStoreId(asset.getSandboxId()), asset.getPath()); - } - - private String getLockOwner(String wpStoreId, String filePath) - { - return avmLockingService.getLockOwner(wpStoreId, filePath); - } - - public boolean hasLockAccess(AssetInfo asset) - { - ParameterCheck.mandatory("asset", asset); - - return avmLockingService.hasAccess( - WCMUtil.getWebProjectStoreId(asset.getSandboxId()), - asset.getAvmPath(), - AuthenticationUtil.getFullyAuthenticatedUser()); - } - - public void updateAssetProperties(AssetInfo asset, Map properties) - { - ParameterCheck.mandatory("asset", asset); - ParameterCheck.mandatory("properties", properties); - - NodeRef avmNodeRef = AVMNodeConverter.ToNodeRef(-1, asset.getAvmPath()); - for (Map.Entry prop : properties.entrySet()) - { - avmNodeService.setProperty(avmNodeRef, prop.getKey(), prop.getValue()); - } - } - - public void setAssetProperties(AssetInfo asset, Map properties) - { - ParameterCheck.mandatory("asset", asset); - ParameterCheck.mandatory("properties", properties); - - setProperties(asset.getAvmPath(), properties); - } - - private void setProperties(String avmPath, Map properties) - { - NodeRef avmNodeRef = AVMNodeConverter.ToNodeRef(-1, avmPath); - avmNodeService.setProperties(avmNodeRef, properties); - } - - public void addAspect(AssetInfo asset, QName aspectName, Map properties) - { - addAspect(asset.getAvmPath(), aspectName, properties); - } - - private void addAspect(String avmPath, QName aspect, Map properties) - { - NodeRef avmNodeRef = AVMNodeConverter.ToNodeRef(-1, avmPath); - avmNodeService.addAspect(avmNodeRef, aspect, properties); - } - - public void removeAspect(AssetInfo asset, QName aspectName) - { - ParameterCheck.mandatory("asset", asset); - - NodeRef avmNodeRef = AVMNodeConverter.ToNodeRef(-1, asset.getAvmPath()); - avmNodeService.removeAspect(avmNodeRef, aspectName); - } - - public Set getAspects(AssetInfo asset) - { - ParameterCheck.mandatory("asset", asset); - - NodeRef avmNodeRef = AVMNodeConverter.ToNodeRef(asset.getSandboxVersion(), asset.getAvmPath()); - return avmNodeService.getAspects(avmNodeRef); - } - - public boolean hasAspect(AssetInfo asset, QName aspectName) - { - ParameterCheck.mandatory("asset", asset); - - NodeRef avmNodeRef = AVMNodeConverter.ToNodeRef(asset.getSandboxVersion(), asset.getAvmPath()); - return avmNodeService.hasAspect(avmNodeRef, aspectName); - } - - public Map getAssetProperties(AssetInfo asset) - { - ParameterCheck.mandatory("asset", asset); - - return getProperties(asset.getSandboxVersion(), asset.getAvmPath()); - } - - private Map getProperties(int version, String avmPath) - { - NodeRef avmNodeRef = AVMNodeConverter.ToNodeRef(version, avmPath); - return avmNodeService.getProperties(avmNodeRef); // note: includes built-in properties - } - - public List listAssetsWebApp(String sbStoreId, String webApp, String parentFolderPathRelativeToWebApp, boolean includeDeleted) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("webApp", webApp); - ParameterCheck.mandatoryString("parentFolderPathRelativeToWebApp", parentFolderPathRelativeToWebApp); - - parentFolderPathRelativeToWebApp = AVMUtil.addLeadingSlash(parentFolderPathRelativeToWebApp); - - String avmPath = WCMUtil.buildStoreWebappPath(sbStoreId, webApp) + parentFolderPathRelativeToWebApp; - - return listAssetsAVM(-1, avmPath, includeDeleted); - } - - public List listAssets(String sbStoreId, String parentFolderPath, boolean includeDeleted) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("parentFolderPath", parentFolderPath); - - String avmPath = AVMUtil.buildAVMPath(sbStoreId, parentFolderPath); - - return listAssetsAVM(-1, avmPath, includeDeleted); - } - - public List listAssets(String sbStoreId, int version, String parentFolderPath, boolean includeDeleted) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("parentFolderPath", parentFolderPath); - - String avmPath = AVMUtil.buildAVMPath(sbStoreId, parentFolderPath); - - return listAssetsAVM(version, avmPath, includeDeleted); - } - - private List listAssetsAVM(int version, String avmPath, boolean includeDeleted) - { - ParameterCheck.mandatoryString("avmPath", avmPath); - - Map nodes = avmService.getDirectoryListing(version, avmPath, includeDeleted); - - List assets = new ArrayList(nodes.size()); - - for (AVMNodeDescriptor node : nodes.values()) - { - String lockOwner = null; - if (avmLockingService != null) - { - String wpStoreId = WCMUtil.getWebProjectStoreIdFromPath(avmPath); - String[] parts = WCMUtil.splitPath(avmPath); - lockOwner = getLockOwner(wpStoreId, parts[1]); - } - - assets.add(new AssetInfoImpl(version, node, lockOwner)); - } - - return assets; - } - - public void deleteAsset(AssetInfo asset) - { - ParameterCheck.mandatory("asset", asset); - - if (! isWebProjectStagingSandbox(asset.getSandboxId())) - { - avmService.removeNode(asset.getAvmPath()); - } - else - { - throw new AccessDeniedException("Not allowed to write in: " + asset.getSandboxId()); - } - } - - public AssetInfo renameAsset(AssetInfo asset, String newName) - { - ParameterCheck.mandatory("asset", asset); - - if (! isWebProjectStagingSandbox(asset.getSandboxId())) - { - String avmParentPath = AVMUtil.splitBase(asset.getAvmPath())[0]; - String oldName = asset.getName(); - - avmService.rename(avmParentPath, oldName, avmParentPath, newName); - - return getAsset(asset.getSandboxId(), WCMUtil.getStoreRelativePath(avmParentPath)+"/"+newName); - } - else - { - throw new AccessDeniedException("Not allowed to write in: " + asset.getSandboxId()); - } - } - - public AssetInfo moveAsset(AssetInfo asset, String parentFolderPath) - { - ParameterCheck.mandatory("asset", asset); - - if (! isWebProjectStagingSandbox(asset.getSandboxId())) - { - String avmDstPath = AVMUtil.buildAVMPath(asset.getSandboxId(), parentFolderPath); - - String avmSrcPath = AVMUtil.splitBase(asset.getAvmPath())[0]; - String name = asset.getName(); - - avmService.rename(avmSrcPath, name, avmDstPath, name); - - return getAsset(asset.getSandboxId(), WCMUtil.getStoreRelativePath(avmDstPath)+"/"+name); - } - else - { - throw new AccessDeniedException("Not allowed to write in: " + asset.getSandboxId()); - } - } - - public AssetInfo copyAsset(AssetInfo asset, String parentFolderPath) - { - ParameterCheck.mandatory("asset", asset); - - if (! isWebProjectStagingSandbox(asset.getSandboxId())) - { - String avmDstParentPath = AVMUtil.buildAVMPath(asset.getSandboxId(), parentFolderPath); - - String avmSrcPath = asset.getAvmPath(); - String name = asset.getName(); - - avmService.copy(-1, avmSrcPath, avmDstParentPath, name); - - return getAsset(asset.getSandboxId(), WCMUtil.getStoreRelativePath(avmDstParentPath+"/"+name)); - } - else - { - throw new AccessDeniedException("Not allowed to write in: " + asset.getSandboxId()); - } - } - - // TODO should this be in sandbox service ? - public void bulkImport(String sbStoreId, String parentFolderPath, File zipFile, boolean isHighByteZip) - { - if (! isWebProjectStagingSandbox(sbStoreId)) - { - String avmDstPath = AVMUtil.buildAVMPath(sbStoreId, parentFolderPath); - - // convert the AVM path to a NodeRef so we can use the NodeService to perform import - NodeRef importRef = AVMNodeConverter.ToNodeRef(-1, avmDstPath); - processZipImport(zipFile, isHighByteZip, importRef); - - // After a bulk import, snapshot the store - avmService.createSnapshot(sbStoreId, "Import of file: " + zipFile.getName(), null); - - // Bind the post-commit transaction listener with data required for virtualization server notification - UpdateSandboxTransactionListener tl = new UpdateSandboxTransactionListener(avmDstPath); - AlfrescoTransactionSupport.bindListener(tl); - } - else - { - throw new AccessDeniedException("Not allowed to write in: " + sbStoreId); - } - - } - - /** - * Process ZIP file for import into an AVM repository store location - * - * @param file ZIP format file - * @param rootRef Root reference of the AVM location to import into - */ - private void processZipImport(File file, boolean isHighByteZip, NodeRef rootRef) - { - try - { - // NOTE: This encoding allows us to workaround bug: - // http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4820807 - // We also try to use the extra encoding information if present - ZipFile zipFile = new ZipFile(file, isHighByteZip ? "Cp437" : null, true); - File alfTempDir = TempFileProvider.getTempDir(); - // build a temp dir name based on the name of the file we are importing - File tempDir = new File(alfTempDir.getPath() + File.separatorChar + file.getName() + "_unpack"); - try - { - ImporterActionExecuter.extractFile(zipFile, tempDir.getPath()); - importDirectory(tempDir.getPath(), rootRef); - } - finally - { - if (tempDir.exists()) - { - ImporterActionExecuter.deleteDir(tempDir); - } - } - } - catch (IOException e) - { - throw new AlfrescoRuntimeException("Unable to process Zip file. File may not be of the expected format.", e); - } - } - - /** - * Recursively import a directory structure into the specified root node - * - * @param dir The directory of files and folders to import - * @param root The root node to import into - */ - private void importDirectory(String dir, NodeRef root) - { - File topdir = new File(dir); - if (!topdir.exists()) return; - for (File file : topdir.listFiles()) - { - try - { - if (file.isFile()) - { - // Create a file in the AVM store - String avmPath = AVMNodeConverter.ToAVMVersionPath(root).getSecond(); - String fileName = file.getName(); - - Map titledProps = new HashMap(); - titledProps.put(ContentModel.PROP_TITLE, fileName); - - createFileAVM(avmPath, fileName, new BufferedInputStream(new FileInputStream(file), BUFFER_SIZE)); - - String filePath = avmPath + '/' + fileName; - - addAspect(filePath, ContentModel.ASPECT_TITLED, titledProps); - } - else - { - // Create a directory in the AVM store - String avmPath = AVMNodeConverter.ToAVMVersionPath(root).getSecond(); - - createFolderAVM(avmPath, file.getName(), null); - - String folderPath = avmPath + '/' + file.getName(); - NodeRef folderRef = AVMNodeConverter.ToNodeRef(-1, folderPath); - importDirectory(file.getPath(), folderRef); - } - } - catch (FileNotFoundException e) - { - // TODO: add failed file info to status message? - throw new AlfrescoRuntimeException("Failed to process ZIP file.", e); - } - catch (FileExistsException e) - { - // TODO: add failed file info to status message? - throw new AlfrescoRuntimeException("Failed to process ZIP file.", e); - } - } - } - - /** - * Update Sandbox Transaction listener - invoked after bulk import - */ - private class UpdateSandboxTransactionListener extends TransactionListenerAdapter - { - private String virtUpdatePath; - - public UpdateSandboxTransactionListener(String virtUpdatePath) - { - this.virtUpdatePath = virtUpdatePath; - } - - /** - * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterCommit() - */ - @Override - public void afterCommit() - { - // Reload virtualisation server as required - if (this.virtUpdatePath != null) - { - WCMUtil.updateVServerWebapp(virtServerRegistry, this.virtUpdatePath, true); - } - } - } -} diff --git a/source/java/org/alfresco/wcm/preview/AbstractPreviewURIServiceProvider.java b/source/java/org/alfresco/wcm/preview/AbstractPreviewURIServiceProvider.java deleted file mode 100644 index fbe2ea5ae3..0000000000 --- a/source/java/org/alfresco/wcm/preview/AbstractPreviewURIServiceProvider.java +++ /dev/null @@ -1,58 +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 . - */ - -package org.alfresco.wcm.preview; - -import java.util.ArrayList; -import java.util.List; - - -/** - * Abstract Preview URI Service Provider - * - * @author janv - * - * @since 3.2 - */ -public abstract class AbstractPreviewURIServiceProvider implements PreviewURIServiceProvider -{ - /* (non-Javadoc) - * @see org.alfresco.wcm.preview.PreviewURIServiceProvider#getPreviewURI(java.lang.String, java.lang.String, org.alfresco.wcm.preview.PreviewContext) - */ - abstract public String getPreviewURI(String sbStoreId, String relativePath, PreviewContext previewContext); - - /* (non-Javadoc) - * @see org.alfresco.wcm.preview.PreviewURIServiceProvider#getPreviewURIs(java.lang.String, java.util.List, org.alfresco.wcm.preview.PreviewContext) - */ - public List getPreviewURIs(String sbStoreId, List relativePaths, PreviewContext previewContext) - { - List previewURIs = null; - - if (relativePaths != null) - { - previewURIs = new ArrayList(relativePaths.size()); - for (String relativePath : relativePaths) - { - previewURIs.add(getPreviewURI(sbStoreId, relativePath, previewContext)); - } - } - - return previewURIs; - } -} \ No newline at end of file diff --git a/source/java/org/alfresco/wcm/preview/NullPreviewURIService.java b/source/java/org/alfresco/wcm/preview/NullPreviewURIService.java deleted file mode 100644 index fb290b9626..0000000000 --- a/source/java/org/alfresco/wcm/preview/NullPreviewURIService.java +++ /dev/null @@ -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 . - */ - -package org.alfresco.wcm.preview; - - -/** - * A PreviewURIService that always returns null (no preview URI). - * - * @author Peter Monks, janv - * - * @since 3.2 - */ -public class NullPreviewURIService extends AbstractPreviewURIServiceProvider -{ - /* (non-Javadoc) - * @see org.alfresco.wcm.preview.PreviewURIServiceProvider#getPreviewURI(java.lang.String, java.lang.String, org.alfresco.wcm.preview.PreviewContext) - */ - @Override - public String getPreviewURI(final String storeId, final String webapp, final PreviewContext previewContext) - { - return(null); - } -} \ No newline at end of file diff --git a/source/java/org/alfresco/wcm/preview/PreviewContext.java b/source/java/org/alfresco/wcm/preview/PreviewContext.java deleted file mode 100644 index e0406d4977..0000000000 --- a/source/java/org/alfresco/wcm/preview/PreviewContext.java +++ /dev/null @@ -1,57 +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 . - */ - -package org.alfresco.wcm.preview; - - -/** - * Additional context Preview URI Service Providers - * - * @author janv - * - * @since 3.2 - */ -public class PreviewContext -{ - private String wpStoreId; - private String webApp; // can be null - private String authenticatedUser; - - /* package */ PreviewContext(String wpStoreId, String webApp, String authenticatedUser) - { - this.wpStoreId = wpStoreId; - this.webApp = webApp; - this.authenticatedUser = authenticatedUser; - } - - public String getWpStoreId() - { - return wpStoreId; - } - - public String getWebApp() - { - return webApp; - } - - public String getAuthenticatedUser() - { - return authenticatedUser; - } -} diff --git a/source/java/org/alfresco/wcm/preview/PreviewURIService.java b/source/java/org/alfresco/wcm/preview/PreviewURIService.java deleted file mode 100644 index c51ebc8b9f..0000000000 --- a/source/java/org/alfresco/wcm/preview/PreviewURIService.java +++ /dev/null @@ -1,70 +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 . - */ - -package org.alfresco.wcm.preview; - -import java.util.List; -import java.util.Set; - -/** - * Client API for retrieving/generating preview URIs - * - * @author janv - * - * @since 3.2 - */ -public interface PreviewURIService -{ - /** - * @param sbStoreId The sandbox store id to generate the preview URI for. - * @param pathToAsset The path to the asset to generate the preview URI for (can be null or empty, to return preview URL to store). - * - * @return The Preview URI for the given sandbox and/or asset (may be null). - */ - public String getPreviewURI(String sbStoreId, String pathToAsset); - - /** - * @param sbStoreId The sandbox store id to generate the preview URI for. - * @param pathsToAssets List of paths to the assets to generate the preview URI for. - * - * @return The Preview URI for the given assets (may be null). - */ - public List getPreviewURIs(String sbStoreId, List pathsToAssets); - - /** - * Return list of registered Preview URI service providers - * - * @return - */ - public Set getProviderNames(); - - /** - * Return default Preview URI service provider - * - * @return - */ - public String getDefaultProviderName(); - - /** - * Return Preview URI service provider configured for web project - * - * @return - */ - public String getProviderName(String wpStoreId); -} diff --git a/source/java/org/alfresco/wcm/preview/PreviewURIServiceImpl.java b/source/java/org/alfresco/wcm/preview/PreviewURIServiceImpl.java deleted file mode 100644 index e47fb5c189..0000000000 --- a/source/java/org/alfresco/wcm/preview/PreviewURIServiceImpl.java +++ /dev/null @@ -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 . - */ -package org.alfresco.wcm.preview; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.repo.avm.util.AVMUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.springframework.extensions.surf.util.ParameterCheck; -import org.alfresco.wcm.util.WCMUtil; -import org.alfresco.wcm.webproject.WebProjectService; - - -/** - * Preview URI Service fundamental API. - *

- * This service API is designed to support the Preview URI API - * - * @author janv - * - * @since 3.2 - */ -public class PreviewURIServiceImpl implements PreviewURIService -{ - private PreviewURIServiceRegistry previewURIProviderRegistry; - private WebProjectService wpService; - - public void setPreviewURIServiceRegistry(PreviewURIServiceRegistry previewURIProviderRegistry) - { - this.previewURIProviderRegistry = previewURIProviderRegistry; - } - - public void setWebProjectService(WebProjectService wpService) - { - this.wpService = wpService; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.preview.PreviewURIService#getPreviewURI(java.lang.String, java.lang.String) - */ - public String getPreviewURI(String sbStoreId, String pathToAsset) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - - String wpStoreId = WCMUtil.getWebProjectStoreId(sbStoreId); - String authenticatedUser = AuthenticationUtil.getFullyAuthenticatedUser(); - - String webApp = null; - if (pathToAsset != null) - { - webApp = WCMUtil.getWebapp(AVMUtil.buildAVMPath(sbStoreId, pathToAsset)); - } - - PreviewContext prevCtx = new PreviewContext(wpStoreId, webApp, authenticatedUser); - - return getProvider(wpStoreId).getPreviewURI(sbStoreId, pathToAsset, prevCtx); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.preview.PreviewURIService#getPreviewURIs(java.lang.String, java.util.List) - */ - public List getPreviewURIs(String sbStoreId, List pathsToAssets) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatory("pathsToAssets", pathsToAssets); - - String wpStoreId = WCMUtil.getWebProjectStoreId(sbStoreId); - String authenticatedUser = AuthenticationUtil.getFullyAuthenticatedUser(); - - String webApp = WCMUtil.getCommonWebApp(sbStoreId, pathsToAssets); - - PreviewContext prevCtx = new PreviewContext(wpStoreId, webApp, authenticatedUser); - - return getProvider(wpStoreId).getPreviewURIs(sbStoreId, pathsToAssets, prevCtx); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.preview.PreviewURIService#getProviderNames() - */ - public Set getProviderNames() - { - Map previewProviders = previewURIProviderRegistry.getPreviewURIServiceProviders(); - return previewProviders.keySet(); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.preview.PreviewURIService#getDefaultProviderName() - */ - public String getDefaultProviderName() - { - // delegate - return previewURIProviderRegistry.getDefaultProviderName(); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.preview.PreviewURIService#getProviderName(java.lang.String) - */ - public String getProviderName(String wpStoreId) - { - // delegate - return wpService.getPreviewProvider(wpStoreId); - } - - private PreviewURIServiceProvider getProvider(String wpStoreId) - { - PreviewURIServiceProvider previewProvider = previewURIProviderRegistry.getPreviewURIServiceProviders().get(getProviderName(wpStoreId)); - if (previewProvider == null) - { - previewProvider = previewURIProviderRegistry.getPreviewURIServiceProviders().get(previewURIProviderRegistry.getDefaultProviderName()); - } - return previewProvider; - } -} diff --git a/source/java/org/alfresco/wcm/preview/PreviewURIServiceProvider.java b/source/java/org/alfresco/wcm/preview/PreviewURIServiceProvider.java deleted file mode 100644 index dff57f4a5c..0000000000 --- a/source/java/org/alfresco/wcm/preview/PreviewURIServiceProvider.java +++ /dev/null @@ -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 . - */ - -package org.alfresco.wcm.preview; - -import java.util.List; - - -/** - * SPI (Service Provider Interface) abstraction for generating preview URLs. - * - * @author janv - * - * @since 3.2 - */ -public interface PreviewURIServiceProvider -{ - /** - * @param sbStoreId The sandbox store id to generate the preview URI for. - * @param pathToAsset The path to the asset to generate the preview URI for (can be null or empty, to return preview URL to store). - * @param previewContext Additional preview context - * - * @return The Preview URI for the given sandbox and/or asset (may be null). - */ - public String getPreviewURI(String sbStoreId, String pathToAsset, PreviewContext previewContext); - - /** - * @param sbStoreId The sandbox store id to generate the preview URI for. - * @param pathsToAssets The paths to the assets to generate the preview URI for. - * @param previewContext Additional preview context - * - * @return The Preview URIs for the given asset paths (may be null). - */ - public List getPreviewURIs(String sbStoreId, List pathsToAssets, PreviewContext previewContext); -} diff --git a/source/java/org/alfresco/wcm/preview/PreviewURIServiceRegistry.java b/source/java/org/alfresco/wcm/preview/PreviewURIServiceRegistry.java deleted file mode 100644 index d5ac0b0bcc..0000000000 --- a/source/java/org/alfresco/wcm/preview/PreviewURIServiceRegistry.java +++ /dev/null @@ -1,47 +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 . - */ - -package org.alfresco.wcm.preview; - -import java.util.Map; - - -/** - * Preview URI Service Provider Registry - * - * @author janv - * - * @since 3.2 - */ -public interface PreviewURIServiceRegistry -{ - /** - * Return list of registered PreviewURI service providers - * - * @return - */ - public Map getPreviewURIServiceProviders(); - - /** - * Return default PreviewURI service provider - * - * @return - */ - public String getDefaultProviderName(); -} diff --git a/source/java/org/alfresco/wcm/preview/PreviewURIServiceRegistryImpl.java b/source/java/org/alfresco/wcm/preview/PreviewURIServiceRegistryImpl.java deleted file mode 100644 index 082759835a..0000000000 --- a/source/java/org/alfresco/wcm/preview/PreviewURIServiceRegistryImpl.java +++ /dev/null @@ -1,73 +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 . - */ -package org.alfresco.wcm.preview; - -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.util.PropertyCheck; -import org.springframework.beans.factory.InitializingBean; - - -/** - * Preview URI Service Provider Registry Implementation - * - * @author janv - * - * @since 3.2 - */ -public class PreviewURIServiceRegistryImpl implements PreviewURIServiceRegistry, InitializingBean -{ - private static final String ERR_INVALID_DEFAULT_PREVIEW_URI_SERVICE = "preview.err.invalid_default_preview_uri_service"; - - private Map previewURIServicesByName; - private String defaultPreviewURIServiceName; - - public void setPreviewURIServiceProvidersByName(Map previewURIServicesByName) - { - this.previewURIServicesByName = previewURIServicesByName; - } - - public Map getPreviewURIServiceProviders() - { - return this.previewURIServicesByName; - } - - public void setDefaultProviderName(String defaultPreviewURIServiceName) - { - this.defaultPreviewURIServiceName = defaultPreviewURIServiceName; - } - - public String getDefaultProviderName() - { - return this.defaultPreviewURIServiceName; - } - - public void afterPropertiesSet() throws Exception - { - PropertyCheck.mandatory(this, "previewURIServicesByName", previewURIServicesByName); - PropertyCheck.mandatory(this, "defaultName", defaultPreviewURIServiceName); - - // Check that the default preview URI service provider name is valid - if ((defaultPreviewURIServiceName.length() == 0) || (previewURIServicesByName.get(defaultPreviewURIServiceName) == null)) - { - AlfrescoRuntimeException.create(ERR_INVALID_DEFAULT_PREVIEW_URI_SERVICE, defaultPreviewURIServiceName, previewURIServicesByName.keySet()); - } - } -} diff --git a/source/java/org/alfresco/wcm/preview/URITemplatePreviewURIService.java b/source/java/org/alfresco/wcm/preview/URITemplatePreviewURIService.java deleted file mode 100644 index abf925b490..0000000000 --- a/source/java/org/alfresco/wcm/preview/URITemplatePreviewURIService.java +++ /dev/null @@ -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 . - */ - -package org.alfresco.wcm.preview; - - -/** - * A PreviewURIService that takes a URI template and replaces the following parameters per request: - *

    - *
  • {storeId} - the store Id of the preview request
  • - *
  • {pathToAsset} - the full path and filename of the asset being previewed (including a leading '/')
  • - *
- * - * @author Peter Monks, janv - * - * @since 3.2 - */ -public class URITemplatePreviewURIService extends AbstractPreviewURIServiceProvider -{ - private final static String URI_TEMPLATE_PARAMETER_STORE_ID = "{storeId}"; - private final static String URI_TEMPLATE_PARAMETER_PATH_TO_ASSET = "{pathToAsset}"; - - protected String uriTemplate; - - public void setUriTemplate(String uriTemplate) - { - this.uriTemplate = uriTemplate; - } - - public URITemplatePreviewURIService() - { - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.preview.PreviewURIServiceProvider#getPreviewURI(java.lang.String, java.lang.String, org.alfresco.wcm.preview.PreviewContext) - */ - public String getPreviewURI(final String storeId, final String pathToAsset, final PreviewContext ignored) - { - String result = uriTemplate; - - if (uriTemplate.contains(URI_TEMPLATE_PARAMETER_STORE_ID)) - { - if (storeId != null && storeId.trim().length() > 0) - { - result = result.replace(URI_TEMPLATE_PARAMETER_STORE_ID, storeId); - } - else - { - // Shouldn't ever happen (store ids are always provided), but better to be safe than sorry - result = result.replace(URI_TEMPLATE_PARAMETER_STORE_ID, ""); - } - } - - if (uriTemplate.contains(URI_TEMPLATE_PARAMETER_PATH_TO_ASSET)) - { - if (pathToAsset != null && pathToAsset.trim().length() > 0) - { - result = result.replace(URI_TEMPLATE_PARAMETER_PATH_TO_ASSET, pathToAsset); - } - else - { - result = result.replace(URI_TEMPLATE_PARAMETER_PATH_TO_ASSET, ""); - } - } - - return(result); - } - -} diff --git a/source/java/org/alfresco/wcm/preview/VirtualisationServerPreviewURIService.java b/source/java/org/alfresco/wcm/preview/VirtualisationServerPreviewURIService.java deleted file mode 100644 index 2215a62e4f..0000000000 --- a/source/java/org/alfresco/wcm/preview/VirtualisationServerPreviewURIService.java +++ /dev/null @@ -1,151 +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 . - */ - -package org.alfresco.wcm.preview; - -import java.text.MessageFormat; - -import org.alfresco.config.JNDIConstants; -import org.alfresco.mbeans.VirtServerRegistry; -import org.alfresco.repo.avm.util.AVMUtil; -import org.alfresco.service.cmr.avm.AVMService; -import org.springframework.extensions.surf.util.ParameterCheck; -import org.alfresco.wcm.util.WCMUtil; - - -/** - * A PreviewURIService that constructs a virtualisation server URI. - * - * @author Peter Monks, janv - * - * @since 3.2 - */ -public class VirtualisationServerPreviewURIService extends AbstractPreviewURIServiceProvider -{ - // TODO - remove deprecated constants from JNDIConstants - - /** - * Default virtualization server IP address - */ - public final static String DEFAULT_VSERVER_IP = "127-0-0-1.ip.alfrescodemo.net"; - - /** - * Default virtualization server port number - */ - public final static int DEFAULT_VSERVER_PORT = 8180; - - /** - * Virtualization server sandbox URL pattern - */ - public final static String PREVIEW_SANDBOX_URL = "http://{0}.www--sandbox.{1}:{2}"; - - /** - * Virtualization server asset URL pattern - */ - public final static String PREVIEW_ASSET_URL = "http://{0}.www--sandbox.{1}:{2}{3}"; - - - private AVMService avmService; - private VirtServerRegistry virtSvrRegistry; - - public void setAvmService(AVMService avmService) - { - this.avmService = avmService; - } - - public void setVirtServerRegistry(VirtServerRegistry virtSvrRegistry) - { - this.virtSvrRegistry = virtSvrRegistry; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.preview.PreviewURIServiceProvider#getPreviewURI(java.lang.String, java.lang.String, org.alfresco.wcm.preview.PreviewContext) - */ - public String getPreviewURI(String sbStoreId, String pathToAsset, PreviewContext ignored) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - - if ((pathToAsset == null) || (pathToAsset.length() == 0)) - { - return buildPreviewStoreUrl(sbStoreId, getVServerDomain(), getVServerPort(), WCMUtil.lookupStoreDNS(avmService, sbStoreId)); - } - - // Sanity checking - if (!pathToAsset.startsWith('/' + JNDIConstants.DIR_DEFAULT_WWW + '/' + JNDIConstants.DIR_DEFAULT_APPBASE)) - { - throw new IllegalStateException("Invalid asset path in AVM node ref: " + sbStoreId + ":" + pathToAsset); - } - - return buildPreviewAssetUrl(pathToAsset, getVServerDomain(), getVServerPort(), WCMUtil.lookupStoreDNS(avmService, sbStoreId)); - } - - private String buildPreviewStoreUrl(String sbStoreId, String domain, String port, String dns) - { - return MessageFormat.format(PREVIEW_SANDBOX_URL, dns, domain, port); - } - - private String buildPreviewAssetUrl(String assetPath, String domain, String port, String dns) - { - ParameterCheck.mandatoryString("assetPath", assetPath); - - if (domain == null || port == null || dns == null) - { - throw new IllegalArgumentException("Domain, port and dns name are mandatory."); - } - - if (assetPath.startsWith(JNDIConstants.DIR_DEFAULT_WWW_APPBASE)) - { - assetPath = assetPath.substring((JNDIConstants.DIR_DEFAULT_WWW_APPBASE).length()); - } - if (assetPath.startsWith(AVMUtil.AVM_PATH_SEPARATOR + WCMUtil.DIR_ROOT)) - { - assetPath = assetPath.substring((AVMUtil.AVM_PATH_SEPARATOR + WCMUtil.DIR_ROOT).length()); - } - - assetPath = AVMUtil.addLeadingSlash(assetPath); - - return MessageFormat.format(PREVIEW_ASSET_URL, dns, domain, port, assetPath); - } - - /** - * @return VServer Port - */ - private String getVServerPort() - { - Integer port = (virtSvrRegistry != null ? virtSvrRegistry.getVirtServerHttpPort() : null); - if (port == null) - { - port = DEFAULT_VSERVER_PORT; - } - return port.toString(); - } - - /** - * @return VServer Domain - */ - private String getVServerDomain() - { - String domain = (virtSvrRegistry != null ? virtSvrRegistry.getVirtServerFQDN() : null); - if (domain == null) - { - domain = DEFAULT_VSERVER_IP; - } - return domain; - } -} diff --git a/source/java/org/alfresco/wcm/sandbox/SandboxConstants.java b/source/java/org/alfresco/wcm/sandbox/SandboxConstants.java deleted file mode 100644 index 21e17b9883..0000000000 --- a/source/java/org/alfresco/wcm/sandbox/SandboxConstants.java +++ /dev/null @@ -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 . - */ - -/*----------------------------------------------------------------------------- -* Author Jon Cox -* File SandboxConstants.java -*----------------------------------------------------------------------------*/ - -package org.alfresco.wcm.sandbox; - -import org.alfresco.service.namespace.QName; - -/** -* WCM sandbox constants -*/ -public class SandboxConstants -{ - // system property keys for sandbox identification and DNS virtualisation mapping - public final static String PROP_BACKGROUND_LAYER = ".background-layer."; - public final static String PROP_SANDBOXID = ".sandbox-id."; - public final static String PROP_DNS = ".dns."; - public final static String PROP_SANDBOX_STORE_PREFIX = ".sandbox.store."; - - // sandbox type - 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"); - - public final static QName PROP_WEBSITE_NAME = QName.createQName(null, ".website.name"); - public final static QName PROP_AUTHOR_NAME = QName.createQName(null, ".author.name"); - public final static QName PROP_WEB_PROJECT_NODE_REF = QName.createQName(null, ".web_project.noderef"); - public final static QName PROP_WEB_PROJECT_PREVIEW_PROVIDER = QName.createQName(null, ".web_project.previewprovider"); - - public final static QName PROP_LAST_DEPLOYMENT_ID = QName.createQName(null, ".deployment.id"); -} diff --git a/source/java/org/alfresco/wcm/sandbox/SandboxFactory.java b/source/java/org/alfresco/wcm/sandbox/SandboxFactory.java deleted file mode 100644 index 1b98854c13..0000000000 --- a/source/java/org/alfresco/wcm/sandbox/SandboxFactory.java +++ /dev/null @@ -1,1364 +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 . - */ -package org.alfresco.wcm.sandbox; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.config.JNDIConstants; -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.mbeans.VirtServerRegistry; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.repo.avm.actions.AVMDeployWebsiteAction; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.avm.AVMStoreDescriptor; -import org.alfresco.service.cmr.avm.locking.AVMLockingService; -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.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.util.DNSNameMangler; -import org.alfresco.util.GUID; -import org.alfresco.wcm.util.WCMUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Helper factory to create WCM sandbox structures - * - * @author Kevin Roast - * @author janv - */ -public final class SandboxFactory extends WCMUtil -{ - private static final Set ZONES; - - public static final String[] PERMISSIONS = new String[] { - PermissionService.WCM_CONTENT_MANAGER, - PermissionService.WCM_CONTENT_PUBLISHER, - PermissionService.WCM_CONTENT_CONTRIBUTOR, - PermissionService.WCM_CONTENT_REVIEWER }; - - private static Log logger = LogFactory.getLog(SandboxFactory.class); - - /** Services */ - private NodeService nodeService; - private PermissionService permissionService; - private AVMService avmService; - private VirtServerRegistry virtServerRegistry; - private AuthorityService authorityService; - private AVMLockingService avmLockingService; - - static - { - HashSet zones = new HashSet(2, 1.0f); - zones.add(AuthorityService.ZONE_APP_WCM); - zones.add(AuthorityService.ZONE_AUTH_ALFRESCO); - ZONES = Collections.unmodifiableSet(zones); - } - - private final static QName PROP_SANDBOX_LOCALHOST_DEPLOYED = QName.createQName(null, ".sandbox.localhost."+AVMDeployWebsiteAction.LIVE_SUFFIX); - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - public void setAvmService(AVMService avmService) - { - this.avmService = avmService; - } - - public void setVirtServerRegistry(VirtServerRegistry virtServerRegistry) - { - this.virtServerRegistry = virtServerRegistry; - } - - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - public void setAvmLockingService(AVMLockingService avmLockingService) - { - this.avmLockingService = avmLockingService; - } - - /** - * Private constructor - */ - private SandboxFactory() - { - } - - /** - * Create the staging sandbox for the named store. - * - * A staging sandbox is comprised of two stores, the first named 'storename-staging' with a - * preview store named 'storename-preview' layered over the staging store. - * - * Various store meta-data properties are set including: - * Identifier for store-types: .sandbox.staging.main and .sandbox.staging.preview - * Store-id: .sandbox-id. (unique across all stores in the sandbox) - * DNS: .dns. = - * Website Name: .website.name = website name - * - * @param storeId The store name to create the sandbox for. - * @param webProjectNodeRef The noderef for the webproject. - * @param branchStoreId The ID of the store to branch this staging store from. - */ - public SandboxInfo createStagingSandbox(String storeId, - NodeRef webProjectNodeRef, - String branchStoreId) - { - long start = System.currentTimeMillis(); - - // create the 'staging' store for the website - String stagingStoreName = WCMUtil.buildStagingStoreName(storeId); - - // tag store with properties - Map props = new HashMap(3); - // tag the store with the store type - props.put(SandboxConstants.PROP_SANDBOX_STAGING_MAIN, new PropertyValue(DataTypeDefinition.TEXT, null)); - props.put(SandboxConstants.PROP_WEB_PROJECT_NODE_REF, new PropertyValue(DataTypeDefinition.NODE_REF, webProjectNodeRef)); - // tag the store with the DNS name property - addStoreDNSPath(stagingStoreName, props, storeId); - - avmService.createStore(stagingStoreName, props); - - if (logger.isTraceEnabled()) - { - logger.trace("Created staging sandbox: " + stagingStoreName); - } - - // we can either branch from an existing staging store or create a new structure - if (branchStoreId != null) - { - String branchStorePath = WCMUtil.buildStagingStoreName(branchStoreId) + ":/" + - JNDIConstants.DIR_DEFAULT_WWW; - avmService.createBranch(-1, branchStorePath, - stagingStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW); - } - else - { - // create the system directories 'www' and 'avm_webapps' - avmService.createDirectory(stagingStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW); - avmService.createDirectory(WCMUtil.buildStoreRootPath(stagingStoreName), - JNDIConstants.DIR_DEFAULT_APPBASE); - } - - - // set staging area permissions - setStagingPermissions(storeId, webProjectNodeRef); - - // Add permissions for layers - - // snapshot the store - avmService.createSnapshot(stagingStoreName, null, null); - - - // create the 'preview' store for the website - String previewStoreName = WCMUtil.buildStagingPreviewStoreName(storeId); - - // tag store with properties - store type, web project DM nodeRef, DNS name - props = new HashMap(3); - // tag the store with the store type - props.put(SandboxConstants.PROP_SANDBOX_STAGING_PREVIEW, new PropertyValue(DataTypeDefinition.TEXT, null)); - // tag the store with the DNS name property - addStoreDNSPath(previewStoreName, props, storeId, "preview"); - // The preview store depends on the main staging store (dist=1) - addStoreBackgroundLayer(props, stagingStoreName, 1); - - avmService.createStore(previewStoreName, props); - - if (logger.isTraceEnabled()) - { - logger.trace("Created staging preview sandbox store: " + previewStoreName + - " above " + stagingStoreName); - } - - // create a layered directory pointing to 'www' in the staging area - avmService.createLayeredDirectory(WCMUtil.buildStoreRootPath(stagingStoreName), - previewStoreName + ":/", - JNDIConstants.DIR_DEFAULT_WWW); - - - // apply READ permissions for all users - //dirRef = AVMNodeConverter.ToNodeRef(-1, WCMUtil.buildStoreRootPath(previewStoreName)); - //permissionService.setPermission(dirRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ, true); - - // snapshot the store - avmService.createSnapshot(previewStoreName, null, null); - - - // tag all related stores to indicate that they are part of a single sandbox - final String sandboxGuid = GUID.generate(); - - props = new HashMap(2); - addSandboxGuid(sandboxGuid, props); - - avmService.setStoreProperties(stagingStoreName, props); - avmService.setStoreProperties(previewStoreName, props); - - if (logger.isTraceEnabled()) - { - dumpStoreProperties(avmService, stagingStoreName); - dumpStoreProperties(avmService, previewStoreName); - } - - SandboxInfo sbInfo = getSandbox(stagingStoreName); - - if (logger.isTraceEnabled()) - { - logger.trace("createStagingSandbox: " + sbInfo.getSandboxId() + " in "+(System.currentTimeMillis()-start)+" ms"); - } - - return sbInfo; - } - - /** - * Get sandbox info for given sandbox store id - * - * @param sandboxId - * @return SandboxInfo returns sandbox info or null if sandbox does not exist or is not visible - */ - /* package */ SandboxInfo getSandbox(String sandboxId) - { - String wpStoreId = WCMUtil.getWebProjectStoreId(sandboxId); - - return getSandbox(wpStoreId, sandboxId, true); - } - - private SandboxInfo getSandbox(String wpStoreId, String sandboxId, boolean withPreview) - { - AVMStoreDescriptor storeDesc = avmService.getStore(sandboxId); - if (storeDesc == null) - { - return null; - } - - String[] storeNames = null; - - // Check sandbox type - Map props = avmService.getStoreProperties(sandboxId); - QName sandboxType = null; - - // derive name for now - String name = null; - - String previewSandboxId = null; - if (withPreview && (! WCMUtil.isPreviewStore(sandboxId))) - { - previewSandboxId = WCMUtil.getCorrespondingPreviewStoreName(sandboxId); - } - - if (props.containsKey(SandboxConstants.PROP_SANDBOX_STAGING_MAIN)) - { - sandboxType = SandboxConstants.PROP_SANDBOX_STAGING_MAIN; - name = sandboxId; - storeNames = new String[] {sandboxId, previewSandboxId}; - } - else if ( props.containsKey( SandboxConstants.PROP_SANDBOX_STAGING_PREVIEW)) - { - sandboxType = SandboxConstants.PROP_SANDBOX_STAGING_PREVIEW; - storeNames = new String[] {WCMUtil.getCorrespondingMainStoreName(sandboxId), sandboxId}; - } - else if (props.containsKey(SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN)) - { - sandboxType = SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN; - name = WCMUtil.getUserName(sandboxId); - storeNames = new String[] {sandboxId, previewSandboxId}; - } - else if (props.containsKey(SandboxConstants.PROP_SANDBOX_AUTHOR_PREVIEW)) - { - sandboxType = SandboxConstants.PROP_SANDBOX_AUTHOR_PREVIEW; - name = WCMUtil.getUserName(sandboxId); - storeNames = new String[] {WCMUtil.getCorrespondingMainStoreName(sandboxId), sandboxId}; - } - else if (props.containsKey(SandboxConstants.PROP_SANDBOX_WORKFLOW_MAIN)) - { - sandboxType = SandboxConstants.PROP_SANDBOX_WORKFLOW_MAIN; - name = WCMUtil.getWorkflowId(sandboxId); - storeNames = new String[] {sandboxId, previewSandboxId}; - } - else if (props.containsKey(SandboxConstants.PROP_SANDBOX_WORKFLOW_PREVIEW)) - { - sandboxType = SandboxConstants.PROP_SANDBOX_WORKFLOW_PREVIEW; - name = WCMUtil.getWorkflowId(sandboxId); - storeNames = new String[] {WCMUtil.getCorrespondingMainStoreName(sandboxId), sandboxId}; - } - else if (props.containsKey(SandboxConstants.PROP_SANDBOX_AUTHOR_WORKFLOW_MAIN)) - { - sandboxType = SandboxConstants.PROP_SANDBOX_AUTHOR_WORKFLOW_MAIN; - name = WCMUtil.getWorkflowId(sandboxId); - storeNames = new String[] {sandboxId, previewSandboxId}; - } - else if (props.containsKey(SandboxConstants.PROP_SANDBOX_AUTHOR_WORKFLOW_PREVIEW)) - { - sandboxType = SandboxConstants.PROP_SANDBOX_AUTHOR_WORKFLOW_PREVIEW; - name = WCMUtil.getWorkflowId(sandboxId); - } - else if (WCMUtil.isLocalhostDeployedStore(wpStoreId, sandboxId)) - { - // TODO refactor - pending explicit WCM services support for deployment config - sandboxType = PROP_SANDBOX_LOCALHOST_DEPLOYED; - name = sandboxId; - storeNames = new String[] {sandboxId}; - } - - if ((storeNames == null) || (storeNames.length == 0)) - { - throw new AlfrescoRuntimeException("Must have at least one store"); - } - - if ((storeNames.length == 1) && - ((! sandboxType.equals(SandboxConstants.PROP_SANDBOX_STAGING_MAIN)) && (! sandboxType.equals(PROP_SANDBOX_LOCALHOST_DEPLOYED)))) - { - throw new AlfrescoRuntimeException("Main store must be of type: " + SandboxConstants.PROP_SANDBOX_STAGING_MAIN); - } - - return new SandboxInfoImpl(wpStoreId, sandboxId, sandboxType, name, storeNames, new Date(storeDesc.getCreateDate()), storeDesc.getCreator()); - } - - private void setStagingPermissions(String storeId, NodeRef wpNodeRef) - { - String storeName = WCMUtil.buildStagingStoreName(storeId); - NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, WCMUtil.buildStoreRootPath(storeName)); - - makeGroupsIfRequired(storeName, dirRef); - // Apply specific user permissions as set on the web project - // All these will be masked out - - Map userRoles = WCMUtil.listWebUsers(nodeService, wpNodeRef); - - for (Map.Entry userRole : userRoles.entrySet()) - { - String username = userRole.getKey(); - String userrole = userRole.getValue(); - - // permissionService.setPermission(dirRef, username, userrole, true); - addToGroupIfRequired(storeName, username, userrole); - } - - // Add group permissions - for (String permission : PERMISSIONS) - { - String cms = authorityService.getName(AuthorityType.GROUP, storeName + "-" + permission); - permissionService.setPermission(dirRef, cms, permission, true); - } - - // TODO: does everyone get read writes? - permissionService.setPermission(dirRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ, true); - } - - private void makeGroupsIfRequired(final String stagingStoreName, final NodeRef dirRef) - { - AuthenticationUtil.runAs(new RunAsWork(){ - - public Object doWork() throws Exception - { - for (String permission : PERMISSIONS) - { - String shortName = stagingStoreName + "-" + permission; - String group = authorityService.getName(AuthorityType.GROUP, shortName); - if (!authorityService.authorityExists(group)) - { - authorityService.createAuthority(AuthorityType.GROUP, shortName, shortName, ZONES); - } - if (!isPermissionSet(dirRef, group, permission)) - { - permissionService.setPermission(dirRef, group, permission, true); - } - } - return null; - }}, AuthenticationUtil.getSystemUserName()); - } - - private boolean isPermissionSet(NodeRef nodeRef, String authority, String permission) - { - Set set = permissionService.getAllSetPermissions(nodeRef); - for (AccessPermission ap : set) - { - if (ap.getAuthority().equals(authority) && ap.isSetDirectly() && ap.getPermission().equals(permission)) - { - return true; - } - } - return false; - } - - private void addToGroupIfRequired(final String stagingStoreName, final String user, final String permission) - { - AuthenticationUtil.runAs(new RunAsWork(){ - - public Object doWork() throws Exception - { - String shortName = stagingStoreName + "-" + permission; - String group = authorityService.getName(AuthorityType.GROUP, shortName); - if (!authorityService.authorityExists(group)) - { - authorityService.createAuthority(AuthorityType.GROUP, shortName, shortName, ZONES); - } - Set members = authorityService.getContainedAuthorities(AuthorityType.USER, group, true); - if (!members.contains(user)) - { - authorityService.addAuthority(group, user); - } - return null; - }}, AuthenticationUtil.getSystemUserName()); - - } - - private void removeFromGroupIfRequired(final String stagingStoreName, final String user, final String permission) - { - AuthenticationUtil.runAs(new RunAsWork(){ - - public Object doWork() throws Exception - { - String shortName = stagingStoreName + "-" + permission; - String group = authorityService.getName(AuthorityType.GROUP, shortName); - if (authorityService.authorityExists(group)) - { - Set members = authorityService.getContainedAuthorities(AuthorityType.USER, group, true); - if (members.contains(user)) - { - authorityService.removeAuthority(group, user); - } - } - return null; - }}, AuthenticationUtil.getSystemUserName()); - } - - private boolean isMaskSet(StoreRef storeRef, String authority, String permission) - { - Set set = permissionService.getAllSetPermissions(storeRef); - for (AccessPermission ap : set) - { - if (ap.getAuthority().equals(authority) && ap.isSetDirectly() && ap.getPermission().equals(permission)) - { - return true; - } - } - return false; - } - - public void setStagingPermissionMasks(String storeId) - { - String storeName = WCMUtil.buildStagingStoreName(storeId); - NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, WCMUtil.buildStoreRootPath(storeName)); - - // Set store permission masks - String currentUser = AuthenticationUtil.getFullyAuthenticatedUser(); - addToGroupIfRequired(storeName, currentUser, PermissionService.WCM_CONTENT_MANAGER); - - String cms = authorityService.getName(AuthorityType.GROUP, storeName + "-" + PermissionService.WCM_CONTENT_MANAGER); - - // read early or the mask prevents access... - boolean setReadPermissions = !isMaskSet(dirRef.getStoreRef(), cms, PermissionService.READ_PERMISSIONS); - - if (!isMaskSet(dirRef.getStoreRef(), cms, PermissionService.CHANGE_PERMISSIONS)) - { - permissionService.setPermission(dirRef.getStoreRef(), cms, PermissionService.CHANGE_PERMISSIONS, true); - } - - if (setReadPermissions) - { - permissionService.setPermission(dirRef.getStoreRef(), cms, PermissionService.READ_PERMISSIONS, true); - } - - if (!isMaskSet(dirRef.getStoreRef(), PermissionService.ALL_AUTHORITIES, PermissionService.READ)) - { - permissionService.setPermission(dirRef.getStoreRef(), PermissionService.ALL_AUTHORITIES, PermissionService.READ, true); - } - } - - /* - private Set getGroupMembers(String stagingStoreName, String permission) - { - String shortName = stagingStoreName + "-" + permission; - String group = authorityService.getName(AuthorityType.GROUP, shortName); - Set members = authorityService.getContainedAuthorities(AuthorityType.USER, group, true); - return members; - - } - */ - - private void updateStagingAreaManagers(String storeId, final List managers) - { - // The stores have the mask set in updateSandboxManagers - String storeName = WCMUtil.buildStagingStoreName(storeId); - - // Set existingMembers = getGroupMembers(storeName, PermissionService.WCM_CONTENT_MANAGER); - - String shortName = storeName + "-" + PermissionService.WCM_CONTENT_MANAGER; - String group = authorityService.getName(AuthorityType.GROUP, shortName); - Set members = authorityService.getContainedAuthorities(AuthorityType.USER, group, true); - Set toRemove = new HashSet(members); - - for (String manager : managers) - { - addToGroupIfRequired(storeName, manager, PermissionService.WCM_CONTENT_MANAGER); - toRemove.remove(manager); - } - - for (String remove : toRemove) - { - removeFromGroupIfRequired(storeName, remove, PermissionService.WCM_CONTENT_MANAGER); - } - } - - public void addStagingAreaUser(String storeId, String authority, String role) - { - // The stores have the mask set in updateSandboxManagers - - //String storeName = WCMUtil.buildStagingStoreName(storeId); - //NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, WCMUtil.buildStoreRootPath(storeName)); - - addToGroupIfRequired(storeId, authority, role); - // permissionService.setPermission(dirRef, authority, role, true); - } - - /** - * Create a user sandbox for the named store. - * - * A user sandbox is comprised of two stores, the first - * named 'storename--username' layered over the staging store with a preview store - * named 'storename--username--preview' layered over the main store. - * - * Various store meta-data properties are set including: - * Identifier for store-types: .sandbox.author.main and .sandbox.author.preview - * Store-id: .sandbox-id. (unique across all stores in the sandbox) - * DNS: .dns. = - * Website Name: .website.name = website name - * - * @param storeId The store id to create the sandbox for - * @param username Username of the user to create the sandbox for - * @param role Role permission for the user - * @return Summary information regarding the sandbox - */ - public SandboxInfo createUserSandbox(String storeId, - String username, - String role) - { - long start = System.currentTimeMillis(); - - // create the user 'main' store - String userStoreName = WCMUtil.buildUserMainStoreName(storeId, username); - String previewStoreName = WCMUtil.buildUserPreviewStoreName(storeId, username); - - SandboxInfo userSandboxInfo = getSandbox(userStoreName); - if (userSandboxInfo != null) - { - if (logger.isTraceEnabled()) - { - logger.trace("Not creating author sandbox as it already exists: " + userStoreName); - } - return userSandboxInfo; - } - - final String sandboxGuid = GUID.generate(); - - String stagingStoreName = WCMUtil.buildStagingStoreName(storeId); - - // tag store with properties - Map props = new HashMap(6); - // tag the store with the store type - props.put(SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN, new PropertyValue(DataTypeDefinition.TEXT, null)); - // tag the store with the base name of the website so that corresponding staging areas can be found. - props.put(SandboxConstants.PROP_WEBSITE_NAME, new PropertyValue(DataTypeDefinition.TEXT, storeId)); - - // tag the store, oddly enough, with its own store name for querying. - addSandboxPrefix(userStoreName, props); - // tag all related stores to indicate that they are part of a single sandbox - addSandboxGuid(sandboxGuid, props); - // tag the store with the DNS name property - addStoreDNSPath(userStoreName, props, storeId, WCMUtil.escapeStoreNameComponent(username)); - // The user store depends on the main staging store (dist=1) - addStoreBackgroundLayer(props, stagingStoreName, 1); - - avmService.createStore(userStoreName, props); - - if (logger.isTraceEnabled()) - { - logger.trace("Created user sandbox: " + userStoreName + " above staging store " + stagingStoreName); - } - - // create a layered directory pointing to 'www' in the staging area - avmService.createLayeredDirectory(WCMUtil.buildStoreRootPath(stagingStoreName), - userStoreName + ":/", - JNDIConstants.DIR_DEFAULT_WWW); - NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, WCMUtil.buildStoreRootPath(userStoreName)); - - // Apply access mask to the store (ACls are applie to the staging area) - - // apply the user role permissions to the sandbox - String currentUser = AuthenticationUtil.getFullyAuthenticatedUser(); - // permissionService.setPermission(dirRef.getStoreRef(), currentUser, AVMUtil.ROLE_CONTENT_MANAGER, true); - addToGroupIfRequired(stagingStoreName, currentUser, PermissionService.WCM_CONTENT_MANAGER); - String cms = authorityService.getName(AuthorityType.GROUP, stagingStoreName + "-" + PermissionService.WCM_CONTENT_MANAGER); - permissionService.setPermission(dirRef.getStoreRef(), cms, PermissionService.WCM_CONTENT_MANAGER, true); - - permissionService.setPermission(dirRef.getStoreRef(), username, PermissionService.ALL_PERMISSIONS, true); - permissionService.setPermission(dirRef.getStoreRef(), PermissionService.ALL_AUTHORITIES, PermissionService.READ, true); - - // snapshot the store - avmService.createSnapshot(userStoreName, null, null); - - // tag store with properties - props = new HashMap(6); - // tag the store with the store type - props.put(SandboxConstants.PROP_SANDBOX_AUTHOR_PREVIEW, new PropertyValue(DataTypeDefinition.TEXT, null)); - // tag the store with its own store name for querying. - props.put(QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + previewStoreName), new PropertyValue(DataTypeDefinition.TEXT, null)); - - // tag all related stores to indicate that they are part of a single sandbox - addSandboxGuid(sandboxGuid, props); - // tag the store with the DNS name property - addStoreDNSPath(previewStoreName, props, storeId, username, "preview"); - // The preview user store depends on the main user store (dist=1) - addStoreBackgroundLayer(props, userStoreName, 1); - // The preview user store depends on the main staging store (dist=2) - addStoreBackgroundLayer(props, stagingStoreName, 2); - - // create the user 'preview' store - avmService.createStore(previewStoreName, props); - - if (logger.isTraceEnabled()) - { - logger.trace("Created user preview sandbox store: " + previewStoreName + - " above " + userStoreName); - } - - // create a layered directory pointing to 'www' in the user 'main' store - avmService.createLayeredDirectory(WCMUtil.buildStoreRootPath(userStoreName), - previewStoreName + ":/", - JNDIConstants.DIR_DEFAULT_WWW); - dirRef = AVMNodeConverter.ToNodeRef(-1, WCMUtil.buildStoreRootPath(previewStoreName)); - - // Apply access mask to the store (ACls are applied to the staging area) - - // apply the user role permissions to the sandbox - permissionService.setPermission(dirRef.getStoreRef(), cms, PermissionService.WCM_CONTENT_MANAGER, true); - permissionService.setPermission(dirRef.getStoreRef(), username, PermissionService.ALL_PERMISSIONS, true); - permissionService.setPermission(dirRef.getStoreRef(), PermissionService.ALL_AUTHORITIES, PermissionService.READ, true); - - // snapshot the store - avmService.createSnapshot(previewStoreName, null, null); - - if (logger.isTraceEnabled()) - { - dumpStoreProperties(avmService, userStoreName); - dumpStoreProperties(avmService, previewStoreName); - } - - SandboxInfo sbInfo = getSandbox(userStoreName); - - if (logger.isTraceEnabled()) - { - logger.trace("createUserSandbox: " + sbInfo.getSandboxId() + " in "+(System.currentTimeMillis()-start)+" ms"); - } - - return sbInfo; - } - - /** - * Create a workflow sandbox for the named store. - * - * Various store meta-data properties are set including: - * Identifier for store-types: .sandbox.workflow.main and .sandbox.workflow.preview - * Store-id: .sandbox-id. (unique across all stores in the sandbox) - * DNS: .dns. = - * Website Name: .website.name = website name - * - * @param storeId The id of the store to create a sandbox for - * @return Information about the sandbox - */ - public SandboxInfo createWorkflowSandbox(final String storeId) - { - long start = System.currentTimeMillis(); - - String stagingStoreName = WCMUtil.buildStagingStoreName(storeId); - - // create the workflow 'main' store - String packageName = WCMUtil.STORE_WORKFLOW + "-" + GUID.generate(); - String mainStoreName = WCMUtil.buildWorkflowMainStoreName(storeId, packageName); - - final String sandboxGuid = GUID.generate(); - - // tag store with properties - Map props = new HashMap(6); - // tag the store with the store type - props.put(SandboxConstants.PROP_SANDBOX_WORKFLOW_MAIN, new PropertyValue(DataTypeDefinition.TEXT, null)); - // tag the store with the base name of the website so that corresponding staging areas can be found. - props.put(SandboxConstants.PROP_WEBSITE_NAME, new PropertyValue(DataTypeDefinition.TEXT, storeId)); - - // tag the store, oddly enough, with its own store name for querying. - addSandboxPrefix(mainStoreName, props); - // tag all related stores to indicate that they are part of a single sandbox - addSandboxGuid(sandboxGuid, props); - // tag the store with the DNS name property - addStoreDNSPath(mainStoreName, props, storeId, packageName); - // The main workflow store depends on the main staging store (dist=1) - addStoreBackgroundLayer(props, stagingStoreName, 1); - - avmService.createStore(mainStoreName, props); - - if (logger.isTraceEnabled()) - { - logger.trace("Created workflow sandbox store: " + mainStoreName); - } - - // create a layered directory pointing to 'www' in the staging area - avmService.createLayeredDirectory(WCMUtil.buildStoreRootPath(stagingStoreName), - mainStoreName + ":/", - JNDIConstants.DIR_DEFAULT_WWW); - - // snapshot the store - avmService.createSnapshot(mainStoreName, null, null); - - // create the workflow 'preview' store - final String previewStoreName = WCMUtil.buildWorkflowPreviewStoreName(storeId, packageName); - - // tag store with properties - props = new HashMap(6); - // tag the store with the store type - props.put(SandboxConstants.PROP_SANDBOX_WORKFLOW_PREVIEW, new PropertyValue(DataTypeDefinition.TEXT, null)); - // tag the store with its own store name for querying. - props.put(QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + previewStoreName), new PropertyValue(DataTypeDefinition.TEXT, null)); - - // tag all related stores to indicate that they are part of a single sandbox - addSandboxGuid(sandboxGuid, props); - - // tag the store with the DNS name property - addStoreDNSPath(previewStoreName, props, storeId, packageName, "preview"); - // The preview workflow store depends on the main workflow store (dist=1) - addStoreBackgroundLayer(props, mainStoreName, 1); - // The preview workflow store depends on the main staging store (dist=2) - addStoreBackgroundLayer(props, stagingStoreName, 2); - - avmService.createStore(previewStoreName, props); - - if (logger.isTraceEnabled()) - { - logger.trace("Created workflow sandbox preview store: " + previewStoreName); - } - - // create a layered directory pointing to 'www' in the workflow 'main' store - avmService.createLayeredDirectory(WCMUtil.buildStoreRootPath(mainStoreName), - previewStoreName + ":/", - JNDIConstants.DIR_DEFAULT_WWW); - - // snapshot the store - avmService.createSnapshot(previewStoreName, null, null); - - if (logger.isTraceEnabled()) - { - dumpStoreProperties(avmService, mainStoreName); - dumpStoreProperties(avmService, previewStoreName); - } - - SandboxInfo sbInfo = getSandbox(mainStoreName); - - if (logger.isTraceEnabled()) - { - logger.trace("createWorkflowSandbox: " + sbInfo.getSandboxId() + " in "+(System.currentTimeMillis()-start)+" ms"); - } - - return sbInfo; - } - - /** - * Create a read-only workflow sandbox for the named store. - * - * Note: read-only means it's only safe to use in a workflow where the sandbox - * is not expected to be updated. The sandbox does not protected itself - * from writes. - * - * Note: this sandbox does not support the preview layer - * Note: a snapshot within this sandbox is NOT taken - * - * Various store meta-data properties are set including: - * Identifier for store-types: .sandbox.workflow.main and .sandbox.workflow.preview - * Store-id: .sandbox-id. (unique across all stores in the sandbox) - * DNS: .dns. = - * Website Name: .website.name = website name - * - * @param storeId The id of the store to create a sandbox for - * @return Information about the sandbox - */ - public SandboxInfo createReadOnlyWorkflowSandbox(final String storeId) - { - long start = System.currentTimeMillis(); - - String wpStoreId = WCMUtil.getWebProjectStoreId(storeId); - String stagingStoreName = WCMUtil.buildStagingStoreName(storeId); - - // create the workflow 'main' store - String packageName = WCMUtil.STORE_WORKFLOW + "-" + GUID.generate(); - String mainStoreName = WCMUtil.buildWorkflowMainStoreName(storeId, packageName); - - final String sandboxGuid = GUID.generate(); - - // tag store with properties - Map props = new HashMap(6); - // tag the store with the store type - props.put(SandboxConstants.PROP_SANDBOX_WORKFLOW_MAIN, new PropertyValue(DataTypeDefinition.TEXT, null)); - // tag the store with the base name of the website so that corresponding staging areas can be found. - props.put(SandboxConstants.PROP_WEBSITE_NAME, new PropertyValue(DataTypeDefinition.TEXT, storeId)); - - // tag the store, oddly enough, with its own store name for querying. - addSandboxPrefix(mainStoreName, props); - // tag all related stores to indicate that they are part of a single sandbox - addSandboxGuid(sandboxGuid, props); - // tag the store with the DNS name property - addStoreDNSPath(mainStoreName, props, storeId, packageName); - // The main workflow store depends on the main staging store (dist=1) - addStoreBackgroundLayer(props, stagingStoreName, 1); - - avmService.createStore(mainStoreName, props); - - if (logger.isTraceEnabled()) - { - logger.trace("Created read-only workflow sandbox store: " + mainStoreName); - } - - // create a layered directory pointing to 'www' in the staging area - avmService.createLayeredDirectory(WCMUtil.buildStoreRootPath(stagingStoreName), - mainStoreName + ":/", - JNDIConstants.DIR_DEFAULT_WWW); - - if (logger.isTraceEnabled()) - { - dumpStoreProperties(avmService, mainStoreName); - } - - SandboxInfo sbInfo = getSandbox(wpStoreId, mainStoreName, false); // no preview store - - if (logger.isTraceEnabled()) - { - logger.trace("createReadOnlyWorkflowSandbox: " + sbInfo.getSandboxId() + " in "+(System.currentTimeMillis()-start)+" ms"); - } - - return sbInfo; - } - - - /** - * Creates a workflow sandbox for the given user store. This will create a - * workflow sandbox layered over the user's main store. - * - * @param stagingStore The name of the staging store the user sandbox is layered over - * @param userStore The name of the user store to create the workflow for - * @return The store name of the main store in the workflow sandbox - */ - // TODO refactor AVMExpiredContentProcessor ... - public String createUserWorkflowSandbox(String stagingStore, String userStore) - { - long start = System.currentTimeMillis(); - - // create the workflow 'main' store - String packageName = "workflow-" + GUID.generate(); - String workflowStoreName = userStore + STORE_SEPARATOR + packageName; - - final String sandboxGuid = GUID.generate(); - - // tag store with properties - Map props = new HashMap(7); - // tag the store with the store type - props.put(SandboxConstants.PROP_SANDBOX_AUTHOR_WORKFLOW_MAIN, new PropertyValue(DataTypeDefinition.TEXT, null)); - // tag the store with the name of the author's store this one is layered over - props.put(SandboxConstants.PROP_AUTHOR_NAME, new PropertyValue(DataTypeDefinition.TEXT, userStore)); - - // tag the store, oddly enough, with its own store name for querying. - addSandboxPrefix(workflowStoreName, props); - // tag all related stores to indicate that they are part of a single sandbox - addSandboxGuid(sandboxGuid, props); - // tag the store with the DNS name property - addStoreDNSPath(workflowStoreName, props, stagingStore, packageName); - // the main workflow store depends on the main user store (dist=1) - addStoreBackgroundLayer(props, userStore, 1); - // The main workflow store depends on the main staging store (dist=2) - addStoreBackgroundLayer(props, stagingStore, 2); - - avmService.createStore(workflowStoreName, props); - - if (logger.isTraceEnabled()) - { - logger.trace("Created user workflow sandbox store: " + workflowStoreName); - } - - // create a layered directory pointing to 'www' in the users store - avmService.createLayeredDirectory( - userStore + ":/" + JNDIConstants.DIR_DEFAULT_WWW, - workflowStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW); - - // snapshot the store - avmService.createSnapshot(workflowStoreName, null, null); - - // create the workflow 'preview' store - String previewStoreName = workflowStoreName + STORE_SEPARATOR + "preview"; - - // tag store with properties - props = new HashMap(7); - // tag the store with the store type - props.put(SandboxConstants.PROP_SANDBOX_AUTHOR_WORKFLOW_PREVIEW, new PropertyValue(DataTypeDefinition.TEXT, null)); - // tag the store with its own store name for querying. - props.put(QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + previewStoreName), new PropertyValue(DataTypeDefinition.TEXT, null)); - - // tag all related stores to indicate that they are part of a single sandbox - addSandboxGuid(sandboxGuid, props); - // tag the store with the DNS name property - addStoreDNSPath(previewStoreName, props, userStore, packageName, "preview"); - // The preview worfkflow store depends on the main workflow store (dist=1) - addStoreBackgroundLayer(props, workflowStoreName, 1); - // The preview workflow store depends on the main user store (dist=2) - addStoreBackgroundLayer(props, userStore, 2); - // The preview workflow store depends on the main staging store (dist=3) - addStoreBackgroundLayer(props, stagingStore, 3); - - avmService.createStore(previewStoreName, props); - - if (logger.isTraceEnabled()) - { - logger.trace("Created user workflow sandbox preview store: " + previewStoreName); - } - - // create a layered directory pointing to 'www' in the workflow 'main' store - avmService.createLayeredDirectory( - workflowStoreName + ":/" + JNDIConstants.DIR_DEFAULT_WWW, - previewStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW); - - // snapshot the store - avmService.createSnapshot(previewStoreName, null, null); - - if (logger.isTraceEnabled()) - { - logger.trace("createUserWorkflowSandbox: " + workflowStoreName + " in "+(System.currentTimeMillis()-start)+" ms"); - } - - // return the main workflow store name - return workflowStoreName; - } - - public List listAllSandboxes(String wpStoreId) - { - return listAllSandboxes(wpStoreId, false, false); - } - - public List listAllSandboxes(String wpStoreId, boolean includeWorkflowSandboxes, boolean includeLocalhostDeployed) - { - long start = System.currentTimeMillis(); - - List stores = avmService.getStores(); - - List sbInfos = new ArrayList(); - for (AVMStoreDescriptor store : stores) - { - String storeName = store.getName(); - - // list main stores - not preview stores or workflow stores or locally deployed "live" ASR servers (LIVE or TEST) - if ((WCMUtil.getWebProjectStoreId(storeName).equals(wpStoreId)) && - (! WCMUtil.isPreviewStore(storeName)) && - ((includeLocalhostDeployed || (! WCMUtil.isLocalhostDeployedStore(wpStoreId, storeName)))) && - ((includeWorkflowSandboxes || (! WCMUtil.isWorkflowStore(storeName)))) - ) - { - sbInfos.add(getSandbox(wpStoreId, storeName, true)); - } - } - - if (logger.isTraceEnabled()) - { - logger.trace("listAllSandboxes: " + wpStoreId + "[" + sbInfos.size() + "] in "+(System.currentTimeMillis()-start)+" ms"); - } - - return sbInfos; - } - public void deleteSandbox(String sbStoreId) - { - deleteSandbox(sbStoreId, false); - } - - public void deleteSandbox(String sbStoreId, boolean isSubmitDirectWorkflowSandbox) - { - deleteSandbox(getSandbox(WCMUtil.getWebProjectStoreId(sbStoreId), sbStoreId, true), isSubmitDirectWorkflowSandbox, true); - } - - public void deleteSandbox(SandboxInfo sbInfo, boolean isSubmitDirectWorkflowSandbox, boolean removeLocks) - { - if (sbInfo != null) - { - long start = System.currentTimeMillis(); - - String mainSandboxStore = sbInfo.getMainStoreName(); - String wpStoreId = WCMUtil.getWebProjectStoreId(mainSandboxStore); - - // found the sandbox to remove - remove the main store (eg. user main store, staging main store, workflow main store) - String path = WCMUtil.buildSandboxRootPath(mainSandboxStore); - - // Notify virtualisation server about removing this sandbox. - // - // Implementation note: - // - // Because the removal of virtual webapps in the - // virtualization server is recursive, it only - // needs to be given the name of the main store. - // - // This notification must occur *prior* to purging content - // within the AVM because the virtualization server must list - // the avm_webapps dir in each store to discover which - // virtual webapps must be unloaded. The virtualization - // server traverses the sandbox's stores in most-to-least - // dependent order, so clients don't have to worry about - // accessing a preview layer whose main layer has been torn - // out from under it. - - // optimization: direct submits no longer virtualize the workflow sandbox - if (! isSubmitDirectWorkflowSandbox) - { - WCMUtil.removeAllVServerWebapps(virtServerRegistry, path, true); - } - - // NOTE: Could use the .sandbox-id. GUID property to delete all sandboxes, - // rather than assume a sandbox always had a single preview - // layer attached. - - // purge stores, eg. main store followed by preview store - String[] avmStoreNames = sbInfo.getStoreNames(); - - for (String avmStoreName : avmStoreNames) - { - // check it exists before we try to remove it - if (avmService.getStore(avmStoreName) != null) - { - // purge store from the system - avmService.purgeStore(avmStoreName); - } - - if (removeLocks) - { - Map lockDataToMatch = Collections.singletonMap(WCMUtil.LOCK_KEY_STORE_NAME, avmStoreName); - avmLockingService.removeLocks(wpStoreId, lockDataToMatch); - } - } - - if (logger.isTraceEnabled()) - { - logger.trace("deleteSandbox: " + mainSandboxStore + " in "+(System.currentTimeMillis()-start)+" ms"); - } - } - } - - /** - * Update the permissions for the list of sandbox managers applied to a user sandbox. - *

- * Ensures that all managers in the list have full WRITE access to the specified user stores. - * - * @param storeId - * The store id of the sandbox to update - * @param managers - * The list of authorities who have ContentManager role in the web project - */ - public void updateSandboxManagers(final String storeId, final List managers) - { - String stagingStoreName = WCMUtil.buildStagingStoreName(storeId); - - updateStagingAreaManagers(stagingStoreName, managers); - } - - /** - * Update the permissions for the list of sandbox managers applied to a user sandbox. - *

- * Ensures that all managers in the list have full WRITE access to the specified user stores. - * - * @param storeId - * The store id of the sandbox to update - * @param managers - * The list of authorities who have ContentManager role in the web project - */ - public void removeSandboxManagers(String storeId, List managersToRemove) - { - removeStagingAreaManagers(storeId, managersToRemove); - } - - /** - * Removes the ContentManager role on staging area to ex-managers. - * - * @param storeId The store id of the sandbox to update - * @param managersToRemove The list of authorities who have had ContentManager role in the web project - */ - private void removeStagingAreaManagers(String storeId, List managersToRemove) - { - String storeName = WCMUtil.buildStagingStoreName(storeId); - - for (String remove : managersToRemove) - { - removeFromGroupIfRequired(storeName, remove, PermissionService.WCM_CONTENT_MANAGER); - } - } - - public void updateSandboxRoles(final String wpStoreId, List usersToUpdate, Set permissionsList) - { - // walk existing user sandboxes and remove manager permissions to exclude old managers - List sbInfos = listAllSandboxes(wpStoreId); // all sandboxes - - for (SandboxInfo sbInfo : sbInfos) - { - if (sbInfo.getSandboxType().equals(SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN)) - { - String username = sbInfo.getName(); - updateUserSandboxRole(wpStoreId, username ,usersToUpdate, permissionsList); - } - } - - updateStagingAreaRole(wpStoreId, usersToUpdate, permissionsList); - } - - /** - * Updates roles on the sandbox identified by username to users from usersToUpdate list. - * - * @param storeId The store id of the sandbox to update - * @param username Username of the user sandbox to update - * @param usersToUpdate The list of users who have role changes - * @param permissionsList List of permissions @see org.alfresco.web.bean.wcm.InviteWebsiteUsersWizard.getPermissionsForType(). It is not mandatory. - */ - private void updateUserSandboxRole(String storeId, String username, List usersToUpdate, Set permissionsList) - { - final String storeName = WCMUtil.buildStagingStoreName(storeId); - - // If permissionsList is set remove all possible user permissions and set only necessary. - // This will fix previous wrong role changes. (paranoid) - // For little better performance just set permissionsList to null. - // But in this case it removes only previous permission. - if (permissionsList != null && permissionsList.size() != 0) - { - for (UserRoleWrapper user : usersToUpdate) - { - for (String permission : permissionsList) - { - removeFromGroupIfRequired(storeName, user.getUserAuth(), permission); - } - - addToGroupIfRequired(storeName, user.getUserAuth(), user.getNewRole()); - } - } - else - { - for (UserRoleWrapper user : usersToUpdate) - { - removeFromGroupIfRequired(storeName, user.getUserAuth(), user.getOldRole()); - addToGroupIfRequired(storeName, user.getUserAuth(), user.getNewRole()); - } - } - } - - /** - * Updates roles on staging sandbox to users from usersToUpdate list. - * - * @param storeId The store id of the sandbox to update - * @param usersToUpdate The list of users who have role changes - * @param permissionsList List of permissions @see org.alfresco.web.bean.wcm.InviteWebsiteUsersWizard.getPermissionsForType(). It is not mandatory. - */ - private void updateStagingAreaRole(String storeId, List usersToUpdate, Set permissionsList) - { - final String storeName = WCMUtil.buildStagingStoreName(storeId); - - // If permissionsList is set remove all possible user permissions and set only necessary. - // This will fix previous wrong role changes. (paranoid) - // For little better performance just set permissionsList to null. - // But in this case it removes only previous permission. - if (permissionsList != null && permissionsList.size() != 0) - { - for (UserRoleWrapper user : usersToUpdate) - { - for (String permission : permissionsList) - { - removeFromGroupIfRequired(storeName, user.getUserAuth(), permission); - } - - addToGroupIfRequired(storeName, user.getUserAuth(), user.getNewRole()); - } - } - else - { - for (UserRoleWrapper user : usersToUpdate) - { - removeFromGroupIfRequired(storeName, user.getUserAuth(), user.getOldRole()); - addToGroupIfRequired(storeName, user.getUserAuth(), user.getNewRole()); - } - } - } - - /** - * Tag a named store with a DNS path meta-data attribute. - * The DNS meta-data attribute is set to the system path 'store:/www/avm_webapps' - * - * @param store Name of the store to tag - */ - private static void addStoreDNSPath(String store, Map props, String... components) - { - String path = WCMUtil.buildSandboxRootPath(store); - // DNS name mangle the property name - can only contain value DNS characters! - String dnsName = DNSNameMangler.MakeDNSName(components); - String dnsProp = SandboxConstants.PROP_DNS + dnsName; - props.put(QName.createQName(null, dnsProp), new PropertyValue(DataTypeDefinition.TEXT, path)); - } - - /** - * Tags a store with a property that indicates one of its - * backgroundStore layers, and the distance of that layer. - * This function must be called separately for each background - * store; for example the "mysite--alice--preview" store had - * as its immediate background "mysite--alice", which itself had - * as its background store "mysite", you'd make a sequence of - * calls like this: - * - *

-    *    tagStoreBackgroundLayer("mysite--alice",          "mysite",        1);
-    *    tagStoreBackgroundLayer("mysite--alice--preview", "mysite--alice", 1);
-    *    tagStoreBackgroundLayer("mysite--alice--preview", "mysite",        2);
-    *   
- * - * This make it easy for other parts of the system to determine - * which stores depend on others directly or indirectly (which is - * useful for reloading virtualized webapps). - * - * @param store Name of the store to tag - * @param backgroundStore Name of store's background store - * @param distance Distance from store. - * The backgroundStore 'mysite' is 1 away from the store 'mysite--alice' - * but 2 away from the store 'mysite--alice--preview'. - */ - private static void addStoreBackgroundLayer(Map props, - String backgroundStore, - int distance) - { - String prop_key = SandboxConstants.PROP_BACKGROUND_LAYER + backgroundStore; - props.put(QName.createQName(null, prop_key), new PropertyValue(DataTypeDefinition.INT, distance)); - } - - private static void addSandboxGuid(String sandboxGuid, Map props) - { - final QName sandboxIdProp = QName.createQName(SandboxConstants.PROP_SANDBOXID + sandboxGuid); - props.put(sandboxIdProp, new PropertyValue(DataTypeDefinition.TEXT, null)); - } - - private static void addSandboxPrefix(String storeName, Map props) - { - props.put(QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + storeName), new PropertyValue(DataTypeDefinition.TEXT, null)); - } - - - /** - * Debug helper method to dump the properties of a store - * - * @param store Store name to dump properties for - */ - private static void dumpStoreProperties(AVMService avmService, String store) - { - logger.trace("Store " + store); - Map props = avmService.getStoreProperties(store); - for (QName name : props.keySet()) - { - logger.trace(" " + name + ": " + props.get(name)); - } - } - - public class UserRoleWrapper - { - private String newRole; - private String oldRole; - private String userAuth; - - public UserRoleWrapper(String userAuth, String oldRole, String newRole) - { - this.userAuth = userAuth; - this.oldRole = oldRole; - this.newRole = newRole; - } - - public String getNewRole() - { - return newRole; - } - public void setNewRole(String newRole) - { - this.newRole = newRole; - } - public String getOldRole() - { - return oldRole; - } - public void setOldRole(String oldRole) - { - this.oldRole = oldRole; - } - public String getUserAuth() - { - return userAuth; - } - public void setUserAuth(String userAuth) - { - this.userAuth = userAuth; - } - } - - public void removeGroupsForStore(final String storeRoot) - { - AuthenticationUtil.runAs(new RunAsWork() - { - - public Void doWork() throws Exception - { - String[] permissions = new String[] { PermissionService.WCM_CONTENT_CONTRIBUTOR, PermissionService.WCM_CONTENT_MANAGER, PermissionService.WCM_CONTENT_PUBLISHER, - PermissionService.WCM_CONTENT_REVIEWER }; - for (String permission : permissions) - { - String shortName = storeRoot + "-" + permission; - String group = authorityService.getName(AuthorityType.GROUP, shortName); - if (authorityService.authorityExists(group)) - { - authorityService.deleteAuthority(group); - } - } - return null; - } - }, AuthenticationUtil.getSystemUserName()); - - } -} diff --git a/source/java/org/alfresco/wcm/sandbox/SandboxInfo.java b/source/java/org/alfresco/wcm/sandbox/SandboxInfo.java deleted file mode 100644 index 60bc68ef3c..0000000000 --- a/source/java/org/alfresco/wcm/sandbox/SandboxInfo.java +++ /dev/null @@ -1,76 +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 . - */ -package org.alfresco.wcm.sandbox; - -import java.util.Date; - -import org.alfresco.service.namespace.QName; - -/** -* Provides information about a WCM sandbox created by SandboxFactory. -*/ -public interface SandboxInfo -{ - /** - * Get the name - * - * @return String name - */ - public String getName(); - - /** - * The sandbox store id - */ - public String getSandboxId(); - - /** - * The web project store id - */ - public String getWebProjectId(); - - /** - * The sandbox type ... for now a QName, based on existing SandboxConstants - */ - public QName getSandboxType(); - - public Date getCreatedDate(); - - public String getCreator(); - - /** - * The sandbox root relative path - eg. for WCM web project with webapps, typically /www/avm_webapps - */ - public String getSandboxRootPath(); - - /** - * A list of ids of the stores within this sandbox. - * The "main" store should come first in this list; - * any other stores should appear in the order that - * they are overlaid on "main" (e.g.: any "preview" - * layers should come afterward, in "lowest first" order). - *

- * Note: all sandboxes must have a "main" layer. - */ - public String[] getStoreNames(); - - /** - * The id of the "main" store within this sandbox. - */ - public String getMainStoreName(); -} diff --git a/source/java/org/alfresco/wcm/sandbox/SandboxInfoImpl.java b/source/java/org/alfresco/wcm/sandbox/SandboxInfoImpl.java deleted file mode 100644 index 54a59f842a..0000000000 --- a/source/java/org/alfresco/wcm/sandbox/SandboxInfoImpl.java +++ /dev/null @@ -1,104 +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 . - */ -package org.alfresco.wcm.sandbox; - -import java.util.Date; - -import org.alfresco.config.JNDIConstants; -import org.alfresco.service.namespace.QName; - -/** - * Provides information about a WCM sandbox created by Sandbox Service/Factory - */ -public class SandboxInfoImpl implements SandboxInfo -{ - private String wpStoreId; - private String sbStoreId; - private QName sandboxType; - private String name; - private String[] storeNames; - private Date createdDate; - private String creator; - - /* package */ SandboxInfoImpl(String wpStoreId, String sbStoreId, QName sandboxType, String name, String[] storeNames, Date createdDate, String creator) - { - this.wpStoreId = wpStoreId; - this.sbStoreId = sbStoreId; - this.sandboxType = sandboxType; - this.name = name; - this.storeNames = storeNames; - this.createdDate = createdDate; - this.creator = creator; - } - - // note: currently derived - for author sandbox this is the username, for staging sandbox this is the sandbox id - public String getName() - { - return this.name; - } - - public String getWebProjectId() - { - return this.wpStoreId; - } - - public String getSandboxId() - { - return this.sbStoreId; - } - - public QName getSandboxType() - { - return this.sandboxType; - } - - public Date getCreatedDate() - { - return this.createdDate; - } - - public String getCreator() - { - return this.creator; - } - - public String getSandboxRootPath() - { - return JNDIConstants.DIR_DEFAULT_WWW_APPBASE; - } - - /** - * A list of names of the stores within this sandbox. - * The "main" store should come first in this list; - * any other stores should appear in the order that - * they are overlaid on "main" (e.g.: any "preview" - * layers should come afterward, in "lowest first" order). - *

- * Note: all sandboxes must have a "main" layer. - */ - public String [] getStoreNames() { return storeNames; } - - /** - * The name of the "main" store within this sandbox. - */ - public String getMainStoreName() - { - return storeNames[0]; - } -} diff --git a/source/java/org/alfresco/wcm/sandbox/SandboxService.java b/source/java/org/alfresco/wcm/sandbox/SandboxService.java deleted file mode 100644 index b5701e098d..0000000000 --- a/source/java/org/alfresco/wcm/sandbox/SandboxService.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright (C) 2005-2011 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 . - */ -package org.alfresco.wcm.sandbox; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.alfresco.service.PublicService; -import org.alfresco.service.namespace.QName; -import org.alfresco.wcm.asset.AssetInfo; -import org.alfresco.service.Auditable; -import org.alfresco.service.NotAuditable; - - -/** - * Sandbox Service fundamental API. - *

- * This service API is designed to support the public facing Sandbox APIs. - * - * @author janv - */ -public interface SandboxService -{ - /** - * Create author/user sandbox within a web project for the current user - *

- * If the author sandbox already exists for this web project then it will be returned - * - * @param wpStoreId web project store id - * @return SandboxInfo the created user sandbox info - */ - @Auditable(parameters={"wpStoreId"}) - public SandboxInfo createAuthorSandbox(String wpStoreId); - - /** - * Create author/user sandbox within a web project for the given user - *

- * If the author sandbox already exists for this web project then it will be returned - *

- * Current user must be a content manager for the web project - * - * @param wpStoreId web project store id - * @param userName user name - * @return SandboxInfo the created user sandbox info - */ - @Auditable(parameters={"wpStoreId", "userName"}) - public SandboxInfo createAuthorSandbox(String wpStoreId, String userName); - - /** - * List the available sandboxes for the current user and given web project - * - * @param wpStoreId web project store id - * @return List list of sandbox info - */ - @NotAuditable - public List listSandboxes(String wpStoreId); - - /** - * List the available sandboxes for the given user and web project - *

- * Current user must be a content manager for the web project - * - * @param wpStoreId web project store id - * @param userName user name - * @return List list of sandbox info - */ - @NotAuditable - public List listSandboxes(String wpStoreId, String userName); - - /** - * Return true if sandbox is visible to user and is of given type - *

- * eg. isSandboxType("test123--myusername", SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN) - * - * @param sbStoreId sandbox store id - * @param sandboxType sandbox type (see SandboxConstants) - * @return boolean true, if sandbox exists with given type - */ - @NotAuditable - public boolean isSandboxType(String sbStoreId, QName sandboxType); - - /** - * Get sandbox info - * - * @param sbStoreId sandbox store id - * @return SandboxInfo null if sandbox does not exist or is not visible to the current user - */ - @NotAuditable - public SandboxInfo getSandbox(String sbStoreId); - - /** - * Gets author/user sandbox info for the current user - *

- * Returns null if the author sandbox can not be found - * - * @param wpStoreId web project store id - * @return SandboxInfo author sandbox info - */ - @NotAuditable - public SandboxInfo getAuthorSandbox(String wpStoreId); - - /** - * Gets author/user sandbox info for the given user - *

- * Returns null if the user sandbox can not be found - *

- * Current user must be a content manager for the web project - * - * @param wpStoreId web project store id - * @param userName userName - * @return SandboxInfo author sandbox info - */ - @NotAuditable - public SandboxInfo getAuthorSandbox(String wpStoreId, String userName); - - /** - * Gets staging sandbox info - *

- * Returns null if the staging sandbox can not be found - * - * @param wpStoreId web project store id - * @return SandboxInfo staging sandbox info - */ - @NotAuditable - public SandboxInfo getStagingSandbox(String wpStoreId); - - /** - * Delete the sandbox - *

- * If the sandbox does not exist, will log a warning and succeed - *

- * Current user must be a content manager for the web project (associated with the sandbox) - * - * @param sbStoreId sandbox store id - */ - @Auditable(parameters={"sbStoreId"}) - public void deleteSandbox(String sbStoreId); - - /** - * List all changed assets for given sandbox (eg. for user sandbox compared to staging sandbox) - *

- * Note: This will list all new/modified/deleted assets from the sandbox root directory (eg. /www/avm_webapps) - ie. across all web apps - * - * @param sbStoreId sandbox store id - * @param includeDeleted if true, include deleted assets as well as new/modified assets - * @return List list of all changed assets - */ - @NotAuditable - public List listChangedAll(String sbStoreId, boolean includeDeleted); - - /** - * List changed assets for given sandbox and web app (eg. in user sandbox) - *

- * Note: This will list new/modified/deleted assets for the given web app - * - * @param sbStoreId sandbox store id - * @param webApp web app to filter by - * @param includeDeleted if true, include deleted assets as well as new/modified assets - * @return List list of changed assets - */ - @NotAuditable - public List listChangedWebApp(String sbStoreId, String webApp, boolean includeDeleted); - - /** - * List changed assets for given sandbox path (eg. between user sandbox and staging sandbox) - *

- * Note: This will list new/modified/deleted assets from the directory and below. The destination path will be dervied. - * - * @param sbStoreId sandbox store id - * @param relativePath relative path to filter by (eg. /www/avm_webapps/ROOT/MyFolderToList) - * @param includeDeleted if true, include deleted assets as well as new/modified assets - * @return List list of changed assets - */ - @NotAuditable - public List listChanged(String sbStoreId, String relativePath, boolean includeDeleted); - - /** - * List changed (new/modified/deleted) assets between any two sandbox paths - * - * @param srcSandboxStoreId source sandbox store id - * @param srcRelativePath source relative path to filter by (eg. /www/avm_webapps/ROOT/MyFolderToList) - * @param dstSandboxStoreId destination sandbox store id - * @param dstRelativePath destination relative path to filter by (eg. /www/avm_webapps/ROOT/MyFolderToList) - * @param includeDeleted if true, include deleted assets as well as new/modified assets - * @return List list of changed assets - */ - @NotAuditable - public List listChanged(String srcSandboxStoreId, String srcRelativePath, String dstSandboxStoreId, String dstRelativePath, boolean includeDeleted); - - /** - * Submit all changed assets for given sandbox (eg. from user sandbox to staging sandbox) - *

- * Note: This will submit all new/modified/deleted assets from the sandbox root directory (eg. /www/avm_webapps) - ie. across all web apps - *

- * @param sbStoreId sandbox store id - * @param submitLabel label for submitted snapshot - * @param submitDescription description for submitted snapshot - */ - @Auditable(parameters={"sbStoreId", "submitLabel", "submitDescription"}) - public void submitAll(String sbStoreId, String submitLabel, String submitDescription); - - /** - * Submit changed assets for given sandbox and web app (eg. in user sandbox) - *

- * Note: This will submit new/modified/deleted assets for the given web app - * - * @param sbStoreId sandbox store id - * @param webApp web app to filter by - * @param submitLabel label for submitted snapshot - * @param submitDescription description for submitted snapshot - */ - @Auditable(parameters={"sbStoreId", "webApp", "submitLabel", "submitDescription"}) - public void submitWebApp(String sbStoreId, String webApp, String submitLabel, String submitDescription); - - /** - * Submit changed asset(s) for given sandbox path (eg. in user sandbox) - *

- * Note: This will submit new/modified/deleted asset(s) for given path (either file or directory and below) - * - * @param sbStoreId sandbox store id - * @param relativePath relative path to filter by (eg. /www/avm_webapps or /www/avm_webapps/ROOT/MyFolderToSubmit) - * @param submitLabel label for submitted snapshot - * @param submitDescription description for submitted snapshot - */ - @Auditable(parameters={"sbStoreId", "relativePath", "submitLabel", "submitDescription"}) - public void submit(String sbStoreId, String relativePath, String submitLabel, String submitDescription); - - /** - * Submit list of changed assets for given sandbox (eg. in user sandbox) - * - * @param sbStoreId sandbox store id - * @param assetPaths list of assets, as relative paths (eg. /www/avm_webapps/ROOT/MyFolderToSubmit) - * @param submitLabel label for submitted snapshot - * @param submitDescription description for submitted snapshot - */ - @Auditable(parameters={"sbStoreId", "relativePath", "submitLabel", "submitDescription"}) - public void submitList(String sbStoreId, List relativePaths, String submitLabel, String submitDescription); - - /** - * Submit list of changed assets for given sandbox (eg. from user sandbox to staging sandbox) - * - * @param sbStoreId sandbox store id - * @param assetNodes list of assets - * @param submitLabel label for submitted snapshot - * @param submitDescription description for submitted snapshot - */ - @Auditable(parameters={"sbStoreId", "assets", "submitLabel", "submitDescription"}) - public void submitListAssets(String sbStoreId, List assets, String submitLabel, String submitDescription); - - /** - * Submit list of changed assets for given sandbox (eg. from user sandbox to staging sandbox) - * - * NOTE: for backwards compatibility - subject to change - hence deprecated for now - * - * @param sbStoreId sandbox store id - * @param assetPaths list of assets, as relative paths (eg. /www/avm_webapps/ROOT/MyFolderToSubmit) - * @param workflowName selected workflow name - if null, will use default submit direct workflow - * @param workflowParams configured workflow params - * @param submitLabel label for submitted snapshot - * @param submitDescription description for submitted snapshot - * @param expirationDates optional map of for those assets set with an expiration date, or can be null (if no expiration dates) - * @param launchDate optional launch date - * @param autoDeploy if true then will auto-deploy on workflow approval - * - * @deprecated subject to change - */ - @NotAuditable - public void submitListAssets(String sbStoreId, List relativePaths, - String workflowName, Map workflowParams, - String submitLabel, String submitDescription, - Map expirationDates, Date launchDate, boolean autoDeploy); - - /** - * Revert all changed assets for given sandbox (eg. in user sandbox) - *

- * Note: This will revert all new/modified/deleted assets from the sandbox store root directory (eg. /www/avm_webapps) - ie. across all web apps - * - * @param sbStoreId sandbox store id - */ - @Auditable(parameters={"sbStoreId"}) - public void revertAll(String sbStoreId); - - /** - * Revert changed assets for given sandbox and web app (eg. in user sandbox) - *

- * Note: This will revert new/modified/deleted assets for the given web app - * - * @param sbStoreId sandbox store id - * @param webApp web app to filter by - */ - @Auditable(parameters={"sbStoreId", "webApp"}) - public void revertWebApp(String sbStoreId, String webApp); - - /** - * Revert changed asset(s) for given sandbox path (eg. in user sandbox) - *

- * Note: This will revert new/modified/deleted asset(s) for given path (either file or directory and below) - * - * @param sbStoreId sandbox store id - * @param relativePath relative path to filter by (eg. /www/avm_webapps/ROOT/MyFolderToRevert) - */ - @NotAuditable - public void revert(String sbStoreId, String relativePath); - - /** - * Revert list of changed assets for given sandbox (eg. in user sandbox) - * - * @param sbStoreId sandbox store id - * @param assetPaths list of assets, as relative paths (eg. /www/avm_webapps/ROOT/MyFolderToRevert) - */ - @NotAuditable - public void revertList(String sbStoreId, List relativePaths); - - /** - * Revert list of changed assets for given sandbox (eg. in user sandbox) - * - * @param assets list of assets - */ - @NotAuditable - public void revertListAssets(String sbStoreId, List assets); - - /** - * Revert sandbox to a specific snapshot version ID (ie. for staging sandbox) - *

- * Current user must be a content manager for the web project - * - * @param sbStoreId staging sandbox store id - * @param version version - */ - @NotAuditable - public void revertSnapshot(String sbStoreId, int version); - - /** - * List all snapshots (sandbox versions) for the given sandbox (ie. for staging sandbox) - *

- * Current user must be a content manager for the web project - * - * @param sbStoreId staging sandbox store id - * @param includeSystemGenerated if false will ignore system generated snapshots else true to get all snapshots - * @return List list of sandbox versions - */ - @NotAuditable - public List listSnapshots(String sbStoreId, boolean includeSystemGenerated); - - /** - * List snapshots (sandbox versions) for the given sandbox between given dates (ie. for staging sandbox) - *

- * Current user must be a content manager for the web project - * - * @param sbStoreId staging sandbox store id - * @param from from date - * @param to to date - * @param includeSystemGenerated if false will ignore system generated snapshots else true to get all snapshots - * @return List list of sandbox versions - */ - @NotAuditable - public List listSnapshots(String sbStoreId, Date from, Date to, boolean includeSystemGenerated); -} diff --git a/source/java/org/alfresco/wcm/sandbox/SandboxServiceImpl.java b/source/java/org/alfresco/wcm/sandbox/SandboxServiceImpl.java deleted file mode 100644 index 1c5f74fc2b..0000000000 --- a/source/java/org/alfresco/wcm/sandbox/SandboxServiceImpl.java +++ /dev/null @@ -1,1259 +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 . - */ -package org.alfresco.wcm.sandbox; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.mbeans.VirtServerRegistry; -import org.alfresco.model.WCMAppModel; -import org.alfresco.model.WCMWorkflowModel; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.repo.avm.util.AVMUtil; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.repo.transaction.AlfrescoTransactionSupport; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.TransactionListenerAdapter; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.repo.workflow.WorkflowModel; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.avm.VersionDescriptor; -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.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.workflow.WorkflowDefinition; -import org.alfresco.service.cmr.workflow.WorkflowPath; -import org.alfresco.service.cmr.workflow.WorkflowService; -import org.alfresco.service.cmr.workflow.WorkflowTask; -import org.alfresco.service.cmr.workflow.WorkflowTaskState; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.NameMatcher; -import org.alfresco.util.Pair; -import org.springframework.extensions.surf.util.ParameterCheck; -import org.alfresco.util.VirtServerUtils; -import org.alfresco.wcm.asset.AssetInfo; -import org.alfresco.wcm.asset.AssetInfoImpl; -import org.alfresco.wcm.asset.AssetService; -import org.alfresco.wcm.util.WCMUtil; -import org.alfresco.wcm.util.WCMWorkflowUtil; -import org.alfresco.wcm.webproject.WebProjectInfo; -import org.alfresco.wcm.webproject.WebProjectService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - - -/** - * Sandbox Service fundamental API. - *

- * This service API is designed to support the public facing Sandbox APIs. - * - * @author janv - */ -public class SandboxServiceImpl implements SandboxService -{ - /** Logger */ - private static Log logger = LogFactory.getLog(SandboxServiceImpl.class); - - private static final String WORKFLOW_SUBMITDIRECT = "jbpm$"+WCMUtil.WORKFLOW_SUBMITDIRECT_NAME; - - private WebProjectService wpService; - private SandboxFactory sandboxFactory; - private AVMService avmService; - private AVMSyncService avmSyncService; - private NameMatcher nameMatcher; - private VirtServerRegistry virtServerRegistry; - private WorkflowService workflowService; - private AssetService assetService; - private TransactionService transactionService; - private AVMLockingService avmLockingService; - - - public void setWebProjectService(WebProjectService wpService) - { - this.wpService = wpService; - } - - public void setSandboxFactory(SandboxFactory sandboxFactory) - { - this.sandboxFactory = sandboxFactory; - } - - public void setAvmService(AVMService avmService) - { - this.avmService = avmService; - } - - public void setAvmLockingService(AVMLockingService avmLockingService) - { - this.avmLockingService = avmLockingService; - } - - public void setAvmSyncService(AVMSyncService avmSyncService) - { - this.avmSyncService = avmSyncService; - } - - public void setNameMatcher(NameMatcher nameMatcher) - { - this.nameMatcher = nameMatcher; - } - - public void setVirtServerRegistry(VirtServerRegistry virtServerRegistry) - { - this.virtServerRegistry = virtServerRegistry; - } - - public void setWorkflowService(WorkflowService workflowService) - { - this.workflowService = workflowService; - } - - public void setAssetService(AssetService assetService) - { - this.assetService = assetService; - } - - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#createAuthorSandbox(java.lang.String) - */ - public SandboxInfo createAuthorSandbox(String wpStoreId) - { - ParameterCheck.mandatoryString("wpStoreId", wpStoreId); - - String currentUserName = AuthenticationUtil.getFullyAuthenticatedUser(); - SandboxInfo sbInfo = null; - - if (! wpService.isWebUser(wpStoreId, currentUserName)) - { - throw new AccessDeniedException("Only web project users may create their own (author) sandbox for '"+currentUserName+"' (store id: "+wpStoreId+")"); - } - else - { - sbInfo = createAuthorSandboxImpl(wpStoreId, currentUserName); - } - - return sbInfo; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#createAuthorSandbox(java.lang.String, java.lang.String) - */ - public SandboxInfo createAuthorSandbox(String wpStoreId, String userName) - { - ParameterCheck.mandatoryString("wpStoreId", wpStoreId); - ParameterCheck.mandatoryString("userName", userName); - - // is the current user a content manager for this web project ? - if (! wpService.isContentManager(wpStoreId)) - { - throw new AccessDeniedException("Only content managers may create author sandbox for '"+userName+"' (store id: "+wpStoreId+")"); - } - - return createAuthorSandboxImpl(wpStoreId, userName); - } - - private SandboxInfo createAuthorSandboxImpl(String wpStoreId, String userName) - { - long start = System.currentTimeMillis(); - - WebProjectInfo wpInfo = wpService.getWebProject(wpStoreId); - - final NodeRef wpNodeRef = wpInfo.getNodeRef(); - - String role = wpService.getWebUserRole(wpNodeRef, userName); - SandboxInfo sbInfo = sandboxFactory.createUserSandbox(wpStoreId, userName, role); - - List sandboxInfoList = new LinkedList(); - sandboxInfoList.add(sbInfo); - - // Bind the post-commit transaction listener with data required for virtualization server notification - CreateSandboxTransactionListener tl = new CreateSandboxTransactionListener(sandboxInfoList, wpService.listWebApps(wpNodeRef)); - AlfrescoTransactionSupport.bindListener(tl); - - if (logger.isDebugEnabled()) - { - logger.debug("createAuthorSandboxImpl: " + sbInfo.getSandboxId() + " in "+(System.currentTimeMillis()-start)+" ms (web project id: " + wpStoreId + ")"); - } - - return sbInfo; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#listSandboxes(java.lang.String) - */ - public List listSandboxes(String wpStoreId) - { - long start = System.currentTimeMillis(); - - ParameterCheck.mandatoryString("wpStoreId", wpStoreId); - - List sbInfos = null; - - String currentUser = AuthenticationUtil.getFullyAuthenticatedUser(); - String userRole = wpService.getWebUserRole(wpStoreId, currentUser); - - if (WCMUtil.ROLE_CONTENT_MANAGER.equals(userRole) || WCMUtil.ROLE_CONTENT_PUBLISHER.equals(userRole)) - { - sbInfos = sandboxFactory.listAllSandboxes(wpStoreId); - } - else - { - sbInfos = new ArrayList(1); - - if (userRole != null) - { - SandboxInfo authorSandbox = getAuthorSandbox(wpStoreId, currentUser); - - if (authorSandbox != null) - { - sbInfos.add(authorSandbox); - } - - sbInfos.add(getSandbox(WCMUtil.buildStagingStoreName(wpStoreId))); // get staging sandbox - } - } - - if (logger.isDebugEnabled()) - { - logger.debug("listSandboxes: " + wpStoreId + " in "+(System.currentTimeMillis()-start)+" ms (web project id: " + wpStoreId + ")"); - } - - return sbInfos; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#listSandboxes(java.lang.String, java.lang.String) - */ - public List listSandboxes(final String wpStoreId, String userName) - { - ParameterCheck.mandatoryString("wpStoreId", wpStoreId); - ParameterCheck.mandatoryString("userName", userName); - - String currentUser = AuthenticationUtil.getFullyAuthenticatedUser(); - String userRole = wpService.getWebUserRole(wpStoreId, currentUser); - - if (WCMUtil.ROLE_CONTENT_MANAGER.equals(userRole) || WCMUtil.ROLE_CONTENT_PUBLISHER.equals(userRole)) - { - throw new AccessDeniedException("Only content managers or content publishers may list sandboxes for '"+userName+"' (web project id: "+wpStoreId+")"); - } - - return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork>() - { - public List doWork() throws Exception - { - return listSandboxes(wpStoreId); - } - }, userName); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#isSandboxType(java.lang.String, org.alfresco.service.namespace.QName) - */ - public boolean isSandboxType(String sbStoreId, QName sandboxType) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatory("sandboxType", sandboxType); - - SandboxInfo sbInfo = getSandbox(sbStoreId); - if (sbInfo != null) - { - return sbInfo.getSandboxType().equals(sandboxType); - } - return false; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#getSandbox(java.lang.String) - */ - public SandboxInfo getSandbox(String sbStoreId) - { - long start = System.currentTimeMillis(); - - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - - String wpStoreId = WCMUtil.getWebProjectStoreId(sbStoreId); - - // check user has read access to web project (ie. is a web user) - if (! wpService.isWebUser(wpStoreId)) - { - return null; - } - - if (! WCMUtil.isStagingStore(sbStoreId)) - { - String currentUser = AuthenticationUtil.getFullyAuthenticatedUser(); - - if (! (WCMUtil.getUserName(sbStoreId).equals(currentUser))) - { - String userRole = wpService.getWebUserRole(wpStoreId, currentUser); - if (! (WCMUtil.ROLE_CONTENT_MANAGER.equals(userRole) || WCMUtil.ROLE_CONTENT_PUBLISHER.equals(userRole))) - { - throw new AccessDeniedException("Only content managers or content publishers may get sandbox '"+sbStoreId+"' (web project id: "+wpStoreId+")"); - } - } - } - - SandboxInfo sbInfo = sandboxFactory.getSandbox(sbStoreId); - - if (logger.isTraceEnabled()) - { - if (sbInfo != null) - { - logger.trace("getSandbox: " + sbInfo.getSandboxId() + " in "+(System.currentTimeMillis()-start)+" ms (web project id: " + wpStoreId + ")"); - } - else - { - logger.trace("getSandbox: " + sbStoreId +" (does not exist) in "+(System.currentTimeMillis()-start)+" ms (web project id: " + wpStoreId + ")"); - } - } - - return sbInfo; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#getAuthorSandbox(java.lang.String) - */ - public SandboxInfo getAuthorSandbox(String wpStoreId) - { - ParameterCheck.mandatoryString("wpStoreId", wpStoreId); - - String currentUserName = AuthenticationUtil.getFullyAuthenticatedUser(); - return getSandbox(WCMUtil.buildUserMainStoreName(WCMUtil.buildStagingStoreName(wpStoreId), currentUserName)); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#getUserSandbox(java.lang.String, java.lang.String) - */ - public SandboxInfo getAuthorSandbox(String wpStoreId, String userName) - { - ParameterCheck.mandatoryString("wpStoreId", wpStoreId); - ParameterCheck.mandatoryString("userName", userName); - - return getSandbox(WCMUtil.buildUserMainStoreName(WCMUtil.buildStagingStoreName(wpStoreId), userName)); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#getStagingSandbox(java.lang.String) - */ - public SandboxInfo getStagingSandbox(String wpStoreId) - { - ParameterCheck.mandatoryString("wpStoreId", wpStoreId); - - return getSandbox(WCMUtil.buildStagingStoreName(wpStoreId)); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#deleteSandbox(java.lang.String) - */ - public void deleteSandbox(String sbStoreId) - { - long start = System.currentTimeMillis(); - - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - - String wpStoreId = WCMUtil.getWebProjectStoreId(sbStoreId); - - if (AuthenticationUtil.isRunAsUserTheSystemUser()) - { - // system may delete (eg. workflow) sandbox - sandboxFactory.deleteSandbox(sbStoreId); - } - else - { - String currentUserName = AuthenticationUtil.getFullyAuthenticatedUser(); - if (sbStoreId.equals(WCMUtil.buildUserMainStoreName(wpStoreId, currentUserName))) - { - // author may delete their own sandbox - sandboxFactory.deleteSandbox(sbStoreId); - } - else - { - if (! wpService.isContentManager(wpStoreId, currentUserName)) - { - throw new AccessDeniedException("Only content managers may delete sandbox '"+sbStoreId+"' (web project id: "+wpStoreId+")"); - } - - if (sbStoreId.equals(wpStoreId)) - { - throw new AccessDeniedException("Cannot delete staging sandbox '"+sbStoreId+"' (web project id: "+wpStoreId+")"); - } - - // content manager may delete sandboxes, except staging sandbox - sandboxFactory.deleteSandbox(sbStoreId); - } - } - - if (logger.isDebugEnabled()) - { - logger.debug("deleteSandbox: " + sbStoreId + " in "+(System.currentTimeMillis()-start)+" ms (web project id: " + wpStoreId + ")"); - } - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#listChangedAll(java.lang.String, boolean) - */ - public List listChangedAll(String sbStoreId, boolean includeDeleted) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - - String avmDirectoryPath = WCMUtil.buildSandboxRootPath(sbStoreId); // currently :/www/avm_webapps - return listChanged(sbStoreId, WCMUtil.getStoreRelativePath(avmDirectoryPath), includeDeleted); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#listChangedWebApp(java.lang.String, java.lang.String, boolean) - */ - public List listChangedWebApp(String sbStoreId, String webApp, boolean includeDeleted) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("webApp", webApp); - - // filter by current webapp - String avmDirectoryPath = WCMUtil.buildStoreWebappPath(sbStoreId, webApp); - return listChanged(sbStoreId, WCMUtil.getStoreRelativePath(avmDirectoryPath), includeDeleted); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#listChanged(java.lang.String, java.lang.String, boolean) - */ - public List listChanged(String sbStoreId, String relativePath, boolean includeDeleted) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("relativePath", relativePath); - - // TODO - allow list for any sandbox - if (! WCMUtil.isUserStore(sbStoreId)) - { - throw new AlfrescoRuntimeException("Not an author sandbox: "+sbStoreId); - } - - // build the paths to the stores to compare - filter by given directory path - String wpStoreId = WCMUtil.getWebProjectStoreId(sbStoreId); - String stagingSandboxId = WCMUtil.buildStagingStoreName(wpStoreId); - - return listChanged(sbStoreId, relativePath, stagingSandboxId, relativePath, includeDeleted); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#listChanged(java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean) - */ - public List listChanged(String srcSandboxStoreId, String srcRelativePath, String dstSandboxStoreId, String dstRelativePath, boolean includeDeleted) - { - ParameterCheck.mandatoryString("srcSandboxStoreId", srcSandboxStoreId); - ParameterCheck.mandatoryString("srcRelativePath", srcRelativePath); - - ParameterCheck.mandatoryString("dstSandboxStoreId", dstSandboxStoreId); - ParameterCheck.mandatoryString("dstRelativePath", dstRelativePath); - - // checks sandbox access (TODO review) - getSandbox(srcSandboxStoreId); // ignore result - getSandbox(dstSandboxStoreId); // ignore result - - String avmSrcPath = AVMUtil.buildAVMPath(srcSandboxStoreId, srcRelativePath); - String avmDstPath = AVMUtil.buildAVMPath(dstSandboxStoreId, dstRelativePath); - - return listChanged(-1, avmSrcPath, -1, avmDstPath, includeDeleted); - } - - private List listChanged(int srcVersion, String srcPath, int dstVersion, String dstPath, boolean includeDeleted) - { - long start = System.currentTimeMillis(); - - List diffs = avmSyncService.compare(srcVersion, srcPath, dstVersion, dstPath, nameMatcher); - - List assets = new ArrayList(diffs.size()); - - for (AVMDifference diff : diffs) - { - // convert each diff record into an AVM node descriptor - String sourcePath = diff.getSourcePath(); - - String[] parts = WCMUtil.splitPath(sourcePath); - AssetInfo asset = assetService.getAsset(parts[0], -1, parts[1], includeDeleted); - if (asset != null) - { - // TODO refactor - ((AssetInfoImpl)asset).setDiffCode(diff.getDifferenceCode()); - assets.add(asset); - } - } - - if (logger.isDebugEnabled()) - { - logger.debug("listChanged: "+assets.size()+" assets in "+(System.currentTimeMillis()-start)+" ms (between "+srcVersion+","+srcPath+" and "+dstVersion+","+dstPath); - } - - return assets; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#submitAll(java.lang.String, java.lang.String, java.lang.String) - */ - public void submitAll(String sbStoreId, String submitLabel, String submitComment) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - - String avmDirectoryPath = WCMUtil.buildSandboxRootPath(sbStoreId); // currently :/www/avm_webapps - submit(sbStoreId, WCMUtil.getStoreRelativePath(avmDirectoryPath), submitLabel, submitComment); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#submitWebApp(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - public void submitWebApp(String sbStoreId, String webApp, String submitLabel, String submitComment) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("webApp", webApp); - - String avmDirectoryPath = WCMUtil.buildStoreWebappPath(sbStoreId, webApp); - submit(sbStoreId, WCMUtil.getStoreRelativePath(avmDirectoryPath), submitLabel, submitComment); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#submit(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - public void submit(String sbStoreId, String relativePath, String submitLabel, String submitComment) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("relativePath", relativePath); - - List assets = listChanged(sbStoreId, relativePath, true); - - submitListAssets(sbStoreId, assets, submitLabel, submitComment); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#submitList(java.lang.String, java.util.List, java.lang.String, java.lang.String) - */ - public void submitList(String sbStoreId, List relativePaths, String submitLabel, String submitComment) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - - List assets = new ArrayList(relativePaths.size()); - - for (String relativePath : relativePaths) - { - // convert each path into an asset - AssetInfo asset = assetService.getAsset(sbStoreId, -1, relativePath, true); - if (asset != null) - { - assets.add(asset); - } - } - - submitListAssets(sbStoreId, assets, submitLabel, submitComment); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#submitListAssets(java.lang.String, java.util.List, java.lang.String, java.lang.String) - */ - public void submitListAssets(String sbStoreId, List assets, String submitLabel, String submitComment) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("submitLabel", submitLabel); - - // TODO - consider submit to higher-level sandbox, not just to staging - if (! WCMUtil.isUserStore(sbStoreId)) - { - throw new AlfrescoRuntimeException("Not an author sandbox: "+sbStoreId); - } - - List relativePaths = new ArrayList(assets.size()); - for (AssetInfo asset : assets) - { - relativePaths.add(asset.getPath()); - } - - // via submit direct workflow - submitViaWorkflow(sbStoreId, relativePaths, null, null, submitLabel, submitComment, null, null, false); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#submitListAssets(java.lang.String, java.util.List, java.lang.String, java.util.Map, java.lang.String, java.lang.String, java.util.Map, java.util.Date, boolean, boolean) - */ - public void submitListAssets(String sbStoreId, List relativePaths, - String workflowName, Map workflowParams, - String submitLabel, String submitComment, - Map expirationDates, Date launchDate, boolean autoDeploy) - { - // via selected workflow - submitViaWorkflow(sbStoreId, relativePaths, workflowName, workflowParams, submitLabel, submitComment, - expirationDates, launchDate, autoDeploy); - } - - /** - * Submits the selected items via the configured workflow. - *

- * This method uses 2 separate transactions to perform the submit. - * The first one creates the workflow sandbox. The virtualisation - * server is then informed of the new stores. The second - * transaction then starts the appropriate workflow. This approach - * is needed to allow link validation to be performed on the - * workflow sandbox. - */ - private void submitViaWorkflow(final String sbStoreId, final List relativePaths, String workflowName, Map workflowParams, - final String submitLabel, final String submitComment, - final Map expirationDates, final Date launchDate, final boolean autoDeploy) - { - long start = System.currentTimeMillis(); - - // checks sandbox access (TODO review) - getSandbox(sbStoreId); // ignore result - - final String wpStoreId = WCMUtil.getWebProjectStoreId(sbStoreId); - final String stagingSandboxId = WCMUtil.buildStagingStoreName(wpStoreId); - - final String finalWorkflowName; - final Map finalWorkflowParams; - - boolean isSubmitDirectWorkflowSandbox = false; - - if ((workflowName == null) || (workflowName.equals(""))) - { - finalWorkflowName = WORKFLOW_SUBMITDIRECT; - finalWorkflowParams = new HashMap(); - isSubmitDirectWorkflowSandbox = true; - } - else - { - finalWorkflowName = workflowName; - finalWorkflowParams = workflowParams; - } - - RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper(); - - final List srcPaths = new ArrayList(relativePaths.size()); - for (String relativePath : relativePaths) - { - srcPaths.add(AVMUtil.buildAVMPath(sbStoreId, relativePath)); - } - - final String webApp = WCMUtil.getCommonWebApp(sbStoreId, relativePaths); - - RetryingTransactionCallback> sandboxCallback = new RetryingTransactionCallback>() - { - public Pair execute() throws Throwable - { - // call the actual implementation - return createWorkflowSandbox(finalWorkflowName, finalWorkflowParams, stagingSandboxId, srcPaths, expirationDates); - } - }; - - // create the workflow sandbox firstly - final Pair workflowInfo = txnHelper.doInTransaction(sandboxCallback, false, true); - - if (workflowInfo != null) - { - final SandboxInfo wfSandboxInfo = workflowInfo.getFirst(); - String virtUpdatePath = workflowInfo.getSecond(); - - // inform the virtualisation server if the workflow sandbox was created - if (virtUpdatePath != null) - { - // optimization: direct submits no longer virtualize the workflow sandbox - if (! isSubmitDirectWorkflowSandbox) - { - WCMUtil.updateVServerWebapp(virtServerRegistry, virtUpdatePath, true); - } - } - - try - { - RetryingTransactionCallback workflowCallback = new RetryingTransactionCallback() - { - public String execute() throws Throwable - { - // call the actual implementation - startWorkflow(wpStoreId, sbStoreId, wfSandboxInfo, webApp, finalWorkflowName, finalWorkflowParams, submitLabel, submitComment, launchDate, autoDeploy); - return null; - } - }; - - // start the workflow - txnHelper.doInTransaction(workflowCallback, false, true); - } - catch (Throwable err) - { - cleanupWorkflowSandbox(wfSandboxInfo); - throw new AlfrescoRuntimeException("Failed to submit to workflow", err); - } - } - - if (logger.isDebugEnabled()) - { - logger.debug("submitViaWorkflow: " + sbStoreId + " ["+submitLabel+", "+finalWorkflowName+"] in "+(System.currentTimeMillis()-start)+" ms (web project id: " + wpStoreId + ")"); - } - } - - /** - * Creates a workflow sandbox for all the submitted items - * - * @param context Faces context - */ - protected Pair createWorkflowSandbox(String workflowName, Map workflowParams, String stagingSandboxId, final List srcPaths, Map expirationDates) - { - // The virtualization server might need to be notified - // because one or more of the files submitted could alter - // the behavior the virtual webapp in the target of the submit. - // For example, the user might be submitting a new jar or web.xml file. - // - // This must take place after the transaction has been completed; - // therefore, a variable is needed to store the path to the - // updated webapp so it can happen in doPostCommitProcessing. - String virtUpdatePath = null; - SandboxInfo sandboxInfo = null; - - // create container for our avm workflow package - - if (! workflowName.equals(WORKFLOW_SUBMITDIRECT)) - { - // Create workflow sandbox for workflow package - sandboxInfo = sandboxFactory.createWorkflowSandbox(stagingSandboxId); - } - else - { - // default to direct submit workflow - - // NOTE: read only workflow sandbox is lighter to construct than full workflow sandbox - sandboxInfo = sandboxFactory.createReadOnlyWorkflowSandbox(stagingSandboxId); - } - - // Example workflow main store name: - // mysite--workflow-9161f640-b020-11db-8015-130bf9b5b652 - String workflowMainStoreName = sandboxInfo.getMainStoreName(); - - final List diffs = new ArrayList(srcPaths.size()); - - // get diff list - also process expiration dates, if any, and set virt svr update path - - for (String srcPath : srcPaths) - { - // We *always* want to update virtualization server - // when a workflow sandbox is given data in the - // context of a submit workflow. Without this, - // it would be impossible to see workflow data - // in context. The raw operation to create a - // workflow sandbox does not notify the virtualization - // server that it exists because it's useful to - // defer this operation until everything is already - // in place; this allows pointlessly fine-grained - // notifications to be suppressed (they're expensive). - // - // Therefore, just derive the name of the webapp - // in the workflow sandbox from the 1st item in - // the submit list (even if it's not in WEB-INF), - // and force the virt server notification after the - // transaction has completed via doPostCommitProcessing. - if (virtUpdatePath == null) - { - // The virtUpdatePath looks just like the srcPath - // except that it belongs to a the main store of - // the workflow sandbox instead of the sandbox - // that originated the submit. - virtUpdatePath = WCMUtil.getCorrespondingPath(srcPath, workflowMainStoreName); - } - - if ((expirationDates != null) && (! expirationDates.isEmpty())) - { - // process the expiration date (if any) - processExpirationDate(srcPath, expirationDates); - } - - diffs.add(new AVMDifference(-1, srcPath, -1, WCMUtil.getCorrespondingPath(srcPath, workflowMainStoreName), AVMDifference.NEWER)); - } - - // write changes to layer so files are marked as modified - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - - public Object doWork() throws Exception - { - avmSyncService.update(diffs, null, false, false, false, false, null, null); - return null; - } - }, AuthenticationUtil.getSystemUserName()); - - return new Pair(sandboxInfo, virtUpdatePath); - } - - /** - * Starts the configured workflow to allow the submitted items to be link - * checked and reviewed. - */ - protected void startWorkflow(String wpStoreId, String sbStoreId, SandboxInfo wfSandboxInfo, String webApp, String workflowName, Map workflowParams, - String submitLabel, String submitComment, Date launchDate, boolean autoDeploy) - { - ParameterCheck.mandatoryString("workflowName", workflowName); - ParameterCheck.mandatory("workflowParams", workflowParams); - - // start the workflow to get access to the start task - WorkflowDefinition wfDef = workflowService.getDefinitionByName(workflowName); - WorkflowPath path = workflowService.startWorkflow(wfDef.id, null); - - if (path != null) - { - // extract the start task - List tasks = workflowService.getTasksForWorkflowPath(path.id); - if (tasks.size() == 1) - { - WorkflowTask startTask = tasks.get(0); - - if (startTask.state == WorkflowTaskState.IN_PROGRESS) - { - final NodeRef workflowPackage = WCMWorkflowUtil.createWorkflowPackage(workflowService, avmService, wfSandboxInfo); - - workflowParams.put(WorkflowModel.ASSOC_PACKAGE, workflowPackage); - - // add submission parameters - workflowParams.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, submitComment); - workflowParams.put(WCMWorkflowModel.PROP_LABEL, submitLabel); - workflowParams.put(WCMWorkflowModel.PROP_FROM_PATH, - WCMUtil.buildStoreRootPath(sbStoreId)); - workflowParams.put(WCMWorkflowModel.PROP_LAUNCH_DATE, launchDate); - workflowParams.put(WCMWorkflowModel.PROP_AUTO_DEPLOY, - new Boolean(autoDeploy)); - workflowParams.put(WCMWorkflowModel.PROP_WEBAPP, - webApp); - workflowParams.put(WCMWorkflowModel.ASSOC_WEBPROJECT, - wpService.getWebProjectNodeFromStore(wpStoreId)); - - // update start task with submit parameters - workflowService.updateTask(startTask.id, workflowParams, null, null); - - // end the start task to trigger the first 'proper' task in the workflow - workflowService.endTask(startTask.id, null); - } - } - } - } - - /** - * Cleans up the workflow sandbox created by the first transaction. This - * action is itself performed in a separate transaction. - */ - private void cleanupWorkflowSandbox(final SandboxInfo sandboxInfo) - { - RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper(); - - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public String execute() throws Throwable - { - // delete AVM stores in the workflow sandbox - sandboxFactory.deleteSandbox(sandboxInfo.getSandboxId()); - return null; - } - }; - - try - { - // Execute the cleanup handler - txnHelper.doInTransaction(callback); - } - catch (Throwable e) - { - // not much we can do now, just log the error to inform admins - logger.error("Failed to cleanup workflow sandbox after workflow failure", e); - } - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#revertAll(java.lang.String) - */ - public void revertAll(String sbStoreId) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - - String avmDirectoryPath = WCMUtil.buildSandboxRootPath(sbStoreId); // currently :/www/avm_webapps - revert(sbStoreId, WCMUtil.getStoreRelativePath(avmDirectoryPath)); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#revertWebApp(java.lang.String, java.lang.String) - */ - public void revertWebApp(String sbStoreId, String webApp) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("webApp", webApp); - - String avmDirectoryPath = WCMUtil.buildStoreWebappPath(sbStoreId, webApp); - revert(sbStoreId, WCMUtil.getStoreRelativePath(avmDirectoryPath)); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#revertAllDir(java.lang.String, java.lang.String) - */ - public void revert(String sbStoreId, String relativePath) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - ParameterCheck.mandatoryString("relativePath", relativePath); - - List assets = listChanged(sbStoreId, relativePath, true); - - revertListAssets(sbStoreId, assets); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#revertList(java.lang.String, java.util.List) - */ - public void revertList(String sbStoreId, List relativePaths) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - - List assets = new ArrayList(relativePaths.size()); - - for (String relativePath : relativePaths) - { - // convert each path into an asset - AssetInfo asset = assetService.getAsset(sbStoreId, -1, relativePath, true); - if (asset != null) - { - assets.add(asset); - } - } - - revertListAssets(sbStoreId, assets); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#revertListAssets(java.lang.String, java.util.List) - */ - public void revertListAssets(String sbStoreId, List assets) - { - long start = System.currentTimeMillis(); - - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - - // checks sandbox access (TODO review) - getSandbox(sbStoreId); // ignore result - - String wpStoreId = WCMUtil.getWebProjectStoreId(sbStoreId); - - List assetsToRevert = new ArrayList(assets.size()); - - List wfRelativePaths = WCMWorkflowUtil.getAssociatedPathsForSandbox(avmSyncService, workflowService, sbStoreId); - - for (AssetInfo asset : assets) - { - if (! asset.getSandboxId().equals(sbStoreId)) - { - // belts-and-braces - logger.warn("revertListAssets: Skip assert "+asset.getPath()+" (was "+asset.getSandboxId()+", expected "+sbStoreId+")"); - continue; - } - - // check if in workflow - if (! wfRelativePaths.contains(asset.getPath())) - { - assetsToRevert.add(asset); - - if (VirtServerUtils.requiresUpdateNotification(asset.getAvmPath())) - { - // Bind the post-commit transaction listener with data required for virtualization server notification - UpdateSandboxTransactionListener tl = new UpdateSandboxTransactionListener(asset.getAvmPath()); - AlfrescoTransactionSupport.bindListener(tl); - } - } - } - - for (AssetInfo asset : assetsToRevert) - { - String [] parentChild = AVMNodeConverter.SplitBase(asset.getAvmPath()); - if (parentChild.length != 2) - { - continue; - } - - AVMNodeDescriptor parent = avmService.lookup(-1, parentChild[0], true); - - if (parent.isLayeredDirectory()) - { - if (logger.isTraceEnabled()) - { - logger.trace("reverting " + parentChild[1] + " in " + parentChild[0]); - } - - avmService.makeTransparent(parentChild[0], parentChild[1]); - } - - if (asset.isFile()) - { - // is file or deleted file - String relativePath = asset.getPath(); - - if (logger.isTraceEnabled()) - { - logger.trace("unlocking file " + relativePath + " in web project " + wpStoreId); - } - - if (avmLockingService.getLockOwner(wpStoreId, relativePath) != null) - { - avmLockingService.removeLock(wpStoreId, relativePath); - } - else - { - if (logger.isWarnEnabled()) - { - logger.warn("expected file " + relativePath + " in " + wpStoreId + " to be locked"); - } - } - } - } - - if (logger.isDebugEnabled()) - { - logger.debug("revertListAssets: " + sbStoreId + " ["+assets.size()+", "+assetsToRevert.size()+"] in "+(System.currentTimeMillis()-start)+" ms (web project id: " + wpStoreId + ")"); - } - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#listSnapshots(java.lang.String, boolean) - */ - public List listSnapshots(String sbStoreId, boolean includeSystemGenerated) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - - String wpStoreId = WCMUtil.getWebProjectStoreId(sbStoreId); - if (! wpService.isContentManager(wpStoreId)) - { - throw new AccessDeniedException("Only content managers may list snapshots '"+sbStoreId+"' (web project id: "+wpStoreId+")"); - } - - return listSnapshots(sbStoreId, null, null, includeSystemGenerated); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#listSnapshots(java.lang.String, java.util.Date, java.util.Date, boolean) - */ - public List listSnapshots(String sbStoreId, Date from, Date to, boolean includeSystemGenerated) - { - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - - String wpStoreId = WCMUtil.getWebProjectStoreId(sbStoreId); - if (! wpService.isContentManager(wpStoreId)) - { - throw new AccessDeniedException("Only content managers may list snapshots '"+sbStoreId+"' (web project id: "+wpStoreId+")"); - } - - return listSnapshotsImpl(sbStoreId, from, to, includeSystemGenerated); - } - - private List listSnapshotsImpl(String sbStoreId, Date from, Date to, boolean includeSystemGenerated) - { - long start = System.currentTimeMillis(); - - List versionsToFilter = null; - - if ((from != null) && (to != null)) - { - versionsToFilter = avmService.getStoreVersions(sbStoreId, from, to); - } - else - { - versionsToFilter = avmService.getStoreVersions(sbStoreId); - } - - List versions = new ArrayList(versionsToFilter.size()); - - for (int i = versionsToFilter.size() - 1; i >= 0; i--) // reverse order - { - VersionDescriptor item = versionsToFilter.get(i); - - // only display snapshots with a valid tag - others are system generated snapshots - if ((includeSystemGenerated == true) || ((item.getTag() != null) && (item.getVersionID() != 0))) - { - versions.add(new SandboxVersionImpl(item)); - } - } - - if (logger.isDebugEnabled()) - { - logger.debug("listSnapshotsImpl: " + sbStoreId + " ["+from+", "+to+", "+versions.size()+"] in "+(System.currentTimeMillis()-start)+" ms (web project id: "+WCMUtil.getWebProjectStoreId(sbStoreId)+")"); - } - - return versions; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxService#revertSnapshot(java.lang.String, int) - */ - public void revertSnapshot(final String sbStoreId, final int revertVersion) - { - long start = System.currentTimeMillis(); - - ParameterCheck.mandatoryString("sbStoreId", sbStoreId); - - String wpStoreId = WCMUtil.getWebProjectStoreId(sbStoreId); - if (! wpService.isContentManager(wpStoreId)) - { - throw new AccessDeniedException("Only content managers may revert staging sandbox '"+sbStoreId+"' (web project id: "+wpStoreId+")"); - } - - // do this as system as the staging area has restricted access (and content manager may not have permission to delete children, for example) - List diffs = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork>() - { - public List doWork() throws Exception - { - String sandboxPath = AVMUtil.buildAVMPath(sbStoreId, AVMUtil.AVM_PATH_SEPARATOR); // root - List diffs = avmSyncService.compare(revertVersion, sandboxPath, -1, sandboxPath, null); - - String message = "Reverted to Version " + revertVersion + "."; - avmSyncService.update(diffs, null, false, false, true, true, message, message); - - return diffs; - } - }, AuthenticationUtil.getSystemUserName()); - - // See if any of the files being reverted require notification of the virt server, to update the webapp - for (AVMDifference diff : diffs) - { - if (VirtServerUtils.requiresUpdateNotification(diff.getSourcePath())) - { - // Bind the post-commit transaction listener with data required for virtualization server notification - UpdateSandboxTransactionListener tl = new UpdateSandboxTransactionListener(diff.getSourcePath()); - AlfrescoTransactionSupport.bindListener(tl); - break; - } - } - - if (logger.isDebugEnabled()) - { - logger.debug("revertSnapshot: " + sbStoreId + " ["+revertVersion+"] in "+(System.currentTimeMillis()-start)+" ms (web project id: "+WCMUtil.getWebProjectStoreId(sbStoreId)+")"); - } - } - - /** - * Sets up the expiration date for the given source path - * - * @param srcPath The path to set the expiration date for - */ - private void processExpirationDate(String srcPath, Map expirationDates) - { - // if an expiration date has been set for this item we need to - // add the expires aspect and the date supplied - Date expirationDate = expirationDates.get(srcPath); - if (expirationDate == null) - { - return; - } - - // make sure the aspect is present - if (avmService.hasAspect(-1, srcPath, WCMAppModel.ASPECT_EXPIRES) == false) - { - avmService.addAspect(srcPath, WCMAppModel.ASPECT_EXPIRES); - } - - // set the expiration date - avmService.setNodeProperty(srcPath, WCMAppModel.PROP_EXPIRATIONDATE, - new PropertyValue(DataTypeDefinition.DATETIME, expirationDate)); - - if (logger.isTraceEnabled()) - { - logger.trace("Set expiration date of " + expirationDate + " for " + srcPath); - } - } - - /** - * Create Sandbox Transaction listener - invoked after commit - */ - private class CreateSandboxTransactionListener extends TransactionListenerAdapter - { - private List sandboxInfoList; - private List webAppNames; - - public CreateSandboxTransactionListener(List sandboxInfoList, List webAppNames) - { - this.sandboxInfoList = sandboxInfoList; - this.webAppNames = webAppNames; - } - - /** - * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterCommit() - */ - @Override - public void afterCommit() - { - // Handle notification to the virtualization server - // (this needs to occur after the sandboxes are created in the main txn) - - // reload virtualisation server for webapp(s) in this web project - for (SandboxInfo sandboxInfo : this.sandboxInfoList) - { - String newlyInvitedStoreName = WCMUtil.buildStagingStoreName(sandboxInfo.getMainStoreName()); - - for (String webAppName : webAppNames) - { - String path = WCMUtil.buildStoreWebappPath(newlyInvitedStoreName, webAppName); - WCMUtil.updateVServerWebapp(virtServerRegistry, path, true); - } - } - } - } - - /** - * Update Sandbox Transaction listener - invoked after submit or revert - */ - private class UpdateSandboxTransactionListener extends TransactionListenerAdapter - { - private String virtUpdatePath; - - public UpdateSandboxTransactionListener(String virtUpdatePath) - { - this.virtUpdatePath = virtUpdatePath; - } - - /** - * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterCommit() - */ - @Override - public void afterCommit() - { - // The virtualization server might need to be notified - // because one or more of the files submitted / reverted could alter - // the behavior the virtual webapp in the target of the submit. - // For example, the user might be submitting a new jar or web.xml file. - // - // This must take place after the transaction has been completed; - - // force an update of the virt server if necessary - if (this.virtUpdatePath != null) - { - WCMUtil.updateVServerWebapp(virtServerRegistry, this.virtUpdatePath, true); - } - } - } -} diff --git a/source/java/org/alfresco/wcm/sandbox/SandboxVersion.java b/source/java/org/alfresco/wcm/sandbox/SandboxVersion.java deleted file mode 100644 index 79c368ba7a..0000000000 --- a/source/java/org/alfresco/wcm/sandbox/SandboxVersion.java +++ /dev/null @@ -1,76 +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 . - */ -package org.alfresco.wcm.sandbox; - -import java.util.Date; - -/** -* Provides information about a WCM sandbox version (snapshot). -*/ -public interface SandboxVersion -{ - /** - * Get the sandbox id - * - * @return String sandbox id - */ - public String getSandboxId(); - - /** - * Get the sandbox version ID - * - * @return The version - */ - public int getVersion(); - - /** - * Get the creator of this version - * - * @return The creator - */ - public String getCreator(); - - /** - * Get the creation date - * - * @return The creation date - */ - public Date getCreatedDate(); - - /** - * Get the submitted (short) label / tag - * - * @return The label - */ - public String getLabel(); - - /** - * Get the submitted (long) description - * - * @return The description - */ - public String getDescription(); - - /** - * Return true if system generated snapshot - * - * @return TRUE if system (implicit) snapshot - */ - boolean isSystemGenerated(); -} diff --git a/source/java/org/alfresco/wcm/sandbox/SandboxVersionImpl.java b/source/java/org/alfresco/wcm/sandbox/SandboxVersionImpl.java deleted file mode 100644 index cd24b2af7b..0000000000 --- a/source/java/org/alfresco/wcm/sandbox/SandboxVersionImpl.java +++ /dev/null @@ -1,92 +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 . - */ -package org.alfresco.wcm.sandbox; - -import java.util.Date; - -import org.alfresco.service.cmr.avm.VersionDescriptor; - -/** -* Provides information about a WCM sandbox version (snapshot). -*/ -public class SandboxVersionImpl implements SandboxVersion -{ - private VersionDescriptor vDesc; - - /* package */ SandboxVersionImpl(VersionDescriptor vDesc) - { - this.vDesc = vDesc; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxVersion#getSandboxId() - */ - public String getSandboxId() - { - return vDesc.getAVMStoreName(); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxVersion#getVersion() - */ - public int getVersion() - { - return vDesc.getVersionID(); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxVersion#getCreator() - */ - public String getCreator() - { - return vDesc.getCreator(); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxVersion#getCreatedDate() - */ - public Date getCreatedDate() - { - return new Date(vDesc.getCreateDate()); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxVersion#getLabel() - */ - public String getLabel() - { - return vDesc.getTag(); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxVersion#getDescription() - */ - public String getDescription() - { - return vDesc.getDescription(); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.sandbox.SandboxVersion#isSystemGenerated() - */ - public boolean isSystemGenerated() - { - return ((vDesc.getTag() == null) || (vDesc.getVersionID() == 0)); - } -} diff --git a/source/java/org/alfresco/wcm/sandbox/script/Asset.java b/source/java/org/alfresco/wcm/sandbox/script/Asset.java deleted file mode 100644 index 897bcd67b5..0000000000 --- a/source/java/org/alfresco/wcm/sandbox/script/Asset.java +++ /dev/null @@ -1,589 +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 . - */ -package org.alfresco.wcm.sandbox.script; - -import java.io.IOException; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.repo.dictionary.DictionaryNamespaceComponent; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.avm.AVMBadArgumentException; -import org.alfresco.service.cmr.avm.AVMNotFoundException; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.dictionary.TypeDefinition; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.ContentIOException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.NamespaceException; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.wcm.asset.AssetInfo; -import org.alfresco.wcm.asset.AssetService; -import org.alfresco.wcm.sandbox.SandboxService; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.extensions.surf.util.Content; -import org.springframework.extensions.surf.util.ISO8601DateFormat; - -/** - * WCM Asset in a sandbox exposed over Java Script API. - * @author mrogers - * - */ -public class Asset implements Serializable -{ - private static final QName NAMESPACE_SERVICE = QName.createQName("", "namespaceService"); - /** - * - */ - private static final long serialVersionUID = -5759260478423750966L; - private AssetInfo asset; - private Sandbox sandbox; - private Map props; - private Set updatedProperties = new HashSet(); - - public Asset(Sandbox sandbox, AssetInfo asset) - { - this.sandbox = sandbox; - this.asset = asset; - } - - /** - * The creator of this asset - * @return the creator - */ - public String getCreator() - { - return asset.getCreator(); - } - - public Date getCreatedDate() - { - return asset.getCreatedDate(); - } - - public long getFileSize() - { - return asset.getFileSize(); - } - - public String getCreatedDateAsISO8601() - { - return ISO8601DateFormat.format(getCreatedDate()); - } - - public String getModifier() - { - return asset.getModifier(); - } - - public Date getModifiedDate() - { - return asset.getModifiedDate(); - } - - public String getModifiedDateAsISO8601() - { - return ISO8601DateFormat.format(getModifiedDate()); - } - - /** - * rename this asset - * @param newName - */ - public Asset rename(String newName) - { - if(!newName.equals(asset.getName())) - { - AssetInfo newAsset = getAssetService().renameAsset(asset, newName); - this.asset = newAsset; - } - return this; - } - - /** - * move this asset - * @param newPath - */ - public Asset move(String newPath) - { - if(!newPath.equals(asset.getPath())) - { - AssetInfo newAsset = getAssetService().moveAsset(asset, newPath); - this.asset = newAsset; - } - return this; - } - - public String getName() - { - return asset.getName(); - } - - /** - * Get the full path of this asset eg. /www/avm_webapps/ROOT/myFile.jpg - * @return the path of this asset. - */ - public String getPath() - { - return asset.getPath(); - } - - public boolean isFile() - { - return asset.isFile(); - } - - public boolean isFolder() - { - return asset.isFolder(); - } - - public boolean isDeleted() - { - return asset.isDeleted(); - } - - public boolean isLocked() - { - return asset.isLocked(); - } - - public String lockOwner() - { - return asset.getLockOwner(); - } - - public int getVersion() - { - return asset.getSandboxVersion(); - } - - /** - * Get the properties as a key value pair. The key will be either a local qname e.g. "cm:content" or - * a global qname e.g. "{http://www.alfresco.com/content/1.0}content". - * - * Some properties will be updatable, protected properties are not. - * - * @return the properties in a key, value pair - */ - - public Map getProperties() - { - if(props == null) { - - // Note there is something very strange going on with scope which is why there's this guff with propsX - Map propsX = new HashMap(); - props = propsX; - NamespaceService ns = getNamespaceService(); - - if(!asset.isDeleted()) - { - Map intprops = getAssetService().getAssetProperties(asset); - - for (QName qname : intprops.keySet()) - { - QName prefixQname = qname.getPrefixedQName(ns); - Serializable propValue = intprops.get(qname); - try - { - propsX.put(prefixQname.toPrefixString(), (null == propValue) ? (null):(propValue.toString())); - } - catch (NamespaceException ne) - { // No local name, only thing I can do is use the full namke - propsX.put(qname.toString(), propValue.toString()); - } - } - } - } - - return props; - } - - /** - * Save the properties please note some system properties are protected and cannot be updated. If you attempt to update a protected property your request will be ignored. - * - * @param properties - */ - public void save() - { - if (!updatedProperties.isEmpty() && (null != props)) - { - Map newProps = new HashMap(props.size()); - QName type = getAssetType(); - DictionaryService dictionaryService = getDictionaryService(); - TypeDefinition typeDefinition = (null != type) ? (dictionaryService.getType(type)) : (null); - if (null != typeDefinition) - { - if (updatedProperties.contains(ContentModel.PROP_NAME)) - { - updatedProperties.remove(ContentModel.PROP_NAME); - rename(getPropertyValue(ContentModel.PROP_NAME)); - } - Map propertyDefinitions = typeDefinition.getProperties(); - for (QName key : updatedProperties) - { - PropertyDefinition propertyDefinition = (propertyDefinitions.containsKey(key)) ? (propertyDefinitions.get(key)) : (dictionaryService.getProperty(key)); - Serializable value = convertValueToDataType(key, propertyDefinition.getDataType().getName(), getPropertyValue(key)); - newProps.put(key, value); - } - getAssetService().setAssetProperties(asset, newProps); - updatedProperties.clear(); - } - else - { - throw new AVMNotFoundException("The type property of the current Asset not found"); - } - } - } - - private String getPropertyValue(QName key) - { - String prefixedQName = completeContentModelQName(key).toPrefixString(); - return props.containsKey(prefixedQName) ? (props.get(prefixedQName)) : (props.get(key.toString())); - } - - private Serializable convertValueToDataType(QName propertyName, QName dataType, String textualValue) - { - Serializable result = null; - if (null != textualValue) - { - try - { - if (DataTypeDefinition.BOOLEAN.equals(dataType)) - { - result = Boolean.parseBoolean(textualValue); - } - else if (DataTypeDefinition.DOUBLE.equals(dataType)) - { - result = Double.parseDouble(textualValue); - } - else if (DataTypeDefinition.FLOAT.equals(dataType)) - { - result = Float.parseFloat(textualValue); - } - else if (DataTypeDefinition.INT.equals(dataType)) - { - result = Integer.parseInt(textualValue); - } - else if (DataTypeDefinition.LONG.equals(dataType)) - { - result = Long.parseLong(textualValue); - } - else if (DataTypeDefinition.NODE_REF.equals(dataType)) - { - result = (NodeRef.isNodeRef(textualValue)) ? (new NodeRef(textualValue)) : (null); - } - else if (DataTypeDefinition.QNAME.equals(dataType)) - { - result = QName.resolveToQName(getNamespaceService(), textualValue); - } - else if (DataTypeDefinition.CONTENT.equals(dataType)) - { - result = ContentData.createContentProperty(textualValue); - } - else if (DataTypeDefinition.TEXT.equals(dataType) || DataTypeDefinition.MLTEXT.equals(dataType)) - { - result = textualValue; - } - } - catch (NumberFormatException e) - { - throw new AVMBadArgumentException("Value for the '" + propertyName + "' property is invalid! Conversion error: " + e.toString()); - } - } - // TODO: Conversion for other DataTypes - return result; - } - - /** - * @param properties - * @throws JSONException - */ - public void setProperties(Object nativeProperties) throws JSONException - { - JSONObject properties = (JSONObject) nativeProperties; - if ((null != asset) && !asset.isDeleted()) - { - Map currentProperties = getProperties(); - if (null == currentProperties) - { - throw new AVMNotFoundException("No a property found for the current Asset"); - } - QName type = getAssetType(); - DictionaryService dictionaryService = getDictionaryService(); - TypeDefinition typeDefinition = (null != type) ? (dictionaryService.getType(type)) : (null); - if (null != typeDefinition) - { - Map propertyDefinitions = typeDefinition.getProperties(); - for (String key : JSONObject.getNames(properties)) - { - QName qName = QName.resolveToQName(getNamespaceService(), key); - if (ContentModel.PROP_CONTENT.equals(qName)) - { - updatedProperties.clear(); - throw new AVMBadArgumentException("The 'Content' property can't be set with the 'setProperties()' method! Use a 'writeContent()' instead"); - } - PropertyDefinition property = (propertyDefinitions.containsKey(qName)) ? (propertyDefinitions.get(qName)) : (dictionaryService.getProperty(qName)); - if (null != property) - { - // TODO: Maybe are multi-valued properties operable? - if (property.isProtected() || property.isMultiValued()) - { - updatedProperties.clear(); - throw new AVMBadArgumentException("The '" + key + "' property is not updatable"); - } - Object associatedValue = properties.get(key); - qName = completeContentModelQName(qName); - currentProperties.put(qName.toPrefixString(), (null != associatedValue) ? (associatedValue.toString()) : (null)); - updatedProperties.add(property.getName()); - } - else - { - updatedProperties.clear(); - throw new AVMNotFoundException("The '" + key + "' property definition can't be found"); - } - } - props = currentProperties; - } - } - } - - private QName completeContentModelQName(QName qName) - { - if (qName.getLocalName().equals(qName.getPrefixString()) && NamespaceService.CONTENT_MODEL_1_0_URI.equals(qName.getNamespaceURI())) - { - DictionaryNamespaceComponent service = (DictionaryNamespaceComponent) getSandbox().getWebproject().getWebProjects().getServiceRegistry().getService(NAMESPACE_SERVICE); - return QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, qName.getLocalName(), service); - } - return qName; - } - - private QName getAssetType() - { - final NodeRef assetNodeRef = AVMNodeConverter.ToNodeRef(asset.getSandboxVersion(), asset.getAvmPath()); - final NodeService nodeService = getNodeService(); - return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public QName doWork() throws Exception - { - RetryingTransactionHelper helper = getSandbox().getWebproject().getWebProjects().getServiceRegistry().getTransactionService().getRetryingTransactionHelper(); - return helper.doInTransaction(new RetryingTransactionCallback() - { - public QName execute() throws Throwable - { - return nodeService.getType(assetNodeRef); - } - }); - } - }, AuthenticationUtil.getFullyAuthenticatedUser()); - } - - /** - * Updates a content of a current Asset - * - * @param content {@link String} value which represents new textual content - * @return true if a content has been set without errors - */ - public boolean writeContent(String content) - { - NodeRef assetNodeRef = AVMNodeConverter.ToNodeRef(asset.getSandboxVersion(), asset.getAvmPath()); - ContentService contentService = getSandbox().getWebproject().getWebProjects().getServiceRegistry().getContentService(); - ContentWriter writer = contentService.getWriter(assetNodeRef, ContentModel.PROP_CONTENT, true); - if ((null != writer) && (null != content)) - { - writer.setMimetype("text/plain"); - writer.setEncoding("UTF-8"); - writer.putContent(content); - return true; - } - return false; - } - - /** - * Updates a content of the current Asset - * - * @param content a {@link Content} value which represents new content - * @return true if a content has been set without errors - */ - public boolean writeContent(Content content) - { - NodeRef assetNodeRef = AVMNodeConverter.ToNodeRef(asset.getSandboxVersion(), asset.getAvmPath()); - ContentService contentService = getSandbox().getWebproject().getWebProjects().getServiceRegistry().getContentService(); - ContentWriter writer = contentService.getWriter(assetNodeRef, ContentModel.PROP_CONTENT, true); - if ((null != writer) && (null != content)) - { - writer.setMimetype(content.getMimetype()); - writer.setEncoding(content.getEncoding()); - writer.putContent(content.getInputStream()); - return true; - } - return false; - } - - /** - * Returns textual representation of the Asset content - * - * @return content as a text - * @throws ContentIOException - * @throws IOException - */ - public String getContent() throws ContentIOException, IOException - { - NodeRef assetNodeRef = AVMNodeConverter.ToNodeRef(asset.getSandboxVersion(), asset.getAvmPath()); - ContentService contentService = getSandbox().getWebproject().getWebProjects().getServiceRegistry().getContentService(); - ContentReader reader = contentService.getReader(assetNodeRef, ContentModel.PROP_CONTENT); - return (null != reader) ? (reader.getContentString()) : (null); - } - - /** - * Submit this asset to staging - * @param submitLabel - * @param submitComment - */ - public void submit(String submitLabel, String submitComment) - { - List items = new ArrayList(1); - items.add(this.getPath()); - getSandboxService().submitList(getSandbox().getSandboxRef(), items, submitLabel, submitComment); - } - - /** - * Delete this asset, after it has been deleted do not use this asset. - */ - public void deleteAsset() - { - getAssetService().deleteAsset(this.asset); - } - - /** - * revert this asset - */ - public void revert() - { - List items = new ArrayList(1); - items.add(this.getPath()); - getSandboxService().revertList(getSandbox().getSandboxRef(), items); - } - - /** - * Get children of this asset, returns an empty array if there are no children. - * Only folders have children. - */ - public Asset[] getChildren() - { - Asset[] ret = new Asset[0]; - if(asset.isFolder()) - { - int i = 0; - List assets = getAssetService().listAssets(getSandbox().getSandboxRef(), asset.getPath(), true); - ret = new Asset[assets.size()]; - for(AssetInfo asset : assets) - { - ret[i++]=new Asset(sandbox, asset); - } - } - return ret; - } - - /** - * create a new file with the specified properties and content. - * @param name the name of the file - * @param stringContent the content of the file. Can be null. - */ - public void createFile(String name, String stringContent) - { - ContentWriter writer = getAssetService().createFile(getSandbox().getSandboxRef(), asset.getPath(), name, null); - if(stringContent != null) - { - writer.putContent(stringContent); - } - } - - /** - * create a new folder - * @param name the name of the new folder - */ - public void createFolder(String name) - { - getAssetService().createFolder(getSandbox().getSandboxRef(), asset.getPath(), name, null); - } - - /** - * Get the parent sandbox which contains this asset - * @return the parent sandbox which contains this asset - */ - public Sandbox getSandbox() - { - return this.sandbox; - } - - /** - * @return - */ - private SandboxService getSandboxService() - { - return getSandbox().getWebproject().getWebProjects().getSandboxService(); - } - - /** - * Get the asset service - * @return the asset service - */ - private AssetService getAssetService() - { - return getSandbox().getWebproject().getWebProjects().getAssetService(); - } - - /** - * Get the asset service - * @return the asset service - */ - private NamespaceService getNamespaceService() - { - return getSandbox().getWebproject().getWebProjects().getNamespaceService(); - } - - private NodeService getNodeService() - { - return getSandbox().getWebproject().getWebProjects().getServiceRegistry().getNodeService(); - } - - private DictionaryService getDictionaryService() - { - return getSandbox().getWebproject().getWebProjects().getServiceRegistry().getDictionaryService(); - } -} diff --git a/source/java/org/alfresco/wcm/sandbox/script/Sandbox.java b/source/java/org/alfresco/wcm/sandbox/script/Sandbox.java deleted file mode 100644 index 8944780805..0000000000 --- a/source/java/org/alfresco/wcm/sandbox/script/Sandbox.java +++ /dev/null @@ -1,349 +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 . - */ -package org.alfresco.wcm.sandbox.script; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.springframework.extensions.surf.util.ISO8601DateFormat; -import org.alfresco.wcm.asset.AssetInfo; -import org.alfresco.wcm.asset.AssetService; -import org.alfresco.wcm.sandbox.SandboxInfo; -import org.alfresco.wcm.sandbox.SandboxConstants; -import org.alfresco.wcm.sandbox.SandboxService; -import org.alfresco.wcm.webproject.script.WebProject; - -/** - * Sandbox object to expose via JavaScript - * - * Provides access to the sandbox metadata and its collection of assets. - * - * @author mrogers - * - */ -public class Sandbox implements Serializable -{ - /** - * serial version id - */ - private static final long serialVersionUID = -9176488061624800911L; - - private SandboxInfo si; - private WebProject webproject; - - /* - * Constructor from a SandboxInfo - */ - public Sandbox(WebProject webproject, SandboxInfo si) - { - this.webproject = webproject; - this.si = si; - } - - public void setName(String name) - { - // read only - } - - /** - * Display name for the sandbox - * @return the name of the sandbox - */ - public String getName() - { - return si.getName(); - } - - /** - * Set the unique reference for this sandbox - no-op, read only - * @param sandboxRef - */ - public void setSandboxRef(String sandboxRef) - { - // read only - } - - /** - * Submit the modified contents of this sandbox - */ - public void submitAll(String submitLabel, String submitComment) - { - getSandboxService().submitAll(getSandboxRef(), submitLabel, submitComment); - } - - /** - * Revert the specified assets (files and directories) modified contents of this sandbox - */ - public void revertAssets(Asset[] files) - { - List items = new ArrayList(files.length); - - for(int i = 0; i < files.length; i++) - { - items.add(i, files[i].getPath()); - } - - getSandboxService().revertList(getSandboxRef(), items); - } - - /** - * Revert the specified files and directories modified contents of this sandbox - */ - public void revert(String[] files) - { - List items = new ArrayList(files.length); - - for(int i = 0; i < files.length; i++) - { - items.add(i, files[i]); - } - - getSandboxService().revertList(getSandboxRef(), items); - } - - /** - * Submit the specified assets (files and directories) modified contents of this sandbox - */ - public void submitAssets(Asset[] files, String submitLabel, String submitComment) - { - List items = new ArrayList(files.length); - - for(int i = 0; i < files.length; i++) - { - items.add(i, files[i].getPath()); - } - - getSandboxService().submitList(getSandboxRef(), items, submitLabel, submitComment); - } - - /** - * Submit the specified files and directories modified contents of this sandbox - */ - public void submit(String[] files, String submitLabel, String submitComment) - { - List items = new ArrayList(files.length); - - for(int i = 0; i < files.length; i++) - { - items.add(i, files[i]); - } - - getSandboxService().submitList(getSandboxRef(), items, submitLabel, submitComment); - } - - /** - * Submit the modified contents of the webapp within this sandbox - */ - public void submitAllWebApp(String webApp, String submitLabel, String submitComment) - { - getSandboxService().submitWebApp(getSandboxRef(), webApp, submitLabel, submitComment); - } - - /** - * Revert all modified contents within this sandbox - */ - public void revertAll() - { - getSandboxService().revertAll(getSandboxRef()); - } - - /** - * Revert all modified contents within this sandbox - */ - public void revertAllWebApp(String webApp) - { - getSandboxService().revertWebApp(getSandboxRef(), webApp); - } - -// /** -// * Get the snapshots, Version Descriptors -// * @param includeSystemGenerated -// */ -// public void getSnapshots(boolean includeSystemGenerated) -// { -// //TODO - What is returned? -// getSandboxService().listSnapshots(getSandboxRef(), includeSystemGenerated); -// } - - /** - * Get the unique reference for this sandbox - */ - public String getSandboxRef() - { - return si.getSandboxId(); - } - - public String getCreator() - { - return si.getCreator(); - } - - public Date getCreatedDate() - { - return si.getCreatedDate(); - } - - public String getCreatedDateAsISO8601() - { - return ISO8601DateFormat.format(si.getCreatedDate()); - } - - /** - * Delete this sandbox - */ - public void deleteSandbox() - { - getSandboxService().deleteSandbox(getSandboxRef()); - } - - /* - * Save the updates to this sandbox - */ - public void save() - { - // no read-write params yet ... - } - - /** - * Get the store names - * @return the list of store names with the "main" store first. - */ - public String[] getStoreNames() - { - return si.getStoreNames(); - } - - /** - * Is this an author sandbox ? - * @return is this an author sandbox - */ - public boolean isAuthorSandbox() - { - return si.getSandboxType().equals(SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN); - } - - /** - * Is this a staging sandbox ? - * @return is this an author sandbox - */ - public boolean isStagingSandbox() - { - return si.getSandboxType().equals(SandboxConstants.PROP_SANDBOX_STAGING_MAIN); - } - - - /** - * Get the modified assets within this sandbox - * @return the list of changed assets - */ - public Asset[] getModifiedAssets() - { - List items = getSandboxService().listChangedAll(getSandboxRef(), true); - Asset[] ret = new Asset[items.size()]; - - int i = 0; - for(AssetInfo item : items) - { - ret[i++] = new Asset(this, item); - } - return ret; - } - - /** - * Get the specified asset (Either folder or file) - * @param path the full path e.g. /www/web_apps/ROOT/index.html - * @return the asset or null if it does not exist - */ - public Asset getAsset(String path) - { - AssetService as = getAssetService(); - AssetInfo item = as.getAsset(getSandboxRef(), path); - if (item != null) - { - Asset newAsset = new Asset(this, item); - return newAsset; - } - return null; - } - - /** - * Get the specified asset with a path relative to the specified web app. - * @param path e.g. index.html - * @param webApp e.g. ROOT - * @return the asset or null if it does not exist - */ - public Asset getAssetWebApp(String webApp, String path) - { - AssetService as = getAssetService(); - AssetInfo item = as.getAssetWebApp(getSandboxRef(), webApp, path); - if (item != null) - { - Asset newAsset = new Asset(this, item); - return newAsset; - } - return null; - - } - - /** - * Get the modified assets within this sandbox - * @return the list of changed assets - */ - public Asset[] getModifiedAssetsWebApp(String webApp) - { - List items = getSandboxService().listChangedWebApp(getSandboxRef(), webApp, true); - Asset[] ret = new Asset[items.size()]; - - int i = 0; - for(AssetInfo item : items) - { - ret[i++] = new Asset(this, item); - } - return ret; - } - - /** - * Get the web project that owns this sandbox - * @return the web project - */ - public WebProject getWebproject() - { - return this.webproject; - } - - /** - * Get the sandbox service - * @return the sandbox service - */ - private SandboxService getSandboxService() - { - return webproject.getWebProjects().getSandboxService(); - } - - /** - * Get the asset service - * @return the asset service - */ - private AssetService getAssetService() - { - return webproject.getWebProjects().getAssetService(); - } -} diff --git a/source/java/org/alfresco/wcm/util/WCMUtil.java b/source/java/org/alfresco/wcm/util/WCMUtil.java deleted file mode 100644 index 79a6cdfa99..0000000000 --- a/source/java/org/alfresco/wcm/util/WCMUtil.java +++ /dev/null @@ -1,895 +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 . - */ -package org.alfresco.wcm.util; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.alfresco.config.JNDIConstants; -import org.alfresco.mbeans.VirtServerRegistry; -import org.alfresco.model.WCMAppModel; -import org.alfresco.repo.avm.actions.AVMDeployWebsiteAction; -import org.alfresco.repo.avm.util.AVMUtil; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.service.cmr.avm.AVMNotFoundException; -import org.alfresco.service.cmr.avm.AVMService; -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.NodeService; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.FileNameValidator; -import org.alfresco.util.VirtServerUtils; -import org.alfresco.wcm.sandbox.SandboxConstants; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.ParameterCheck; - -/** - * Helper methods and constants related to WCM directories, paths and store name manipulation. - * - * @author Ariel Backenroth, Kevin Roast, janv - */ -public class WCMUtil extends AVMUtil -{ - private static Log logger = LogFactory.getLog(WCMUtil.class); - - /** - * Extracts the sandbox store id from the avm path - * - * @param avmPath an absolute avm path - * - * @return the sandbox store id - */ - public static String getSandboxStoreId(final String avmPath) - { - return getStoreName(avmPath); - } - - /** - * Extracts the web project store id from the (sandbox) store name - *

- * For example, if the (sandbox) store name is: teststore--admin then the web project store id is: teststore - *

- * Note: Although the staging sandbox store name is currently equivalent to the web project store id, it should - * be derived using 'buildStagingStoreName'. - * - * @param storeName the sandbox store id - * - * @return the web project store id - */ - public static String getWebProjectStoreId(final String storeName) - { - final int index = storeName.indexOf(WCMUtil.STORE_SEPARATOR); - return (index == -1 - ? storeName - : storeName.substring(0, index)); - } - - /** - * Extracts the web project store id from the avm path - * - * For example, if the avm path is: teststore--admin:/www/ROOT then the web project id is: teststore - * - * @param avmPath an absolute avm path - * - * @return the web project store id. - */ - public static String getWebProjectStoreIdFromPath(final String avmPath) - { - return getWebProjectStoreId(getStoreName(avmPath)); - } - - /** - * Indicates whether the store name describes a preview store. - * - * @param storeName the store name - * - * @return true if the store is a preview store, false otherwise. - */ - protected static boolean isPreviewStore(final String storeName) - { - return ((storeName != null) && (storeName.endsWith(WCMUtil.STORE_SEPARATOR + WCMUtil.STORE_PREVIEW))); - } - - - /** - * http://wiki.alfresco.com/wiki/WCM_Deployment_Features#Debugging_.26_Testing - * - * Examples of locally deployed store names for web project "MyWebProj" are: - * - * MyWebProjlive - * MyWebProj--adminlive - * - * Note: if web project "MyWebProjlive" is pre-created then should be possible to browse staging: - * - * http://wiki.alfresco.com/wiki/WCM_Deployment_Features#Deployed_Runtime - * - * @param storeName - * @return - */ - protected static boolean isLocalhostDeployedStore(String wpStoreId, String storeName) - { - return ((storeName.startsWith(wpStoreId)) && - (storeName.endsWith(AVMDeployWebsiteAction.LIVE_SUFFIX)) && - (! wpStoreId.endsWith(AVMDeployWebsiteAction.LIVE_SUFFIX))); - } - - /** - * Indicates whether the store name describes a workflow store. - * - * @param storeName the store name - * - * @return true if the store is a workflow store, false otherwise. - */ - protected static boolean isWorkflowStore(String storeName) - { - if (WCMUtil.isPreviewStore(storeName)) - { - storeName = WCMUtil.getCorrespondingMainStoreName(storeName); - } - - return ((storeName != null) && (storeName.indexOf(STORE_SEPARATOR + STORE_WORKFLOW) != -1)); - } - - /** - * Indicates whether the store name describes a user store. - * - * @param storeName the store name - * - * @return true if the store is a user store, false otherwise. - */ - public static boolean isUserStore(String storeName) - { - if (WCMUtil.isPreviewStore(storeName)) - { - storeName = WCMUtil.getCorrespondingMainStoreName(storeName); - } - return ((storeName != null) && (storeName.indexOf(WCMUtil.STORE_SEPARATOR) != -1)); - } - - /** - * Indicates whether the store name describes a staging store. - * - * @param storeName the store name - * - * @return true if the store is a main store, false otherwise. - */ - public static boolean isStagingStore(String storeName) - { - return ((storeName != null) && (storeName.indexOf(WCMUtil.STORE_SEPARATOR) == -1)); - } - - /** - * Extracts the username from the store name. - * - * @param storeName the store name - * - * @return the username associated or null if this is a staging store. - */ - public static String getUserName(String storeName) - { - if (WCMUtil.isPreviewStore(storeName)) - { - storeName = WCMUtil.getCorrespondingMainStoreName(storeName); - } - final int index = storeName.indexOf(WCMUtil.STORE_SEPARATOR); - return (index == -1 ? null : unescapeStoreNameComponent(storeName.substring(index - + WCMUtil.STORE_SEPARATOR.length()))); - } - - /** - * Extracts the workflow id - * - * @param storeName - * @return - */ - public static String getWorkflowId(String storeName) - { - if (WCMUtil.isPreviewStore(storeName)) - { - storeName = WCMUtil.getCorrespondingMainStoreName(storeName); - } - final int index = storeName.indexOf(STORE_SEPARATOR + STORE_WORKFLOW); - return (index == -1 - ? null - : storeName.substring(index + WCMUtil.STORE_SEPARATOR.length())); - } - - /** - * Returns the corresponding main store name if this is a preview store name. - * - * @param storeName the preview store name. - * - * @return the corresponding main store name. - * - * @exception IllegalArgumentException if this is not a preview store name. - */ - protected static String getCorrespondingMainStoreName(final String storeName) - { - if (!WCMUtil.isPreviewStore(storeName)) - { - throw new IllegalArgumentException("store " + storeName + " is not a preview store"); - } - return storeName.substring(0, - (storeName.length() - - (WCMUtil.STORE_SEPARATOR + WCMUtil.STORE_PREVIEW).length())); - } - - /** - * Returns the corresponding preview store name if this is a main store name. - * - * @param storeName the main store name. - * - * @return the corresponding preview store name. - * - * @exception IllegalArgumentException if this is not a main store name. - */ - protected static String getCorrespondingPreviewStoreName(final String storeName) - { - if (WCMUtil.isPreviewStore(storeName)) - { - throw new IllegalArgumentException("store " + storeName + " is already a preview store"); - } - return storeName + WCMUtil.STORE_SEPARATOR + WCMUtil.STORE_PREVIEW; - } - - /** - * Returns the corresponding path in the main store name if this is a path in - * a preview store. - * - * @param avmPath an avm path within the main store. - * - * @return the corresponding path within the preview store. - * - * @exception IllegalArgumentException if this is not a path within the preview store. - */ - protected static String getCorrespondingPathInMainStore(final String avmPath) - { - String storeName = getStoreName(avmPath); - storeName = WCMUtil.getCorrespondingMainStoreName(storeName); - return WCMUtil.getCorrespondingPath(avmPath, storeName); - } - - /** - * Returns the corresponding path in the preview store name if this is a path in - * a main store. - * - * @param avmPath an avm path within the main store. - * - * @return the corresponding path within the preview store. - * - * @exception IllegalArgumentException if this is not a path within the preview store. - */ - protected static String getCorrespondingPathInPreviewStore(final String avmPath) - { - String storeName = getStoreName(avmPath); - storeName = WCMUtil.getCorrespondingPreviewStoreName(storeName); - return WCMUtil.getCorrespondingPath(avmPath, storeName); - } - - /** - * Returns the corresponding path in the store provided. - * - * @param avmPath an avm path - * @param otherStore the other store name to return the corresponding path for - * - * @return the corresponding path within the supplied store - */ - public static String getCorrespondingPath(final String avmPath, final String otherStoreName) - { - return (buildAVMPath(otherStoreName, WCMUtil.getStoreRelativePath(avmPath))); - } - - /** - * Utility function for escaping part of a compound store name (delimited by STORE_SEPARATOR sequences). Uses ISO - * 9075 style encoding to escape otherwise problematic character sequences. - * - * @param component - * the component - * @return the escaped string - */ - public static final String escapeStoreNameComponent(String component) - { - StringBuilder builder = null; - int length = component.length(); - // If the component matches one of the common suffixes, encode it - if (component.equals(STORE_PREVIEW) || component.equals(STORE_WORKFLOW)) - { - builder = new StringBuilder(length + 5); - appendEncoded(builder, component); - return builder.toString(); - } - - // Look for problematic character sequences - Matcher matcher = PATTERN_ILLEGAL_SEQUENCE.matcher(component); - int lastAppendPosition = 0; - while (matcher.find()) - { - if (builder == null) - { - builder = new StringBuilder(length + 5); - } - if (matcher.start() != lastAppendPosition) - { - builder.append(component, lastAppendPosition, matcher.start()); - } - lastAppendPosition = matcher.end(); - appendEncoded(builder, matcher.group()); - } - if (builder == null) - { - return component; - } - if (lastAppendPosition < length) - { - builder.append(component, lastAppendPosition, length); - } - - return builder.toString(); - } - - /** - * Utility function for decoding from Strings produced by the above method. - * - * @param component - * the encoded component - * @return the decoded component - */ - private static String unescapeStoreNameComponent(String component) - { - StringBuilder builder = null; - int length = component.length(); - int lastAppendPosition = 0; - int escapeIndex; - while ((escapeIndex = component.indexOf("-x", lastAppendPosition)) != -1) - { - if (builder == null) - { - builder = new StringBuilder(length + 5); - } - if (escapeIndex != lastAppendPosition) - { - builder.append(component, lastAppendPosition, escapeIndex); - } - lastAppendPosition = component.indexOf('-', escapeIndex + 2); - builder.appendCodePoint(Integer.parseInt(component.substring(escapeIndex + 2, lastAppendPosition), 16)); - lastAppendPosition++; - } - if (builder == null) - { - return component; - } - if (lastAppendPosition < length) - { - builder.append(component, lastAppendPosition, length); - } - - return builder.toString(); - } - - private static final void appendEncoded(StringBuilder builder, String sequence) - { - builder.append("-x").append(Integer.toString(sequence.codePointAt(0), 16).toUpperCase()).append("-"); - int length = sequence.length(); - int next = sequence.offsetByCodePoints(0, 1); - if (next < length) - { - builder.append(sequence, next, length); - } - } - - /** - * Returns the main staging store name for the specified web project - * - * @param wpStoreId web project store id to build staging store name for - * @return String main staging store name for the specified web project store id - */ - public static String buildStagingStoreName(final String wpStoreId) - { - ParameterCheck.mandatoryString("wpStoreId", wpStoreId); - return wpStoreId; - } - - /** - * Returns the preview store name for the specified store id. - * - * @param storeId store id to build preview store name for - * - * @return preview store name for the specified store id - */ - protected static String buildStagingPreviewStoreName(final String storeId) - { - return (WCMUtil.buildStagingStoreName(storeId) + WCMUtil.STORE_SEPARATOR + - WCMUtil.STORE_PREVIEW); - } - - /** - * Returns the user's main store name for a specific username - * - * @param storeId store id to build user store name for - * @param username of the user to build store name for - * - * @return the main store for the specified user and store id - */ - public static String buildUserMainStoreName(final String storeId, - final String userName) - { - ParameterCheck.mandatoryString("userName", userName); - String fixedUserName = escapeStoreNameComponent(userName); - return (WCMUtil.buildStagingStoreName(storeId) + WCMUtil.STORE_SEPARATOR + - fixedUserName); - } - - /** - * Returns the preview store name for a specific username. - * - * @param storeId store id to build user preview store name for - * @param username of the user to build preview store name for - * - * @return the preview store for the specified user and store id - */ - protected static String buildUserPreviewStoreName(final String storeId, - final String username) - { - return (WCMUtil.buildUserMainStoreName(storeId, username) + WCMUtil.STORE_SEPARATOR + - WCMUtil.STORE_PREVIEW); - } - - /** - * Returns the store name for a specific workflow Id. - * - * @param storeId store id to build workflow store name for - * @param workflowId of the user to build workflow store name for - * - * @return the store for the specified workflow and store ids - */ - protected static String buildWorkflowMainStoreName(final String storeId, - final String workflowId) - { - ParameterCheck.mandatoryString("workflowId", workflowId); - return (WCMUtil.buildStagingStoreName(storeId) + WCMUtil.STORE_SEPARATOR + - workflowId); - } - - /** - * Returns the preview store name for a specific workflow Id. - * - * @param storeId store id to build preview workflow store name for - * @param workflowId of the user to build preview workflow store name for - * - * @return the store for the specified preview workflow and store ids - */ - protected static String buildWorkflowPreviewStoreName(final String storeId, - final String workflowId) - { - return (WCMUtil.buildWorkflowMainStoreName(storeId, workflowId) + - WCMUtil.STORE_SEPARATOR + WCMUtil.STORE_PREVIEW); - } - - /** - * Returns the root path for the specified store name - * - * eg. mystore -> mystore:/www - * - * @param storeName store to build root path for - * - * @return root path for the specified store name - */ - public static String buildStoreRootPath(final String storeName) - { - ParameterCheck.mandatoryString("storeName", storeName); - return buildAVMPath(storeName, AVM_PATH_SEPARATOR_CHAR + JNDIConstants.DIR_DEFAULT_WWW); - } - - /** - * Returns the root path for the specified sandbox name - * - * * eg. mystore -> mystore:/www/avm_webapps - * - * @param storeName store to build root sandbox path for - * - * @return root sandbox path for the specified store name - */ - public static String buildSandboxRootPath(final String storeName) - { - ParameterCheck.mandatoryString("storeName", storeName); - return buildAVMPath(storeName, JNDIConstants.DIR_DEFAULT_WWW_APPBASE); - } - - /** - * Returns the root webapp path for the specified store and webapp name - * - * @param storeName store to build root webapp path for - * @param webapp webapp folder name - * - * @return the root webapp path for the specified store and webapp name - */ - public static String buildStoreWebappPath(final String storeName, String webApp) - { - ParameterCheck.mandatoryString("webApp", webApp); - return WCMUtil.buildSandboxRootPath(storeName) + AVM_PATH_SEPARATOR_CHAR + webApp; - } - - public static String lookupStoreDNS(AVMService avmService, String store) - { - ParameterCheck.mandatoryString("store", store); - - final Map props = - avmService.queryStorePropertyKey(store, QName.createQName(null, SandboxConstants.PROP_DNS + '%')); - - return (props.size() == 1 - ? props.keySet().iterator().next().getLocalName().substring(SandboxConstants.PROP_DNS.length()) - : null); - } - - public static NodeRef getWebProjectNodeFromWebProjectStore(AVMService avmService, String wpStoreId) - { - NodeRef wpNodeRef = null; - - String stagingStoreId = wpStoreId; // note: equivalent to WCMUtil.buildStagingStoreName(wpStoreId) - - try - { - PropertyValue pValue = avmService.getStoreProperty(stagingStoreId, SandboxConstants.PROP_WEB_PROJECT_NODE_REF); - - if (pValue != null) - { - wpNodeRef = (NodeRef)pValue.getValue(DataTypeDefinition.NODE_REF); - } - } - catch (AVMNotFoundException nfe) - { - logger.warn(wpStoreId + " is not a web project: " + nfe); - } - - return wpNodeRef; - } - - /** - * Returns web project store id for an AVM store name (or null for vanilla AVM store) - */ - public static String getWebProject(AVMService avmService, String avmStoreName) - { - String wpStoreId = WCMUtil.getWebProjectStoreId(avmStoreName); - if (WCMUtil.getWebProjectNodeFromWebProjectStore(avmService, wpStoreId) != null) - { - return wpStoreId; - } - return null; - } - - /** - * Converts the provided path to an absolute path within the avm. - * - * @param parentAVMPath used as the parent path if the provided path - * is relative, otherwise used to extract the parent path portion up until - * the webapp directory. - * @param path a path relative to the parentAVMPath path, or if it is - * absolute, it is relative to the sandbox used in the parentAVMPath. - * - * @return an absolute path within the avm using the paths provided. - */ - /* - protected static String buildPath(final String parentAVMPath, - final String path, - final PathRelation relation) - { - String parent = parentAVMPath; - if (path == null || path.length() == 0 || ".".equals(path) || "./".equals(path)) - { - return parent; - } - - if (path.charAt(0) == AVM_PATH_SEPARATOR_CHAR) - { - final Matcher m = relation.pattern().matcher(parent); - if (m.matches()) - { - parent = m.group(1); - } - } - else if (parent.charAt(parent.length() - 1) != AVM_PATH_SEPARATOR_CHAR) - { - parent = parent + AVM_PATH_SEPARATOR_CHAR; - } - - return parent + path; - } - */ - - /** - * Returns a path relative to the store portion of the avm path. - * - * @param absoluteAVMPath an absolute path within the avm - * @return the path without the store prefix. - */ - public static String getStoreRelativePath(final String absoluteAVMPath) - { - ParameterCheck.mandatoryString("absoluteAVMPath", absoluteAVMPath); - return AVMUtil.splitPath(absoluteAVMPath)[1]; - } - - /** - * Returns a path relative to the webapp portion of the avm path. - * - * @param absoluteAVMPath an absolute path within the avm - * @return a relative path within the webapp. - */ - protected static String getWebappRelativePath(final String absoluteAVMPath) - { - final Matcher m = WEBAPP_RELATIVE_PATH_PATTERN.matcher(absoluteAVMPath); - return m.matches() && m.group(3).length() != 0 ? m.group(3) : AVM_PATH_SEPARATOR; - } - - /** - * Returns the webapp within the path - * - * @param absoluteAVMPath the path from which to extract the webapp name - * - * @return an the webapp name contained within the path or null. - */ - public static String getWebapp(final String absoluteAVMPath) - { - final Matcher m = WEBAPP_RELATIVE_PATH_PATTERN.matcher(absoluteAVMPath); - return m.matches() && m.group(2).length() != 0 ? m.group(2) : null; - } - - /** - * Returns the path portion up the webapp - * - * @param absoluteAVMPath the path from which to extract the webapp path - * - * @return an absolute avm path to the webapp contained within - * the path or null. - */ - protected static String getWebappPath(final String absoluteAVMPath) - { - final Matcher m = WEBAPP_RELATIVE_PATH_PATTERN.matcher(absoluteAVMPath); - return m.matches() && m.group(1).length() != 0 ? m.group(1) : null; - } - - /** - * Returns a path relative to the sandbox porition of the avm path. - * - * @param absoluteAVMPath an absolute path within the avm - * @return a relative path within the sandbox. - */ - protected static String getSandboxRelativePath(final String absoluteAVMPath) - { - final Matcher m = SANDBOX_RELATIVE_PATH_PATTERN.matcher(absoluteAVMPath); - return m.matches() && m.group(2).length() != 0 ? m.group(2) : AVM_PATH_SEPARATOR; - } - - /** - * Returns the path portion up the sandbox - * - * @param absoluteAVMPath the path from which to extract the sandbox path - * - * @return an absolute avm path to the sandbox contained within - * the path or null. - */ - protected static String getSandboxPath(final String absoluteAVMPath) - { - final Matcher m = SANDBOX_RELATIVE_PATH_PATTERN.matcher(absoluteAVMPath); - return m.matches() && m.group(1).length() != 0 ? m.group(1) : null; - } - - protected static Map listWebUsers(NodeService nodeService, NodeRef wpNodeRef) - { - List userInfoRefs = listWebUserRefs(nodeService, wpNodeRef, true); - - Map webUsers = new HashMap(23); - - for (ChildAssociationRef ref : userInfoRefs) - { - NodeRef userInfoRef = ref.getChildRef(); - String userName = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME); - String userRole = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE); - - webUsers.put(userName, userRole); - } - - return webUsers; - } - - protected static List listWebUserRefs(NodeService nodeService, NodeRef wpNodeRef, boolean preLoad) - { - return nodeService.getChildAssocs(wpNodeRef, WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL, preLoad); - } - - /** - * Creates all directories for a path if they do not already exist. - */ - /* - protected static void makeAllDirectories(AVMService avmService, final String avmDirectoryPath) - { - // LOGGER.debug("mkdir -p " + avmDirectoryPath); - String s = avmDirectoryPath; - final Stack dirNames = new Stack(); - while (s != null) - { - try - { - if (avmService.lookup(-1, s) != null) - { - // LOGGER.debug("path " + s + " exists"); - break; - } - } - catch (AVMNotFoundException avmfe) - { - } - final String[] sb = AVMNodeConverter.SplitBase(s); - s = sb[0]; - // LOGGER.debug("pushing " + sb[1]); - dirNames.push(sb); - } - - while (!dirNames.isEmpty()) - { - final String[] sb = dirNames.pop(); - // LOGGER.debug("creating " + sb[1] + " in " + sb[0]); - avmService.createDirectory(sb[0], sb[1]); - } - } - */ - - /** - * Update notification on the virtualisation server webapp as required for the specified path - * - * @param path Path to match against - * @param force True to force update of server even if path does not match - */ - public static void updateVServerWebapp(VirtServerRegistry vServerRegistry, String path, boolean force) - { - if (force || VirtServerUtils.requiresUpdateNotification(path)) - { - final int webappIndex = path.indexOf(AVM_PATH_SEPARATOR_CHAR, - path.indexOf(JNDIConstants.DIR_DEFAULT_APPBASE) + - JNDIConstants.DIR_DEFAULT_APPBASE.length() + 1); - - if (webappIndex != -1) - { - path = path.substring(0, webappIndex); - } - vServerRegistry.updateWebapp(-1, path, true); - } - } - - /** - * Removal notification on all the virtualisation server webapp as required by the specified path - * - * @param path Path to match against - * @param force True to force update of server even if path does not match - */ - protected static void removeAllVServerWebapps(VirtServerRegistry vServerRegistry, String path, boolean force) - { - if (force || VirtServerUtils.requiresUpdateNotification(path)) - { - final int webappIndex = path.indexOf(AVM_PATH_SEPARATOR_CHAR, - path.indexOf(JNDIConstants.DIR_DEFAULT_APPBASE) + - JNDIConstants.DIR_DEFAULT_APPBASE.length() + 1); - - if (webappIndex != -1) - { - path = path.substring(0, webappIndex); - } - vServerRegistry.removeAllWebapps(-1, path, true); - } - } - - /** - * Removal notification on the virtualisation server webapp as required for the specified path - * - * @param path Path to match against - * @param force True to force update of server even if path does not match - */ - protected static void removeVServerWebapp(VirtServerRegistry vServerRegistry, String path, boolean force) - { - if (force || VirtServerUtils.requiresUpdateNotification(path)) - { - final int webappIndex = path.indexOf(AVM_PATH_SEPARATOR_CHAR, - path.indexOf(JNDIConstants.DIR_DEFAULT_APPBASE) + - JNDIConstants.DIR_DEFAULT_APPBASE.length() + 1); - - if (webappIndex != -1) - { - path = path.substring(0, webappIndex); - } - vServerRegistry.removeWebapp(-1, path, true); - } - } - - // return common web app or null if paths span multiple web apps (or no web app) - public static String getCommonWebApp(String sbStoreId, List storeRelativePaths) - { - String derivedWebApp = null; - boolean multiWebAppsFound = false; - - for (String storeRelativePath : storeRelativePaths) - { - // Example srcPath: - // mysite--alice:/www/avm_webapps/ROOT/foo.txt - String srcPath = WCMUtil.buildAVMPath(sbStoreId, storeRelativePath); - - // TODO - don't really need the sbStoreId - // derive webapp for now - String srcWebApp = WCMUtil.getWebapp(srcPath); - if (srcWebApp != null) - { - if (derivedWebApp == null) - { - derivedWebApp = srcWebApp; - } - else if (! derivedWebApp.equals(srcWebApp)) - { - multiWebAppsFound = true; - } - } - } - - return (multiWebAppsFound == false ? derivedWebApp : null); - } - - // Component Separator. - protected static final String STORE_SEPARATOR = "--"; - - /** - * Matches character sequences that must be escaped in a compound store name. We disallow non-ASCII characters due to - * Tomcat 5.5's insistence on URL decoding paths with the JVM default charset (not necessarily UTF-8) - */ - protected static final Pattern PATTERN_ILLEGAL_SEQUENCE = Pattern.compile(FileNameValidator.FILENAME_ILLEGAL_REGEX - + "|[^\\p{ASCII}]|-x|" + STORE_SEPARATOR); - - // names of the stores representing the layers for an AVM website - //XXXarielb this should be private - protected final static String STORE_WORKFLOW = "workflow"; - protected final static String STORE_PREVIEW = "preview"; - - // servlet default webapp - // Note: this webapp is mapped to the URL path "" - public final static String DIR_ROOT = "ROOT"; - - protected final static String SPACE_ICON_WEBSITE = "space-icon-website"; - - // Locking constants - public static final String LOCK_KEY_STORE_NAME = "avm-store-name"; - - // web user role permissions - public static final String ROLE_CONTENT_MANAGER = PermissionService.WCM_CONTENT_MANAGER; - public static final String ROLE_CONTENT_PUBLISHER = PermissionService.WCM_CONTENT_PUBLISHER; - public static final String ROLE_CONTENT_CONTRIBUTOR = PermissionService.WCM_CONTENT_CONTRIBUTOR; - public static final String ROLE_CONTENT_REVIEWER = PermissionService.WCM_CONTENT_REVIEWER; - - private final static Pattern WEBAPP_RELATIVE_PATH_PATTERN = - Pattern.compile("([^:]+:/" + JNDIConstants.DIR_DEFAULT_WWW + - AVM_PATH_SEPARATOR + JNDIConstants.DIR_DEFAULT_APPBASE + "/([^/]+))(.*)"); - - private final static Pattern SANDBOX_RELATIVE_PATH_PATTERN = - Pattern.compile("([^:]+:/" + JNDIConstants.DIR_DEFAULT_WWW + - AVM_PATH_SEPARATOR + JNDIConstants.DIR_DEFAULT_APPBASE + ")(.*)"); - - public static final String WORKFLOW_SUBMITDIRECT_NAME = "wcmwf:submitdirect"; -} diff --git a/source/java/org/alfresco/wcm/util/WCMWorkflowUtil.java b/source/java/org/alfresco/wcm/util/WCMWorkflowUtil.java deleted file mode 100644 index 77d04a2bdd..0000000000 --- a/source/java/org/alfresco/wcm/util/WCMWorkflowUtil.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (C) 2005-2012 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 . - */ -package org.alfresco.wcm.util; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; - -import org.alfresco.model.WCMWorkflowModel; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.workflow.WorkflowModel; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMNotFoundException; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.avm.LayeringDescriptor; -import org.alfresco.service.cmr.avmsync.AVMDifference; -import org.alfresco.service.cmr.avmsync.AVMSyncService; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.workflow.WorkflowService; -import org.alfresco.service.cmr.workflow.WorkflowTask; -import org.alfresco.service.cmr.workflow.WorkflowTaskQuery; -import org.alfresco.service.namespace.QName; -import org.alfresco.wcm.sandbox.SandboxInfo; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * WCM Specific workflow related helper methods. - * - * @author Ariel Backenroth - * @author Kevin Roast - * @author janv - */ -public class WCMWorkflowUtil -{ - private static final Log logger = LogFactory.getLog(WCMWorkflowUtil.class); - - public static NodeRef createWorkflowPackage(WorkflowService workflowService, AVMService avmService, SandboxInfo sandboxInfo) - { - // create package paths (layered to user sandbox area as target) - final String workflowMainStoreName = sandboxInfo.getMainStoreName(); - final String packagesPath = WCMUtil.buildStoreRootPath(workflowMainStoreName); - - // convert package to workflow package - final AVMNodeDescriptor packageDesc = avmService.lookup(-1, packagesPath); - final NodeRef packageNodeRef = workflowService.createPackage(AVMNodeConverter.ToNodeRef(-1, packageDesc.getPath())); - - avmService.setNodeProperty(packagesPath, WorkflowModel.PROP_IS_SYSTEM_PACKAGE, new PropertyValue(DataTypeDefinition.BOOLEAN, true)); - - // NOTE: WCM-1019: As permissions are now implemented for AVM nodes we no longer need to set permisssions here - // as they will be inherited from the store the workflow store is layered over. - - //final ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance()); - //final PermissionService permissionService = services.getPermissionService(); - //permissionService.setPermission(packageNodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.ALL_PERMISSIONS, true); - - return packageNodeRef; - } - - public static List getAssociatedTasksForSandbox(WorkflowService workflowService, final String storeName) - { - long start = System.currentTimeMillis(); - - String fromPath = WCMUtil.buildStoreRootPath(storeName); - WorkflowTaskQuery query = new WorkflowTaskQuery(); - - HashMap props = new HashMap(1, 1.0f); - - props.put(WCMWorkflowModel.PROP_FROM_PATH, fromPath); - query.setProcessCustomProps(props); - query.setActive(true); - - List tasks = workflowService.queryTasks(query); - - if (logger.isTraceEnabled()) - { - logger.trace("getAssociatedTasksForSandbox: "+storeName+" (found "+tasks.size()+" tasks originating user sandbox "+fromPath+") in "+(System.currentTimeMillis()-start)+" msecs"); - } - - return tasks; - } - - /** - * @deprecated since 3.2 - */ - public static List getAssociatedTasksForNode(AVMService avmService, AVMNodeDescriptor node, List tasks) - { - List result = new LinkedList(); - - for (WorkflowTask task : tasks) - { - final NodeRef ref = task.path.instance.workflowPackage; - final String path = WCMUtil.getCorrespondingPath(node.getPath(), ref.getStoreRef().getIdentifier()); - - if (logger.isDebugEnabled()) - { - logger.debug("checking store " + ref.getStoreRef().getIdentifier() + - " for " + node.getPath() + " (" + path + ")"); - } - - try - { - final LayeringDescriptor ld = avmService.getLayeringInfo(-1, path); - if (!ld.isBackground()) - { - if (logger.isDebugEnabled()) - { - logger.debug(path + " is in the foreground. workflow active"); - } - - result.add(task); - } - } - catch (final AVMNotFoundException avmnfe) - { - if (logger.isDebugEnabled()) - { - logger.debug(path + " not found"); - } - } - } - - return result; - } - - /** - * @deprecated since 3.2 - */ - public static List getAssociatedTasksForNode(WorkflowService workflowService, AVMService avmService, AVMNodeDescriptor node) - { - final List tasks = getAssociatedTasksForSandbox(workflowService, WCMUtil.getSandboxStoreId(node.getPath())); - return getAssociatedTasksForNode(avmService, node, tasks); - } - - public static List getAssociatedPathsForSandbox(AVMSyncService avmSyncService, WorkflowService workflowService, String sandboxName) - { - long start = System.currentTimeMillis(); - - List tasks = getAssociatedTasksForSandbox(workflowService, sandboxName); - List storeRelativePaths = getAssociatedPathsForSandboxTasks(avmSyncService, sandboxName, tasks); - - if (logger.isDebugEnabled()) - { - logger.debug("getAssociatedPathsForSandbox: "+sandboxName+" (tasks="+tasks.size()+", paths="+storeRelativePaths.size()+") in "+(System.currentTimeMillis()-start)+" msecs"); - } - - return storeRelativePaths; - } - - private static List getAssociatedPathsForSandboxTasks(AVMSyncService avmSyncService, String sandboxName, List tasks) - { - long start = System.currentTimeMillis(); - - String stagingSandboxName = WCMUtil.buildStagingStoreName(WCMUtil.getWebProjectStoreId(sandboxName)); - List storeRelativePaths = new ArrayList(tasks.size()); - - for (WorkflowTask task : tasks) - { - final NodeRef ref = task.path.instance.workflowPackage; - - String wfPath = AVMNodeConverter.ToAVMVersionPath(ref).getSecond(); - String stagingSandboxPath = WCMUtil.getCorrespondingPath(wfPath, stagingSandboxName); - - List diffs = avmSyncService.compare(-1, wfPath, -1, stagingSandboxPath, null, true); - - for (AVMDifference diff : diffs) - { - storeRelativePaths.add(WCMUtil.getStoreRelativePath(diff.getSourcePath())); - } - } - - if (logger.isTraceEnabled()) - { - logger.trace("getAssociatedPathsForSandboxTasks: "+sandboxName+" (tasks="+tasks.size()+", paths="+storeRelativePaths.size()+") in "+(System.currentTimeMillis()-start)+" msecs"); - } - - return storeRelativePaths; - } -} diff --git a/source/java/org/alfresco/wcm/webproject/WebProjectInfo.java b/source/java/org/alfresco/wcm/webproject/WebProjectInfo.java deleted file mode 100644 index 2f11e038ba..0000000000 --- a/source/java/org/alfresco/wcm/webproject/WebProjectInfo.java +++ /dev/null @@ -1,135 +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 . - */ -package org.alfresco.wcm.webproject; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Web Project Information - * - * @author janv - */ -public interface WebProjectInfo -{ - /** - * Get the site node reference - * - * @return NodeRef site node reference, null if not set - */ - public NodeRef getNodeRef(); - - /** -  * Get the name - * - * @return String name - */ - public String getName(); - - /** - * Set the name - * - * @param name the name to set - */ - public void setName(String name); - - /** - * Get the web project store id - * - * @return the web project store id (generated from the passed DNS name) - */ - public String getStoreId(); - - /** - * Get the staging store name - * - * @return String staging store name - */ - public String getStagingStoreName(); - - /** - * Get the description - * - * @return String description - */ - public String getDescription(); - - /** - * Set the description - * - * @param description description - */ - public void setDescription(String description); - - /** - * Get the title - * - * @return the title - */ - public String getTitle(); - - /** - * Set the title - * - * @param title the title to set - */ - public void setTitle(String title); - - /** - * Get the default webapp - * - * @return the webapp name - */ - public String getDefaultWebApp(); - - /** - * Set the default webapp - * - * @param webApp the webapp name to set - */ - public void setDefaultWebApp(String defaultWebApp); - - /** - * @return true if this web project can also be used as a template - */ - public boolean isTemplate(); - - /** - * @param isTemplate set to true if this web project can also be used as a template - */ - public void setIsTemplate(boolean isTemplate); - - /** - * Get the preview URI service provider name - * - * @since 3.2 - * - * @return the preview URI service provider name - * - */ - public String getPreviewProviderName(); - - /** - * Set the preview URI service provider name - * - * @since 3.2 - * - * @param previewURIServiceProviderName the preview URI service provider name to set - */ - public void setPreviewProviderName(String previewURIServiceProviderName); -} diff --git a/source/java/org/alfresco/wcm/webproject/WebProjectInfoImpl.java b/source/java/org/alfresco/wcm/webproject/WebProjectInfoImpl.java deleted file mode 100644 index 226568fa91..0000000000 --- a/source/java/org/alfresco/wcm/webproject/WebProjectInfoImpl.java +++ /dev/null @@ -1,200 +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 . - */ -package org.alfresco.wcm.webproject; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.wcm.util.WCMUtil; - -/** - * Web Project Information - * - * @author janv - */ -public class WebProjectInfoImpl implements WebProjectInfo -{ - /** Web Project node reference */ - private NodeRef nodeRef; - - /** Web Project name */ - private String name; - - /** Web Project title */ - private String title; - - /** Web Project description */ - private String description; - - /** Web Project store id (aka DNS name) */ - private String wpStoreId; - - /** Web Project default webApp name */ - private String defaultWebApp; - - /** Web Project true if the web project can also be used as template */ - private boolean isTemplate; - - /** Web Project preview provider name (if null then default preview provider will be used) */ - private String previewURIServiceProviderName; - - /** - * Constructor - */ - public WebProjectInfoImpl(String wpStoreId, - String name, - String title, - String description, - String defaultWebApp, - boolean isTemplate, - NodeRef nodeRef, - String previewProvider) - { - this.wpStoreId = wpStoreId; - this.name = name; - this.title = title; - this.description = description; - this.defaultWebApp = defaultWebApp; - this.isTemplate = isTemplate; - this.nodeRef = nodeRef; - this.previewURIServiceProviderName = previewProvider; - } - - /** - * Get the site node reference - * - * @return NodeRef site node reference, null if not set - */ - public NodeRef getNodeRef() - { - return nodeRef; - } - - /** - * Get the name - * - * @return String name - */ - public String getName() - { - return name; - } - - /** - * @param name the name to set - */ - public void setName(String name) - { - this.name = name; - } - - /** - * @return the dnsName - */ - public String getStoreId() - { - return wpStoreId; - } - - /** - * Get the staging store name - * - * @return String staging store name - */ - public String getStagingStoreName() - { - return WCMUtil.buildStagingStoreName(getStoreId()); - } - - /** - * Get the description - * - * @return String description - */ - public String getDescription() - { - return description; - } - - /** - * Set the description - * - * @param description description - */ - public void setDescription(String description) - { - this.description = description; - } - - /** - * @return the title - */ - public String getTitle() - { - return title; - } - - /** - * @param title the title to set - */ - public void setTitle(String title) - { - this.title = title; - } - - /** - * @return the webApp - */ - public String getDefaultWebApp() - { - return defaultWebApp; - } - - /** - * @param webApp the webApp to set - */ - public void setDefaultWebApp(String defaultWebApp) - { - this.defaultWebApp = defaultWebApp; - } - - /** - * @return the useAsTemplate - */ - public boolean isTemplate() - { - return isTemplate; - } - - /** - * @param isTemplate the isTemplate to set - */ - public void setIsTemplate(boolean isTemplate) - { - this.isTemplate = isTemplate; - } - - public String getPreviewProviderName() - { - return previewURIServiceProviderName; - } - - public void setPreviewProviderName(String previewURIServiceProviderName) - { - this.previewURIServiceProviderName = previewURIServiceProviderName; - } -} diff --git a/source/java/org/alfresco/wcm/webproject/WebProjectService.java b/source/java/org/alfresco/wcm/webproject/WebProjectService.java deleted file mode 100644 index 03de704e16..0000000000 --- a/source/java/org/alfresco/wcm/webproject/WebProjectService.java +++ /dev/null @@ -1,563 +0,0 @@ -/* - * Copyright (C) 2005-2011 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 . - */ -package org.alfresco.wcm.webproject; - -import java.util.List; -import java.util.Map; - -import org.alfresco.service.PublicService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.Auditable; -import org.alfresco.service.NotAuditable; - - -/** - * Web Project Service fundamental API. - *

- * This service API is designed to support the public facing Web Project APIs. - * - * @author janv - */ -public interface WebProjectService -{ - // - // Web project operations - // - - /** - * Create a new web project (with a default ROOT webapp) - *

- * Note: the DNS name will be used to generate the web project store id, which can be subsequently retrieved via WebProjectInfo.getStoreId() - * - * @param dnsName DNS name (required, must be unique) - * @param name name (required, must be unique) - * @param title title - * @param description description - * @return WebProjectInfo the created web project info - */ - @NotAuditable - public WebProjectInfo createWebProject(String dnsName, String name, String title, String description); - - /** - * Create a new web project (with a default ROOT webapp) - *

- * Note: the DNS name will be used to generate the web project store id, which can be subsequently retrieved via WebProjectInfo.getStoreId() - * - * @param dnsName DNS name (required, must be unique) - * @param name name (required, must be unique) - * @param title title - * @param description description - * @param sourceNodeRef web project node ref to branch from (can be null) - * @return WebProjectInfo the created web project info - * - * @deprecated see createWebProject(String dnsName, WebProjectInfo wpInfo) - */ - @NotAuditable - public WebProjectInfo createWebProject(String dnsName, String name, String title, String description, NodeRef sourceNodeRef); - - /** - * Create a new web project (with given default web app) - *

- * Note: the DNS name will be used to generate the web project store id, which can be subsequently retrieved via WebProjectInfo.getStoreId() - * - * @param dnsName DNS name (required, must be unique) - * @param name name (required, must be unique) - * @param title title - * @param description description - * @param defaultWebApp default webapp (if null, will default to ROOT webapp) - * @param useAsTemplate true if this web project can be used as a template to branch from - * @param sourceNodeRef web project node ref to branch from (can be null) - * @return WebProjectInfo the created web project info - */ - @NotAuditable - public WebProjectInfo createWebProject(String dnsName, String name, String title, String description, String defaultWebApp, boolean useAsTemplate, NodeRef sourceNodeRef); - - /** - * Create a new web project (with given web project info) - *

- * Note: the DNS name will be used to generate the web project store id, which can be subsequently retrieved via WebProjectInfo.getStoreId() - * - * @param wpInfo web project info - * - * Note: - * - * @param dnsName DNS name (required, must be unique) - * @param name name (required, must be unique) - * @param title title - * @param description description - * @param defaultWebApp default webapp (if null, will default to ROOT webapp) - * @param useAsTemplate true if this web project can be used as a template to branch from - * @param sourceNodeRef web project node ref to branch from (can be null) - * @param previewProvider preview URI service provider name (must correspond to registered name, if null will be set to default provider) - * - * @return WebProjectInfo the created web project info - */ - @NotAuditable - public WebProjectInfo createWebProject(WebProjectInfo wpInfo); - - /** - * Determines whether the "Web Projects" container node is present. - * - * @return true if the "Web Projects" container node is present - */ - @NotAuditable - public boolean hasWebProjectsRoot(); - - /** - * Returns the Web Projects container - * - * @return NodeRef the node ref of the "Web Projects" container node - */ - @NotAuditable - public NodeRef getWebProjectsRoot(); - - /** - * Returns the Web Project for the given AVM path - * - * @param absoluteAVMPath the AVM path from which to determine the Web Project - * @return NodeRef the web project node ref for the path or null if it could not be determined - */ - @NotAuditable - public NodeRef getWebProjectNodeFromPath(String absoluteAVMPath); - - /** - * Returns the Web Project for the given AVM store name (sandbox store id) - * - * @param storeName the AVM store name (sandbox store id) from which to determine the Web Project - * @return NodeRef the web project node ref for the path or null if it could not be determined - */ - @NotAuditable - public NodeRef getWebProjectNodeFromStore(String storeName); - - /** - * List the available web projects for the current user - * - * @return List list of web project info - */ - @NotAuditable - public List listWebProjects(); - - /** - * List the web projects for the given user (based on the available web projects for the current user) - * - * @param userName user name - * @return List list of web project info - */ - @NotAuditable - public List listWebProjects(String userName); - - /** - * Return true if web project node ref is a web project - * - * @param wpNodeRef web project store id - * @return boolean true, if web project - */ - @NotAuditable - public boolean isWebProject(String wpStoreId); - - /** - * Return true if web project node ref is a web project - * - * @param wpNodeRef web project node ref - * @return boolean true, if web project - */ - @NotAuditable - public boolean isWebProject(NodeRef wpNodeRef); - - /** - * Gets web project info based on the store id of a web project - *

- * Returns null if the web project can not be found - * - * @param wpStoreId web project store id - * @return WebProjectInfo web project info - */ - @NotAuditable - public WebProjectInfo getWebProject(String wpStoreId); - - /** - * Gets web project info based on the DM nodeRef of a web project - *

- * Returns null if the web project can not be found - * - * @param wpNodeRef web project node ref - * @return WebProjectInfo web project info - */ - @NotAuditable - public WebProjectInfo getWebProject(NodeRef wpNodeRef); - - /** - * Get preview provider name configured for given web project (if not configured then return default preview provider) - * @param wpStoreId web project store id - * @return previewProviderName preview URI service provide name - */ - @NotAuditable - public String getPreviewProvider(String wpStoreId); - - /** - * Update the web project info - *

- * Note: the nodeRef and storeId (dnsName) of a web project cannot be updated once the web project has been created - * - * @param wpInfo web project info - */ - @NotAuditable - public void updateWebProject(WebProjectInfo wpInfo); - - /** - * Delete the web project - *

- * If the web project does not exist, will log a warning and succeed - *

- * Current user must be a content manager for the web project - * - * @param name web project store id - */ - @NotAuditable - public void deleteWebProject(String wpStoreId); - - /** - * Delete the web project - *

- * If the web project does not exist, will log a warning and succeed - *

- * Current user must be a content manager for the web project - *

- * Note: this will cascade delete all sandboxes associated with a web project - * - * @param name web project node ref - */ - @NotAuditable - public void deleteWebProject(NodeRef wpNodeRef); - - // - // Web app operations - // - - /** - * Create webapp for the given web project. - *

- * Current user must be a content manager for the web project - * - * @param wpStoreId web project store id - * @param name webapp name (must be unique within a web project) - * @param description webapp description - */ - @NotAuditable - public void createWebApp(String wpStoreId, String name, String description); - - /** - * Create webapp for the given web project. - *

- * Current user must be a content manager for the web project - * - * @param wpNodeRef web project node ref - * @param name webapp name (must be unique within a web project) - * @param description webapp description - */ - @NotAuditable - public void createWebApp(NodeRef wpNodeRef, String name, String description); - - /** - * List webapps for the web project - * - * @param wpStoreId web project store id - * @return List list of webapp names - */ - @NotAuditable - public List listWebApps(String wpStoreId); - - /** - * List webapps for the web project - * - * @param wpNodeRef web project node ref - * @return List list of webapp names - */ - @NotAuditable - public List listWebApps(NodeRef wpNodeRef); - - /** - * Delete webapp from the given web project - *

- * Current user must be a content manager for the web project - *

- * Note: this will cascade delete all assets within a webapp - * - * @param wpStoreId web project store id - * @param name webapp name - */ - @NotAuditable - public void deleteWebApp(String wpStoreId, String name); - - /** - * Delete webapp from the given web project - *

- * Current user must be a content manager for the web project - *

- * Note: this will cascade delete all assets within a webapp - * - * @param wpNodeRef web project node ref - * @param name webapp name - */ - @NotAuditable - public void deleteWebApp(NodeRef wpNodeRef, String name); - - // - // Web user operations - // - - /** - * Returns true if the current user is a manager of this web project - *

- * Note: This includes admin users but does not include the System user - * - * @param wpStoreId web project store id - * @return boolean true if the user is a manager (role = WCMUtil.ROLE_CONTENT_MANAGER), false otherwise - */ - @NotAuditable - public boolean isContentManager(String wpStoreId); - - /** - * Returns true if the current user is a manager of this web project - * - * @param wpNodeRef web project node ref - * @return boolean true if the user is a manager (role = WCMUtil.ROLE_CONTENT_MANAGER), false otherwise - */ - @NotAuditable - public boolean isContentManager(NodeRef wpNodeRef); - - /** - * Returns true if the user is a manager of this web project - *

- * Note: This includes admin users but does not include the System user - * - * @param storeName web project store id - * @param username user name - * @return boolean true if the user is a manager, false otherwise - */ - @NotAuditable - public boolean isContentManager(String wpStoreId, String username); - - /** - * Returns true if the user is a manager of this web project - *

- * Note: This includes admin users but does not include the System user - * - * @param wpNodeRef web project node ref - * @param userName user name - * @return boolean true if the user is a manager (role = WCMUtil.ROLE_CONTENT_MANAGER), false otherwise - */ - @NotAuditable - public boolean isContentManager(NodeRef wpNodeRef, String userName); - - /** - * List the web users of the web project - *

- * Current user must be a content manager for the web project - * - * @param wpStoreId web project store id - * @return Map map of pairs - */ - @NotAuditable - public Map listWebUsers(String wpStoreId); - - /** - * List the web users of the web project - *

- * Current user must be a content manager for the web project - * - * @param wpNodeRef web project node ref - * @return Map map of pairs - */ - @NotAuditable - public Map listWebUsers(NodeRef wpNodeRef); - - /** - * Get the number of web users invited to this web project - * - * @param wpNodeRef web project node ref - * @return int number of invited web users - */ - @NotAuditable - public int getWebUserCount(NodeRef wpNodeRef); - - /** - * Gets the role of the specified user - * - * @param wpStoreId web project store id - * @param userName user name - * @return String web project role for this user, null if no assigned role - */ - @NotAuditable - public String getWebUserRole(String wpStoreId, String userName); - - /** - * Gets the role of the specified user - * - * @param wpNodeRef web project node ref - * @param userName user name - * @return String web project role for this user, null if no assigned role - */ - @NotAuditable - public String getWebUserRole(NodeRef wpNodeRef, String userName); - - /** - * Indicates whether current user is a web user of the web project or not - * - * @param store id web project store id - * @return boolean true if the current user is a web user of the web project, false otherwise - */ - @NotAuditable - public boolean isWebUser(String wpStoreId); - - /** - * Indicates whether current user is a web user of the web project or not - * - * @param wpNodeRef web project node ref - * @return boolean true if the current user is a web user of the web project, false otherwise - */ - @NotAuditable - public boolean isWebUser(NodeRef wpNodeRef); - - /** - * Indicates whether given user is a web user of the web project or not - * - * @param store id web project store id - * @param userName user name - * @return boolean true if the user is a web user of the web project, false otherwise - */ - @NotAuditable - public boolean isWebUser(String wpStoreId, String userName); - - /** - * Indicates whether given user is a web user of the web project or not - * - * @param wpNodeRef web project node ref - * @param userName user name - * @return boolean true if the user is a web user of the web project, false otherwise - */ - @NotAuditable - public boolean isWebUser(NodeRef wpNodeRef, String userName); - - /** - * Invite users/groups to web project - *

- * Note: authority name can be user or group, although a group is flattened into a set of users - *

- * Note: author sandbox will NOT be auto created for each invited user - * - * @param wpStoreId web project store id - * @param userGroupRoles map of pairs - */ - @NotAuditable - public void inviteWebUsersGroups(String wpStoreId, Map userGroupRoles); - - /** - * Invite users/groups to web project - *

- * Note: authority name can be user or group, although a group is flattened into a set of users - * - * @param wpStoreId web project store id - * @param userGroupRoles map of pairs - * @param autoCreateAuthorSandbox if true then auto create an author sandbox for each invited user - */ - @NotAuditable - public void inviteWebUsersGroups(String wpStoreId, Map userGroupRoles, boolean autoCreateAuthorSandbox); - - /** - * Invite users/groups to web project - *

- * Note: authority name can be user or group, although a group is flattened into a set of users - * - * @param wpNodeRef web project node ref - * @param userGroupRoles map of pairs - * @param autoCreateAuthorSandbox if true then auto create the author sandbox for each invited user - */ - @NotAuditable - public void inviteWebUsersGroups(NodeRef wpNodeRef, Map userGroupRoles, boolean autoCreateAuthorSandbox); - - /** - * Invite user to web project - *

- * Note: author sandbox will NOT be auto created for each invited user - * - * @param wpStoreId web project store id - * @param userName user name (not a group) - * @param userRole web project role - */ - @NotAuditable - public void inviteWebUser(String wpStoreId, String userName, String userRole); - - /** - * Invite user to web project - * - * @param wpStoreId web project store id - * @param userName user name (not a group) - * @param userRole web project role - * @param autoCreateAuthorSandbox if true then auto create the author sandbox for each invited user - */ - @NotAuditable - public void inviteWebUser(String wpStoreId, String userName, String userRole, boolean autoCreateAuthorSandbox); - - /** - * Invite user to web project - * - * @param wpNodeRef web project node ref - * @param userName user name (not a group) - * @param userRole web project role - * @param autoCreateAuthorSandbox if true then auto create the author sandbox for each invited user - */ - @NotAuditable - public void inviteWebUser(NodeRef wpNodeRef, String userName, String userRole, boolean autoCreateAuthorSandbox); - - /** - * Uninvite user from a web project - *

- * Note: author sandbox will NOT be auto deleted - * - * @param wpStoreId web project store id - * @param userName user name - */ - @NotAuditable - public void uninviteWebUser(String wpStoreId, String userName); - - /** - * Uninvite user from a web project - *

- * Note: if author sandbox is auto deleted then this will cascade delete without warning (even if there are changed items) - * - * @param wpStoreId web project store id - * @param userName user name - * @param autoDeleteAuthorSandbox if true then auto delete the author sandbox - */ - @NotAuditable - public void uninviteWebUser(String wpStoreId, String userName, boolean autoDeleteAuthorSandbox); - - /** - * Uninvite user from a web project - *

- * Note: if author sandbox is auto deleted then this will cascade delete without warning (even if there are changed items) - * - * @param wpNodeRef web project node ref - * @param userName user name - * @param autoDeleteAuthorSandbox if true then auto delete the author sandbox - */ - @NotAuditable - public void uninviteWebUser(NodeRef wpNodeRef, String userName, boolean autoDeleteAuthorSandbox); -} diff --git a/source/java/org/alfresco/wcm/webproject/WebProjectServiceImpl.java b/source/java/org/alfresco/wcm/webproject/WebProjectServiceImpl.java deleted file mode 100644 index 39668d73ce..0000000000 --- a/source/java/org/alfresco/wcm/webproject/WebProjectServiceImpl.java +++ /dev/null @@ -1,1616 +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 . - */ -package org.alfresco.wcm.webproject; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.mbeans.VirtServerRegistry; -import org.alfresco.model.ApplicationModel; -import org.alfresco.model.ContentModel; -import org.alfresco.model.WCMAppModel; -import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.repo.avm.util.AVMUtil; -import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.repo.rule.RuleModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.repo.transaction.AlfrescoTransactionSupport; -import org.alfresco.repo.transaction.TransactionListenerAdapter; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMNotFoundException; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.avm.locking.AVMLockingService; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.InvalidNodeRefException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.security.AccessStatus; -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.cmr.security.PersonService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.DNSNameMangler; -import org.alfresco.wcm.preview.PreviewURIServiceRegistry; -import org.alfresco.wcm.sandbox.SandboxConstants; -import org.alfresco.wcm.sandbox.SandboxFactory; -import org.alfresco.wcm.sandbox.SandboxInfo; -import org.alfresco.wcm.sandbox.SandboxFactory.UserRoleWrapper; -import org.alfresco.wcm.util.WCMUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.ParameterCheck; - -/** - * Web Project Service Implementation - * - * @author janv - */ -public class WebProjectServiceImpl extends WCMUtil implements WebProjectService -{ - /** Logger */ - private static Log logger = LogFactory.getLog(WebProjectServiceImpl.class); - - /** The DM store where web projects are kept */ - public static final StoreRef WEBPROJECT_STORE = new StoreRef("workspace://SpacesStore"); - - /** The web projects root node reference */ - private NodeRef webProjectsRootNodeRef; // note: WCM is not currently MT-enabled (so this is OK) - private boolean isSetWebProjectsRootNodeRef; - - /** Services */ - private NodeService nodeService; - private NamespaceService namespaceService; - private SearchService searchService; - private AVMService avmService; - private AuthorityService authorityService; - private PermissionService permissionService; - private PersonService personService; - private SandboxFactory sandboxFactory; - private VirtServerRegistry virtServerRegistry; - private PreviewURIServiceRegistry previewURIProviderRegistry; - private TransactionService transactionService; - private AVMLockingService avmLockingService; - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - public void setAvmService(AVMService avmService) - { - this.avmService = avmService; - } - - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - public void setPersonService(PersonService personService) - { - this.personService = personService; - } - - public void setSandboxFactory(SandboxFactory sandboxFactory) - { - this.sandboxFactory = sandboxFactory; - } - - public void setVirtServerRegistry(VirtServerRegistry virtServerRegistry) - { - this.virtServerRegistry = virtServerRegistry; - } - - public void setPreviewURIServiceRegistry(PreviewURIServiceRegistry previewURIProviderRegistry) - { - this.previewURIProviderRegistry = previewURIProviderRegistry; - } - - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - public void setAvmLockingService(AVMLockingService avmLockingService) - { - this.avmLockingService = avmLockingService; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.WebProjectService#createWebProject(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - public WebProjectInfo createWebProject(String dnsName, String name, String title, String description) - { - return createWebProject(dnsName, name, title, description, null, false, null); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.WebProjectService#createWebProject(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.alfresco.service.cmr.repository.NodeRef) - */ - public WebProjectInfo createWebProject(String dnsName, String name, String title, String description, NodeRef sourceNodeRef) - { - return createWebProject(dnsName, name, title, description, null, false, sourceNodeRef); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.WebProjectService#createWebProject(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean, org.alfresco.service.cmr.repository.NodeRef) - */ - public WebProjectInfo createWebProject(String dnsName, String name, String title, String description, String defaultWebApp, boolean useAsTemplate, NodeRef sourceNodeRef) - { - return createWebProject(new WebProjectInfoImpl(dnsName, name, title, description, defaultWebApp, useAsTemplate, sourceNodeRef, null)); - } - - public WebProjectInfo createWebProject(WebProjectInfo wpInfo) - { - long start = System.currentTimeMillis(); - - String wpStoreId = wpInfo.getStoreId(); - String name = wpInfo.getName(); - String title = wpInfo.getTitle(); - String description = wpInfo.getDescription(); - boolean useAsTemplate = wpInfo.isTemplate(); - NodeRef sourceNodeRef = wpInfo.getNodeRef(); - String defaultWebApp = wpInfo.getDefaultWebApp(); - String previewProviderName = wpInfo.getPreviewProviderName(); - - ParameterCheck.mandatoryString("wpStoreId", wpStoreId); - ParameterCheck.mandatoryString("name", name); - - // Generate web project store id (an AVM store name) - wpStoreId = DNSNameMangler.MakeDNSName(wpStoreId); - - if (wpStoreId.indexOf(WCMUtil.STORE_SEPARATOR) != -1) - { - throw new IllegalArgumentException("Unexpected store id '"+wpStoreId+"' - should not contain '"+WCMUtil.STORE_SEPARATOR+"'"); - } - - if (wpStoreId.indexOf(AVMUtil.AVM_STORE_SEPARATOR_CHAR) != -1) - { - throw new IllegalArgumentException("Unexpected store id '"+wpStoreId+"' - should not contain '"+AVMUtil.AVM_STORE_SEPARATOR_CHAR+"'"); - } - - if (previewProviderName == null) - { - // default preview URI service provider - previewProviderName = previewURIProviderRegistry.getDefaultProviderName(); - } - else if (! previewURIProviderRegistry.getPreviewURIServiceProviders().keySet().contains(previewProviderName)) - { - throw new AlfrescoRuntimeException("Cannot update web project '" + wpInfo.getStoreId() + "' - unknown preview URI service provider ("+previewProviderName+")"); - } - - // default webapp name - defaultWebApp = (defaultWebApp != null && defaultWebApp.length() != 0) ? defaultWebApp : WCMUtil.DIR_ROOT; - - // create the website space in the correct parent folder - Map props = new HashMap(1); - props.put(ContentModel.PROP_NAME, name); - props.put(WCMAppModel.PROP_ISSOURCE, useAsTemplate); - props.put(WCMAppModel.PROP_DEFAULTWEBAPP, defaultWebApp); - props.put(WCMAppModel.PROP_AVMSTORE, wpStoreId); // reference to the root AVM store - props.put(WCMAppModel.PROP_PREVIEW_PROVIDER, previewProviderName); - - NodeRef webProjectsRoot = getWebProjectsRoot(); - - // ALF-906: ensure that DM rules are not inherited by web projects - if(!nodeService.hasAspect(webProjectsRoot, RuleModel.ASPECT_IGNORE_INHERITED_RULES)) - { - nodeService.addAspect(webProjectsRoot, RuleModel.ASPECT_IGNORE_INHERITED_RULES, null); - } - - ChildAssociationRef childAssocRef = nodeService.createNode( - webProjectsRoot, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(name)), - WCMAppModel.TYPE_AVMWEBFOLDER, - props); - - NodeRef wpNodeRef = childAssocRef.getChildRef(); - - - // apply the uifacets aspect - icon, title and description props - Map uiFacetsProps = new HashMap(4); - uiFacetsProps.put(ApplicationModel.PROP_ICON, WCMUtil.SPACE_ICON_WEBSITE); - uiFacetsProps.put(ContentModel.PROP_TITLE, title); - uiFacetsProps.put(ContentModel.PROP_DESCRIPTION, description); - nodeService.addAspect(wpNodeRef, ApplicationModel.ASPECT_UIFACETS, uiFacetsProps); - - // branch from source web project, if supplied - String branchStoreId = null; - if (sourceNodeRef != null) - { - branchStoreId = (String)nodeService.getProperty(sourceNodeRef, WCMAppModel.PROP_AVMSTORE); - } - - // create the AVM staging store to represent the newly created location website - sandboxFactory.createStagingSandbox(wpStoreId, wpNodeRef, branchStoreId); // ignore return, fails if web project already exists - - String stagingStore = WCMUtil.buildStagingStoreName(wpStoreId); - - // create the default webapp folder under the hidden system folders - if (branchStoreId == null) - { - String stagingStoreRoot = WCMUtil.buildSandboxRootPath(stagingStore); - avmService.createDirectory(stagingStoreRoot, defaultWebApp); - avmService.addAspect(AVMNodeConverter.ExtendAVMPath(stagingStoreRoot, defaultWebApp), WCMAppModel.ASPECT_WEBAPP); - } - - // now the sandbox is created set the permissions masks for the store - sandboxFactory.setStagingPermissionMasks(wpStoreId); - - // set preview provider on staging store (used for preview lookup) - avmService.setStoreProperty(stagingStore, - SandboxConstants.PROP_WEB_PROJECT_PREVIEW_PROVIDER, - new PropertyValue(DataTypeDefinition.TEXT, previewProviderName)); - - // Snapshot the store with the empty webapp - avmService.createSnapshot(wpStoreId, null, null); - - // break the permissions inheritance on the web project node so that only assigned users can access it - permissionService.setInheritParentPermissions(wpNodeRef, false); - - // TODO: Currently auto-creates author sandbox for creator of web project (eg. an admin or a DM contributor to web projects root space) - // NOTE: JSF client does not yet allow explicit creation of author sandboxes - inviteWebUser(wpNodeRef, AuthenticationUtil.getFullyAuthenticatedUser(), WCMUtil.ROLE_CONTENT_MANAGER, true); - - // Bind the post-commit transaction listener with data required for virtualization server notification - CreateWebAppTransactionListener tl = new CreateWebAppTransactionListener(wpStoreId, WCMUtil.DIR_ROOT); - AlfrescoTransactionSupport.bindListener(tl); - - if (logger.isDebugEnabled()) - { - logger.debug("Created web project: " + wpNodeRef + " in "+(System.currentTimeMillis()-start)+" ms (store id: " + wpStoreId + ")"); - } - - // Return created web project info - return new WebProjectInfoImpl(wpStoreId, name, title, description, defaultWebApp, useAsTemplate, wpNodeRef, previewProviderName); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#createWebApp(java.lang.String, java.lang.String, java.lang.String) - */ - public void createWebApp(String wpStoreId, String webAppName, String webAppDescription) - { - createWebApp(getWebProjectNodeFromStore(wpStoreId), webAppName, webAppDescription); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#createWebApp(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String) - */ - public void createWebApp(NodeRef wpNodeRef, final String webAppName, final String webAppDescription) - { - long start = System.currentTimeMillis(); - - WebProjectInfo wpInfo = getWebProject(wpNodeRef); - - if (isContentManager(wpNodeRef)) - { - // get AVM store name of the staging sandbox - final String stagingStoreId = wpInfo.getStagingStoreName(); - - AuthenticationUtil.runAs(new RunAsWork() - { - public Object doWork() throws Exception - { - final String parent = WCMUtil.buildSandboxRootPath(stagingStoreId); - avmService.createDirectory(parent, webAppName); - - String path = AVMNodeConverter.ExtendAVMPath(parent, webAppName); - avmService.addAspect(path, ApplicationModel.ASPECT_UIFACETS); - avmService.addAspect(path, WCMAppModel.ASPECT_WEBAPP); - - if (webAppDescription != null && webAppDescription.length() != 0) - { - avmService.setNodeProperty(path, - ContentModel.PROP_DESCRIPTION, - new PropertyValue(DataTypeDefinition.TEXT, - webAppDescription)); - } - - // Snapshot the store with the empty webapp - avmService.createSnapshot(stagingStoreId, null, null); - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - - CreateWebAppTransactionListener tl = new CreateWebAppTransactionListener(wpInfo.getStoreId(), webAppName); - AlfrescoTransactionSupport.bindListener(tl); - - if (logger.isDebugEnabled()) - { - logger.debug("Created web app: "+webAppName+" in "+(System.currentTimeMillis()-start)+" ms (store id: "+wpInfo.getStoreId()+")"); - } - } - else - { - throw new AccessDeniedException("Only content managers may create new webapp '"+webAppName+"' (store id: "+wpInfo.getStoreId()+")"); - } - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#listWebApps(java.lang.String) - */ - public List listWebApps(String wpStoreId) - { - return listWebApps(getWebProjectNodeFromStore(wpStoreId)); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#listWebApps(org.alfresco.service.cmr.repository.NodeRef) - */ - public List listWebApps(NodeRef wpNodeRef) - { - WebProjectInfo wpInfo = getWebProject(wpNodeRef); - - String path = WCMUtil.buildSandboxRootPath(wpInfo.getStagingStoreName()); - Map folders = avmService.getDirectoryListing(-1, path); - - List webAppNames = new ArrayList(folders.size()); - webAppNames.addAll(folders.keySet()); - return webAppNames; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#deleteWebApp(java.lang.String, java.lang.String) - */ - public void deleteWebApp(String wpStoreId, String webAppName) - { - deleteWebApp(getWebProjectNodeFromStore(wpStoreId), webAppName); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#deleteWebApp(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - public void deleteWebApp(NodeRef wpNodeRef, final String webAppName) - { - long start = System.currentTimeMillis(); - - ParameterCheck.mandatoryString("webAppName", webAppName); - - WebProjectInfo wpInfo = getWebProject(wpNodeRef); - - if (webAppName.equals(wpInfo.getDefaultWebApp())) - { - throw new AlfrescoRuntimeException("Cannot delete default webapp '"+webAppName+"' (store id: "+wpInfo.getStoreId()+")"); - } - else if (isContentManager(wpInfo.getNodeRef())) - { - // get AVM store name of the staging sandbox - final String wpStoreId = wpInfo.getStoreId(); - - WCMUtil.removeVServerWebapp(virtServerRegistry, WCMUtil.buildStoreWebappPath(wpStoreId, webAppName), true); - - AuthenticationUtil.runAs(new RunAsWork() - { - public Object doWork() throws Exception - { - final String parent = WCMUtil.buildSandboxRootPath(wpStoreId); - - avmService.removeNode(parent, webAppName); - - // Snapshot the store with the webapp removed - avmService.createSnapshot(wpStoreId, null, null); - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - - if (logger.isDebugEnabled()) - { - logger.debug("Deleted web app: "+webAppName+" in "+(System.currentTimeMillis()-start)+" ms (store id: "+wpStoreId+")"); - } - } - else - { - throw new AccessDeniedException("Only content managers may delete webapp '"+webAppName+"' (web project: "+wpNodeRef+")"); - } - } - - /* - * @see org.alfresco.wcm.webproject.WebProjectService#hasWebProjectsRoot() - */ - public boolean hasWebProjectsRoot() - { - return getWebProjectsRootOrNull() != null; - } - - private NodeRef getWebProjectsRootOrNull() - { - if (!this.isSetWebProjectsRootNodeRef) - { - // Get the root 'web projects' folder - List results = this.searchService.selectNodes(this.nodeService.getRootNode(WEBPROJECT_STORE), - getWebProjectsPath(), null, this.namespaceService, false); - int size = results.size(); - if (size > 1) - { - // More than one root web projects folder exits - throw new AlfrescoRuntimeException("More than one root 'Web Projects' folder exists"); - } - if (size > 0) - { - this.webProjectsRootNodeRef = results.get(0); - } - this.isSetWebProjectsRootNodeRef = true; - } - - return this.webProjectsRootNodeRef; - } - - /** - * Get the node reference that is the web projects root - * - * @return NodeRef node reference - */ - public NodeRef getWebProjectsRoot() - { - NodeRef result = getWebProjectsRootOrNull(); - if (result == null) - { - // No root web projects folder exists - throw new AlfrescoRuntimeException("No root 'Web Projects' folder exists (is WCM enabled ?)"); - } - return result; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#listWebProjects() - */ - public List listWebProjects() - { - NodeRef wpRoot = getWebProjectsRoot(); - - Set nodeTypeQNames = new HashSet(1); - nodeTypeQNames.add(WCMAppModel.TYPE_AVMWEBFOLDER); - List webProjects = nodeService.getChildAssocs(wpRoot, nodeTypeQNames); - - List result = new ArrayList(webProjects.size()); - for (ChildAssociationRef childAssocRefs : webProjects) - { - result.add(getWebProject(childAssocRefs.getChildRef())); - } - - return result; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#listWebProjects(java.lang.String) - */ - public List listWebProjects(String userName) - { - List webProjects = listWebProjects(); - List result = new ArrayList(webProjects.size()); - for (WebProjectInfo webProject : webProjects) - { - if (isWebUser(webProject.getNodeRef(), userName) == true) - { - result.add(webProject); - } - } - return result; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#isWebProject(java.lang.String) - */ - public boolean isWebProject(String wpStoreId) - { - NodeRef wpNodeRef = getWebProjectNodeFromStore(wpStoreId); - if (wpNodeRef == null) - { - return false; - } - return isWebProject(wpNodeRef); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#isWebProject(org.alfresco.service.cmr.repository.NodeRef) - */ - public boolean isWebProject(NodeRef wpNodeRef) - { - if (wpNodeRef == null) - { - return false; - } - - try - { - return (WCMAppModel.TYPE_AVMWEBFOLDER.equals(nodeService.getType(wpNodeRef))); - } - catch (InvalidNodeRefException e) - { - return false; - } - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#getWebProject(java.lang.String) - */ - public WebProjectInfo getWebProject(String wpStoreId) - { - WebProjectInfo result = null; - - // Get the web project node - NodeRef wpNodeRef = getWebProjectNodeFromStore(wpStoreId); - if (wpNodeRef != null) - { - // Create the web project info - result = getWebProject(wpNodeRef); - } - - // Return the web project info - return result; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#getPreviewProvider(java.lang.String) - */ - public String getPreviewProvider(String wpStoreId) - { - ParameterCheck.mandatoryString("wpStoreId", wpStoreId); - - String previewProviderName = null; - - try - { - String stagingStoreId = WCMUtil.buildStagingStoreName(wpStoreId); - PropertyValue pValue = avmService.getStoreProperty(stagingStoreId, SandboxConstants.PROP_WEB_PROJECT_PREVIEW_PROVIDER); - - if (pValue != null) - { - previewProviderName = (String)pValue.getValue(DataTypeDefinition.TEXT); - } - } - catch (AVMNotFoundException nfe) - { - logger.warn(wpStoreId + " is not a web project: " + nfe); - } - - if (previewProviderName == null) - { - previewProviderName = previewURIProviderRegistry.getDefaultProviderName(); - } - - return previewProviderName; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#getWebProject(org.alfresco.service.cmr.repository.NodeRef) - */ - public WebProjectInfo getWebProject(NodeRef wpNodeRef) - { - if (! isWebProject(wpNodeRef)) - { - throw new IllegalArgumentException(wpNodeRef + " is not a web project"); - } - - // Get the properties - Map properties = this.nodeService.getProperties(wpNodeRef); - - String name = (String)properties.get(ContentModel.PROP_NAME); - String title = (String)properties.get(ContentModel.PROP_TITLE); - String description = (String)properties.get(ContentModel.PROP_DESCRIPTION); - String wpStoreId = (String)properties.get(WCMAppModel.PROP_AVMSTORE); - String defaultWebApp = (String)properties.get(WCMAppModel.PROP_DEFAULTWEBAPP); - Boolean useAsTemplate = (Boolean)properties.get(WCMAppModel.PROP_ISSOURCE); - String previewProvider = (String)properties.get(WCMAppModel.PROP_PREVIEW_PROVIDER); - - // Create and return the web project info - WebProjectInfo wpInfo = new WebProjectInfoImpl(wpStoreId, name, title, description, defaultWebApp, useAsTemplate, wpNodeRef, previewProvider); - return wpInfo; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#updateWebProject(org.alfresco.wcm.webproject.WebProjectInfo) - */ - public void updateWebProject(WebProjectInfo wpInfo) - { - long start = System.currentTimeMillis(); - - NodeRef wpNodeRef = getWebProjectNodeFromStore(wpInfo.getStoreId()); - if (wpNodeRef == null) - { - throw new AlfrescoRuntimeException("Cannot update web project '" + wpInfo.getStoreId() + "' - it does not exist."); - } - - if (! listWebApps(wpNodeRef).contains(wpInfo.getDefaultWebApp())) - { - throw new AlfrescoRuntimeException("Cannot update web project '" + wpInfo.getStoreId() + "' - unknown default web app ("+wpInfo.getDefaultWebApp()+")"); - } - - if (wpInfo.getPreviewProviderName() == null) - { - wpInfo.setPreviewProviderName(previewURIProviderRegistry.getDefaultProviderName()); - } - else if (! previewURIProviderRegistry.getPreviewURIServiceProviders().keySet().contains(wpInfo.getPreviewProviderName())) - { - throw new AlfrescoRuntimeException("Cannot update web project '" + wpInfo.getStoreId() + "' - unknown preview URI service provider ("+wpInfo.getPreviewProviderName()+")"); - } - - // Note: the site preset and short name can not be updated - - // Update the properties of the site - note: cannot change storeId or wpNodeRef - Map properties = this.nodeService.getProperties(wpNodeRef); - - properties.put(ContentModel.PROP_NAME, wpInfo.getName()); - properties.put(ContentModel.PROP_TITLE, wpInfo.getTitle()); - properties.put(ContentModel.PROP_DESCRIPTION, wpInfo.getDescription()); - properties.put(WCMAppModel.PROP_DEFAULTWEBAPP, wpInfo.getDefaultWebApp()); - properties.put(WCMAppModel.PROP_ISSOURCE, wpInfo.isTemplate()); - properties.put(WCMAppModel.PROP_PREVIEW_PROVIDER, wpInfo.getPreviewProviderName()); - - this.nodeService.setProperties(wpNodeRef, properties); - - // set preview provider on staging store (used for preview lookup) - String stagingStore = WCMUtil.buildStagingStoreName(wpInfo.getStoreId()); - - avmService.deleteStoreProperty(stagingStore, SandboxConstants.PROP_WEB_PROJECT_PREVIEW_PROVIDER); - avmService.setStoreProperty(stagingStore, - SandboxConstants.PROP_WEB_PROJECT_PREVIEW_PROVIDER, - new PropertyValue(DataTypeDefinition.TEXT, wpInfo.getPreviewProviderName())); - - if (logger.isDebugEnabled()) - { - logger.debug("Updated web project: " + wpNodeRef + " in "+(System.currentTimeMillis()-start)+" ms (store id: " + wpInfo.getStoreId() + ")"); - } - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#deleteWebProject(java.lang.String) - */ - public void deleteWebProject(String wpStoreId) - { - NodeRef wpNodeRef = getWebProjectNodeFromStore(wpStoreId); - if (wpNodeRef != null) - { - deleteWebProject(wpNodeRef); - } - else - { - // by definition, the current user is not a content manager since the web project does not exist (or is not visible) - throw new AccessDeniedException("Only content managers may delete a web project"); - } - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#deleteWebProject(org.alfresco.service.cmr.repository.NodeRef) - */ - public void deleteWebProject(final NodeRef wpNodeRef) - { - long start = System.currentTimeMillis(); - - if (! isContentManager(wpNodeRef)) - { - // the current user is not a content manager since the web project does not exist (or is not visible) - throw new AccessDeniedException("Only content managers may delete web project"); - } - - // delete all attached website sandboxes in reverse order to the layering - final String wpStoreId = (String)nodeService.getProperty(wpNodeRef, WCMAppModel.PROP_AVMSTORE); - - if (wpStoreId != null) - { - // Notify virtualization server about removing this website - // - // Implementation note: - // - // Because the removal of virtual webapps in the virtualization - // server is recursive, it only needs to be given the name of - // the main staging store. - // - // This notification must occur *prior* to purging content - // within the AVM because the virtualization server must list - // the avm_webapps dir in each store to discover which - // virtual webapps must be unloaded. The virtualization - // server traverses the sandbox's stores in most-to-least - // dependent order, so clients don't have to worry about - // accessing a preview layer whose main layer has been torn - // out from under it. - // - // It does not matter what webapp name we give here, so "/ROOT" - // is as sensible as anything else. It's all going away. - - final String sandbox = WCMUtil.buildStagingStoreName(wpStoreId); - String path = WCMUtil.buildStoreWebappPath(sandbox, "/ROOT"); - - WCMUtil.removeAllVServerWebapps(virtServerRegistry, path, true); - - try - { - RetryingTransactionCallback deleteWebProjectWork = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - AuthenticationUtil.runAs(new RunAsWork() - { - public Object doWork() throws Exception - { - List sbInfos = sandboxFactory.listAllSandboxes(wpStoreId, true, true); - - for (SandboxInfo sbInfo : sbInfos) - { - String sbStoreId = sbInfo.getSandboxId(); - - if (WCMUtil.isLocalhostDeployedStore(wpStoreId, sbStoreId)) - { - if (getWebProject(WCMUtil.getWebProjectStoreId(sbStoreId)) != null) - { - continue; - } - } - - // delete sandbox (and associated preview sandbox, if it exists) - sandboxFactory.deleteSandbox(sbInfo, false, false); - } - - // delete all web project locks in one go (ie. all those currently held against staging store) - avmLockingService.removeLocks(wpStoreId); - - StoreRef archiveStoreRef = nodeService.getStoreArchiveNode(wpNodeRef.getStoreRef()).getStoreRef(); - - // delete the web project node itself - nodeService.deleteNode(wpNodeRef); - nodeService.deleteNode(new NodeRef(archiveStoreRef, wpNodeRef.getId())); - - sandboxFactory.removeGroupsForStore(sandbox); - - return null; - } - }, AuthenticationUtil.getSystemUserName()); - - return null; - } - }; - - transactionService.getRetryingTransactionHelper().doInTransaction(deleteWebProjectWork); - - if (logger.isDebugEnabled()) - { - logger.debug("Deleted web project: " + wpNodeRef + " in "+(System.currentTimeMillis()-start)+" ms (store id: " + wpStoreId + ")"); - } - } - catch (Throwable err) - { - throw new AlfrescoRuntimeException("Failed to delete web project: ", err); - } - } - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#isContentManager(java.lang.String) - */ - public boolean isContentManager(String storeName) - { - return isContentManager(storeName, AuthenticationUtil.getFullyAuthenticatedUser()); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.WebProjectService#isContentManager(java.lang.String, java.lang.String) - */ - public boolean isContentManager(String wpStoreId, String userName) - { - return isContentManager(getWebProjectNodeFromStore(wpStoreId), userName); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#isContentManager(org.alfresco.service.cmr.repository.NodeRef) - */ - public boolean isContentManager(NodeRef wpNodeRef) - { - return isContentManager(wpNodeRef, AuthenticationUtil.getFullyAuthenticatedUser()); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#isContentManager(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - public boolean isContentManager(NodeRef wpNodeRef, String userName) - { - String userRole = getWebUserRole(wpNodeRef, userName); - return WCMUtil.ROLE_CONTENT_MANAGER.equals(userRole); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#isWebUser(java.lang.String) - */ - public boolean isWebUser(String wpStoreId) - { - return isWebUser(getWebProjectNodeFromStore(wpStoreId)); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#isWebUser(org.alfresco.service.cmr.repository.NodeRef) - */ - public boolean isWebUser(NodeRef wpNodeRef) - { - // note: admin is an implied web user (content manager) although will not appear in listWebUsers unless explicitly invited - return (permissionService.hasPermission(wpNodeRef, PermissionService.READ) == AccessStatus.ALLOWED); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#isWebUser(java.lang.String, java.lang.String) - */ - public boolean isWebUser(String wpStoreId, String username) - { - return isWebUser(getWebProjectNodeFromStore(wpStoreId), username); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#isWebUser(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - public boolean isWebUser(final NodeRef wpNodeRef, String userName) - { - return AuthenticationUtil.runAs(new RunAsWork() - { - public Boolean doWork() throws Exception - { - return isWebUser(wpNodeRef); - } - }, userName); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#getWebUserCount(org.alfresco.service.cmr.repository.NodeRef) - */ - public int getWebUserCount(NodeRef wpNodeRef) - { - long start = System.currentTimeMillis(); - - int cnt = WCMUtil.listWebUserRefs(nodeService, wpNodeRef, false).size(); - - if (logger.isTraceEnabled()) - { - logger.trace("Get web user cnt: " + wpNodeRef + "(" + cnt + ") in "+(System.currentTimeMillis()-start)+" ms"); - } - - return cnt; - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#listWebUsers(java.lang.String) - */ - public Map listWebUsers(String wpStoreId) - { - return listWebUsers(getWebProjectNodeFromStore(wpStoreId)); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#listWebUsers(org.alfresco.service.cmr.repository.NodeRef) - */ - public Map listWebUsers(NodeRef wpNodeRef) - { - long start = System.currentTimeMillis(); - - // special case: allow System - eg. to allow user to create their own sandbox on-demand (createAuthorSandbox) - if (isContentManager(wpNodeRef) - || (AuthenticationUtil.getRunAsUser().equals(AuthenticationUtil.getSystemUserName()) - || (permissionService.hasPermission(wpNodeRef, PermissionService.ADD_CHILDREN) == AccessStatus.ALLOWED))) - { - Map users = WCMUtil.listWebUsers(nodeService, wpNodeRef); - - if (logger.isTraceEnabled()) - { - logger.trace("List web users: " + wpNodeRef + "(" + users.size() + ") in "+(System.currentTimeMillis()-start)+" ms"); - } - - return users; - } - else - { - throw new AccessDeniedException("Only content managers may list users in a web project"); - } - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#getWebUserRole(java.lang.String, java.lang.String) - */ - public String getWebUserRole(String wpStoreId, String userName) - { - return getWebUserRole(getWebProjectNodeFromStore(wpStoreId), userName); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#getWebUserRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - public String getWebUserRole(NodeRef wpNodeRef, String userName) - { - ParameterCheck.mandatoryString("userName", userName); - - String userRole = null; - - if (! isWebProject(wpNodeRef)) - { - logger.warn(wpNodeRef + " is not a web project"); - return null; - } - - if (authorityService.isAdminAuthority(userName)) - { - // fake the Content Manager role for an admin user - userRole = WCMUtil.ROLE_CONTENT_MANAGER; - } - else - { - userRole = getWebUserRoleImpl(wpNodeRef, userName); - } - - return userRole; - } - - private String getWebUserRoleImpl(NodeRef wpNodeRef, String userName) - { - NodeRef userRef = getWebUserRef(wpNodeRef, userName); - String userRole = null; - - if (userRef != null) - { - userRole = (String)nodeService.getProperty(userRef, WCMAppModel.PROP_WEBUSERROLE); - } - - return userRole; - } - - private NodeRef getWebUserRef(NodeRef wpNodeRef, String userName) - { - StringBuilder query = new StringBuilder(128); - query.append("+PARENT:\"").append(wpNodeRef).append("\" "); - query.append("+TYPE:\"").append(WCMAppModel.TYPE_WEBUSER).append("\" "); - query.append("+@").append(NamespaceService.WCMAPP_MODEL_PREFIX).append("\\:username:\""); - query.append(userName); - query.append("\""); - - ResultSet resultSet = null; - List nodes = null; - try - { - resultSet = searchService.query( - WEBPROJECT_STORE, - SearchService.LANGUAGE_LUCENE, - query.toString()); - nodes = resultSet.getNodeRefs(); - } - finally - { - if (resultSet != null) - { - resultSet.close(); - } - } - - // Lucene indexing may strip certain international characters or treat them as equivalent so we do string - // comparisons on the results to ensure an exact match - Iterator i = nodes.iterator(); - while (i.hasNext()) - { - if (!nodeService.getProperty(i.next(), WCMAppModel.PROP_WEBUSERNAME).equals(userName)) - { - i.remove(); - } - } - - if (nodes.size() == 1) - { - return nodes.get(0); - } - else if (nodes.size() == 0) - { - if (logger.isTraceEnabled()) - { - logger.trace("getWebUserRef: web user ("+userName+") not found in web project: "+wpNodeRef); - } - } - else - { - logger.error("getWebUserRef: more than one web user ("+userName+") found in web project: "+wpNodeRef); - } - - return null; - } - - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#findWebProjectNodeFromPath(java.lang.String) - */ - public NodeRef getWebProjectNodeFromPath(String absoluteAVMPath) - { - return getWebProjectNodeFromStore(WCMUtil.getWebProjectStoreIdFromPath(absoluteAVMPath)); - } - - /*(non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#getWebProjectNodeFromStore(java.lang.String) - */ - public NodeRef getWebProjectNodeFromStore(String wpStoreId) - { - ParameterCheck.mandatoryString("wpStoreId", wpStoreId); - - return WCMUtil.getWebProjectNodeFromWebProjectStore(avmService, wpStoreId); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#inviteWebUsersGroups(java.lang.String, java.util.Map) - */ - public void inviteWebUsersGroups(String wpStoreId, Map userGroupRoles) - { - inviteWebUsersGroups(getWebProjectNodeFromStore(wpStoreId), userGroupRoles, false); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#inviteWebUsersGroups(java.lang.String, java.util.Map, boolean) - */ - public void inviteWebUsersGroups(String wpStoreId, Map userGroupRoles, boolean autoCreateAuthorSandbox) - { - inviteWebUsersGroups(getWebProjectNodeFromStore(wpStoreId), userGroupRoles, autoCreateAuthorSandbox); - } - - public void inviteWebUsersGroups(NodeRef wpNodeRef, Map userGroupRoles, boolean autoCreateAuthorSandbox) - { - long start = System.currentTimeMillis(); - - if (! (isContentManager(wpNodeRef) || - permissionService.hasPermission(wpNodeRef, PermissionService.ADD_CHILDREN) == AccessStatus.ALLOWED)) - { - throw new AccessDeniedException("Only content managers may invite web users"); - } - - WebProjectInfo wpInfo = getWebProject(wpNodeRef); - String wpStoreId = wpInfo.getStoreId(); - - // build a list of managers who will have full permissions on ALL staging areas - List managers = new ArrayList(4); - Map webSiteUsers = new HashMap(8); - List managersToRemove = new LinkedList(); - List usersToUpdate = new LinkedList(); - - // retrieve the list of managers from the existing users - for (Map.Entry userRole : userGroupRoles.entrySet()) - { - String authority = userRole.getKey(); - String role = userRole.getValue(); - - for (String userAuth : findNestedUserAuthorities(authority)) - { - if (WCMUtil.ROLE_CONTENT_MANAGER.equals(role)) - { - managers.add(userAuth); - } - } - } - - List userInfoRefs = nodeService.getChildAssocs(wpNodeRef, WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL); - - for (ChildAssociationRef ref : userInfoRefs) - { - NodeRef userInfoRef = ref.getChildRef(); - String username = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME); - String userrole = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE); - - if (WCMUtil.ROLE_CONTENT_MANAGER.equals(userrole) && managers.contains(username) == false) - { - managers.add(username); - } - - // add each existing user to the map which will be rechecked for update changed user permissions - webSiteUsers.put(username, userInfoRef); - } - - List sandboxInfoList = new LinkedList(); - - int invitedCount = 0; - boolean managersUpdateRequired = false; - - for (Map.Entry userRole : userGroupRoles.entrySet()) - { - String authority = userRole.getKey(); - String role = userRole.getValue(); - - for (String userAuth : findNestedUserAuthorities(authority)) - { - if (webSiteUsers.keySet().contains(userAuth) == false) - { - if (autoCreateAuthorSandbox) - { - // create a sandbox for the user with permissions based on role - SandboxInfo sbInfo = sandboxFactory.createUserSandbox(wpStoreId, userAuth, role); - sandboxInfoList.add(sbInfo); - } - - sandboxFactory.addStagingAreaUser(wpStoreId, userAuth, role); - - // create an app:webuser instance for each authority and assoc to the web project node - createWebUser(wpNodeRef, userAuth, role); - - // if this new user is a manager, we'll need to update the manager permissions applied - // to each existing user sandbox - to ensure that new managers have access to them - managersUpdateRequired |= (WCMUtil.ROLE_CONTENT_MANAGER.equals(role)); - - invitedCount++; - } - else - { - // TODO - split out into separate 'change role' - // if user role have been changed then update required properties etc. - NodeRef userRef = webSiteUsers.get(userAuth); - String oldUserRole = (String)nodeService.getProperty(userRef, WCMAppModel.PROP_WEBUSERROLE); - - if (!role.equals(oldUserRole)) - { - // change in role - Map props = nodeService.getProperties(userRef); - props.put(WCMAppModel.PROP_WEBUSERNAME, userAuth); - props.put(WCMAppModel.PROP_WEBUSERROLE, role); - nodeService.setProperties(userRef, props); - - if (WCMUtil.ROLE_CONTENT_MANAGER.equals(role)) - { - managersUpdateRequired = true; - } - else if (WCMUtil.ROLE_CONTENT_MANAGER.equals(oldUserRole)) - { - managersToRemove.add(userAuth); - } - - usersToUpdate.add(sandboxFactory.new UserRoleWrapper(userAuth, oldUserRole, role)); - - if (logger.isDebugEnabled()) - { - logger.debug(userAuth +"'s role has been changed from '" + oldUserRole + - "' to '" + role + "'"); - } - } - } - } - } - - // Bind the post-commit transaction listener with data required for virtualization server notification - CreateSandboxTransactionListener tl = new CreateSandboxTransactionListener(sandboxInfoList, listWebApps(wpNodeRef)); - AlfrescoTransactionSupport.bindListener(tl); - - if (managersUpdateRequired == true) - { - sandboxFactory.updateSandboxManagers(wpStoreId, managers); - } - - // TODO - split out into separate 'change role' - // remove ex-managers from sandboxes - if (managersToRemove.size() != 0) - { - sandboxFactory.removeSandboxManagers(wpStoreId, managersToRemove); - } - - // get permissions and roles for a web project folder type - Set perms = permissionService.getSettablePermissions(WCMAppModel.TYPE_AVMWEBFOLDER); - - // set permissions for each user - for (Map.Entry userRole : userGroupRoles.entrySet()) - { - String authority = userRole.getKey(); - String role = userRole.getValue(); - - for (String permission : perms) - { - if (role.equals(permission)) - { - permissionService.setPermission(wpNodeRef, - authority, - permission, - true); - break; - } - } - } - - // TODO - split out into separate 'change role' - // update user's roles - if (usersToUpdate.size() != 0) - { - sandboxFactory.updateSandboxRoles(wpStoreId, usersToUpdate, perms); - } - - if (logger.isDebugEnabled()) - { - logger.debug("Invited "+invitedCount+" web users in "+(System.currentTimeMillis()-start)+" ms (store id: "+wpStoreId+")"); - } - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#inviteWebUser(java.lang.String, java.lang.String, java.lang.String) - */ - public void inviteWebUser(String wpStoreId, String userAuth, String role) - { - inviteWebUser(getWebProjectNodeFromStore(wpStoreId), userAuth, role, false); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#inviteWebUser(java.lang.String, java.lang.String, java.lang.String, boolean) - */ - public void inviteWebUser(String wpStoreId, String userAuth, String role, boolean autoCreateAuthorSandbox) - { - inviteWebUser(getWebProjectNodeFromStore(wpStoreId), userAuth, role, autoCreateAuthorSandbox); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#inviteWebUser(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, boolean) - */ - public void inviteWebUser(NodeRef wpNodeRef, String userAuth, String role, boolean autoCreateAuthorSandbox) - { - long start = System.currentTimeMillis(); - - if (! (isContentManager(wpNodeRef) || - permissionService.hasPermission(wpNodeRef, PermissionService.ADD_CHILDREN) == AccessStatus.ALLOWED)) - { - throw new AccessDeniedException("Only content managers may invite web user"); - } - - WebProjectInfo wpInfo = getWebProject(wpNodeRef); - final String wpStoreId = wpInfo.getStoreId(); - - // build a list of managers who will have full permissions on ALL staging areas - List managers = new ArrayList(4); - - // retrieve the list of managers from the existing users - Map existingUserRoles = listWebUsers(wpNodeRef); - for (Map.Entry userRole : existingUserRoles.entrySet()) - { - String username = userRole.getKey(); - String userrole = userRole.getValue(); - - if (WCMUtil.ROLE_CONTENT_MANAGER.equals(userrole) && managers.contains(username) == false) - { - managers.add(username); - } - } - - // get permissions and roles for a web project folder type - Set perms = permissionService.getSettablePermissions(WCMAppModel.TYPE_AVMWEBFOLDER); - - NodeRef userRef = getWebUserRef(wpNodeRef, userAuth); - if (userRef != null) - { - // TODO - split out into separate 'change role' - // if user role has been changed then update required properties etc. - String oldUserRole = (String)nodeService.getProperty(userRef, WCMAppModel.PROP_WEBUSERROLE); - if (!role.equals(oldUserRole)) - { - // change in role - Map props = nodeService.getProperties(userRef); - props.put(WCMAppModel.PROP_WEBUSERNAME, userAuth); - props.put(WCMAppModel.PROP_WEBUSERROLE, role); - nodeService.setProperties(userRef, props); - - if (WCMUtil.ROLE_CONTENT_MANAGER.equals(role)) - { - managers.add(userAuth); - sandboxFactory.updateSandboxManagers(wpStoreId, managers); - } - else if (WCMUtil.ROLE_CONTENT_MANAGER.equals(oldUserRole)) - { - List managersToRemove = new LinkedList(); - managersToRemove.add(userAuth); - - sandboxFactory.removeSandboxManagers(wpStoreId, managersToRemove); - } - - List usersToUpdate = new LinkedList(); - usersToUpdate.add(sandboxFactory.new UserRoleWrapper(userAuth, oldUserRole, role)); - - sandboxFactory.updateSandboxRoles(wpStoreId, usersToUpdate, perms); - - if (logger.isDebugEnabled()) - { - logger.debug("Web user "+userAuth +"'s role has been changed from '" + oldUserRole + "' to '" + role + "' in "+(System.currentTimeMillis()-start)+" ms (store id: "+wpStoreId+")"); - } - } - } - else - { - if (autoCreateAuthorSandbox) - { - // create a sandbox for the user with permissions based on role - SandboxInfo sbInfo = sandboxFactory.createUserSandbox(wpStoreId, userAuth, role); - - List sandboxInfoList = new LinkedList(); - sandboxInfoList.add(sbInfo); - - // Bind the post-commit transaction listener with data required for virtualization server notification - CreateSandboxTransactionListener tl = new CreateSandboxTransactionListener(sandboxInfoList, listWebApps(wpNodeRef)); - AlfrescoTransactionSupport.bindListener(tl); - } - - // if this new user is a manager, we'll need to update the manager permissions applied - // to each existing user sandbox - to ensure that new user has access to them - if (WCMUtil.ROLE_CONTENT_MANAGER.equals(role)) - { - managers.add(userAuth); - sandboxFactory.updateSandboxManagers(wpStoreId, managers); - } - - sandboxFactory.addStagingAreaUser(wpStoreId, userAuth, role); - - // create an app:webuser instance for the user and assoc to the web project node - createWebUser(wpNodeRef, userAuth, role); - - // set permissions for the user - for (String permission : perms) - { - if (role.equals(permission)) - { - permissionService.setPermission(wpNodeRef, - userAuth, - permission, - true); - break; - } - } - - if (logger.isDebugEnabled()) - { - logger.debug("Invited web user: "+userAuth+" in "+(System.currentTimeMillis()-start)+" ms (store id: "+wpStoreId+")"); - } - } - } - - private void createWebUser(NodeRef wpNodeRef, String userName, String userRole) - { - // create an app:webuser instance for the user and assoc to the web project node - Map props = new HashMap(2, 1.0f); - props.put(WCMAppModel.PROP_WEBUSERNAME, userName); - props.put(WCMAppModel.PROP_WEBUSERROLE, userRole); - nodeService.createNode(wpNodeRef, - WCMAppModel.ASSOC_WEBUSER, - WCMAppModel.ASSOC_WEBUSER, - WCMAppModel.TYPE_WEBUSER, - props); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#uninviteWebUser(java.lang.String, java.lang.String) - */ - public void uninviteWebUser(String wpStoreId, String userAuth) - { - uninviteWebUser(getWebProjectNodeFromStore(wpStoreId), userAuth, false); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#uninviteWebUser(java.lang.String, java.lang.String, boolean) - */ - public void uninviteWebUser(String wpStoreId, String userAuth, boolean autoDeleteAuthorSandbox) - { - uninviteWebUser(getWebProjectNodeFromStore(wpStoreId), userAuth, autoDeleteAuthorSandbox); - } - - /* (non-Javadoc) - * @see org.alfresco.wcm.webproject.WebProjectService#uninviteWebUser(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, boolean) - */ - public void uninviteWebUser(NodeRef wpNodeRef, String userAuth, boolean autoDeleteAuthorSandbox) - { - long start = System.currentTimeMillis(); - - if (! isContentManager(wpNodeRef)) - { - throw new AccessDeniedException("Only content managers may uninvite web user '"+userAuth+"' from web project: "+wpNodeRef); - } - - ParameterCheck.mandatory("wpNodeRef", wpNodeRef); - ParameterCheck.mandatoryString("userAuth", userAuth); - - WebProjectInfo wpInfo = getWebProject(wpNodeRef); - String wpStoreId = wpInfo.getStoreId(); - String userMainStore = WCMUtil.buildUserMainStoreName(wpStoreId, userAuth); - - if (autoDeleteAuthorSandbox) - { - sandboxFactory.deleteSandbox(userMainStore); - } - - // remove the store reference from the website folder meta-data (see also WCMUtil.listWebUsers) - List userInfoRefs = nodeService.getChildAssocs(wpNodeRef, WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL); - - // retrieve the list of managers from the existing users - List managers = new ArrayList(4); - for (ChildAssociationRef ref : userInfoRefs) - { - NodeRef userInfoRef = ref.getChildRef(); - String username = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME); - String userrole = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE); - - if (WCMUtil.ROLE_CONTENT_MANAGER.equals(userrole) && managers.contains(username) == false) - { - managers.add(username); - } - } - - for (ChildAssociationRef ref : userInfoRefs) - { - NodeRef userInfoRef = ref.getChildRef(); - String user = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME); - - if (userAuth.equals(user)) - { - // remove the association to this web project user meta-data - nodeService.removeChild(wpNodeRef, ref.getChildRef()); - - // remove permission for the user (also fixes ETWOONE-338) - permissionService.clearPermission(wpNodeRef, userAuth); - - if (logger.isDebugEnabled()) - { - logger.debug("Uninvited web user: "+userAuth+" in "+(System.currentTimeMillis()-start)+" ms (store id: "+wpStoreId+")"); - } - - break; // for loop - } - } - } - - /** - * Find all nested user authorities contained with an authority - * - * @param authority The authority to search, USER authorities are returned immediately, GROUP authorites - * are recursively scanned for contained USER authorities. - * - * @return a Set of USER authorities - */ - private Set findNestedUserAuthorities(String authority) - { - Set users; - - AuthorityType authType = AuthorityType.getAuthorityType(authority); - if (authType.equals(AuthorityType.USER)) - { - users = new HashSet(1, 1.0f); - if (personService.personExists(authority) == true) - { - users.add(authority); - } - } - else if (authType.equals(AuthorityType.GROUP)) - { - // walk each member of the group - users = authorityService.getContainedAuthorities(AuthorityType.USER, authority, false); - for (String userAuth : users) - { - if (personService.personExists(userAuth) == false) - { - users.remove(userAuth); - } - } - } - else - { - users = Collections.emptySet(); - } - - return users; - } - - private String getWebProjectsPath() - { - return "/"+SPACES_COMPANY_HOME_CHILDNAME+"/"+SPACES_WCM_CHILDNAME; - } - - private static final String SPACES_COMPANY_HOME_CHILDNAME = "app:company_home"; // should match repository property: spaces.company_home.childname - private static final String SPACES_WCM_CHILDNAME = "app:wcm"; // should match repository property: spaces.wcm.childname - - - /** - * Create WebProject/WebApp Transaction listener - invoked after commit - */ - private class CreateWebAppTransactionListener extends TransactionListenerAdapter - { - private String wpStoreId; - private String webApp; - - public CreateWebAppTransactionListener(String wpStoreId, String webApp) - { - this.wpStoreId = wpStoreId; - this.webApp = webApp; - } - - /** - * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterCommit() - */ - @Override - public void afterCommit() - { - // post-commit - if (wpStoreId != null) - { - // update the virtualisation server with webapp - // performed after the main txn has committed successfully - String newStoreName = WCMUtil.buildStagingStoreName(wpStoreId); - - String path = WCMUtil.buildStoreWebappPath(newStoreName, webApp); - - WCMUtil.updateVServerWebapp(virtServerRegistry, path, true); - } - } - } - - /** - * Create Sandbox Transaction listener - invoked after commit - */ - private class CreateSandboxTransactionListener extends TransactionListenerAdapter - { - private List sandboxInfoList; - private List webAppNames; - - public CreateSandboxTransactionListener(List sandboxInfoList, List webAppNames) - { - this.sandboxInfoList = sandboxInfoList; - this.webAppNames = webAppNames; - } - - /** - * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterCommit() - */ - @Override - public void afterCommit() - { - // Handle notification to the virtualization server - // (this needs to occur after the sandboxes are created in the main txn) - - // reload virtualisation server for webapp(s) in this web project - for (SandboxInfo sandboxInfo : this.sandboxInfoList) - { - String newlyInvitedStoreName = WCMUtil.buildStagingStoreName(sandboxInfo.getMainStoreName()); - - for (String webAppName : webAppNames) - { - String path = WCMUtil.buildStoreWebappPath(newlyInvitedStoreName, webAppName); - WCMUtil.updateVServerWebapp(virtServerRegistry, path, true); - } - } - } - } -} diff --git a/source/java/org/alfresco/wcm/webproject/script/WebProject.java b/source/java/org/alfresco/wcm/webproject/script/WebProject.java deleted file mode 100644 index f331113e33..0000000000 --- a/source/java/org/alfresco/wcm/webproject/script/WebProject.java +++ /dev/null @@ -1,315 +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 . - */ -package org.alfresco.wcm.webproject.script; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -import org.alfresco.repo.jscript.ScriptNode; -import org.alfresco.repo.jscript.ScriptableHashMap; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.wcm.webproject.WebProjectInfo; -import org.alfresco.wcm.webproject.WebProjectService; -import org.alfresco.wcm.sandbox.SandboxInfo; -import org.alfresco.wcm.sandbox.SandboxService; -import org.alfresco.wcm.sandbox.script.Sandbox; - - -/** - * WebProject object to expose via JavaScript - */ -public class WebProject implements Serializable -{ - public static final String ROLE_CONTENT_MANAGER = "ContentManager"; - public static final String ROLE_CONTENT_PUBLISHER = "ContentPublisher"; - public static final String ROLE_CONTENT_REVIEWER = "ContentReviewer"; - public static final String ROLE_CONTENT_CONTRIBUTOR = "ContentContributor"; - - /** - * - */ - private static final long serialVersionUID = -2194205151549790079L; - - WebProjectInfo info; - - private String name; - private String title; - private String description; - private boolean isTemplate; - private String webProjectRef; - private WebProjects webprojects; - - /* - * Constructor for Outbound WebProjects - */ - public WebProject(WebProjects webprojects, WebProjectInfo info) - { - this.info = info; - this.name = info.getName(); - this.title = info.getTitle(); - this.description = info.getDescription(); - this.isTemplate = info.isTemplate(); - this.webProjectRef = info.getStoreId(); - this.webprojects = webprojects; - } - - public void setName(String name) { - this.name = name; - if(info != null) { - info.setName(name); - } - } - public String getName() { - return name; - } - - public void setTitle(String title) { - this.title = title; - if(info != null) { - info.setTitle(title); - } - } - public String getTitle() { - return title; - } - - public void setDescription(String description) { - this.description = description; - if(info != null) { - info.setDescription(description); - } - } - - public String getDescription() { - return description; - } - - - public void setTemplate(boolean isTemplate) { - this.isTemplate = isTemplate; - if(info != null) { - info.setIsTemplate(isTemplate); - } - } - - public void setTemplate(Boolean isTemplate) { - if (isTemplate != null) - { - this.setTemplate(isTemplate.booleanValue()); - } - } - - public boolean isTemplate() { - return isTemplate; - } - - // read-only property - public void setWebProjectRef(String webProjectRef) { - this.webProjectRef = webProjectRef; - } - - // - public String getWebProjectRef() - { - return webProjectRef; - } - - // read-only property - public NodeRef getNodeRef() - { - return info.getNodeRef(); - } - - /** - * delete this web project - */ - public void deleteWebProject() - { - getWebProjectService().deleteWebProject(webProjectRef); - } - - /** - * update this web project - */ - public void save() - { - getWebProjectService().updateWebProject(info); - } - - /** - * getSandboxes - * @param userName - * @return the sandboxes or an empty map if there are none. - */ - public ScriptableHashMap getSandboxes(String userName) - { - ScriptableHashMap result = new ScriptableHashMap(); - - // TODO at the moment the user can only have one sandbox - this will change in future - SandboxInfo si = getSandboxService().getAuthorSandbox(webProjectRef, userName); - if(si != null) - { - Sandbox sandbox = new Sandbox(this, si); - result.put(userName, sandbox); - } - return result; - } - - - /** - * Create a user sandbox, if the user already has a sandbox does nothing. - * @param userName - * @return the newly created sandbox details - */ - public Sandbox createSandbox(String userName) - { - SandboxInfo si = getSandboxService().createAuthorSandbox(webProjectRef, userName); - Sandbox sandbox = new Sandbox(this, si); - return sandbox; - } - - /** - * Get a single sandbox by its unique reference - * @param sandboxRef - * @return the sandbox or null if it is not found. - */ - public Sandbox getSandbox(String sandboxRef) - { - SandboxInfo si = getSandboxService().getSandbox(sandboxRef); - if(si != null) - { - Sandbox sandbox = new Sandbox(this, si); - return sandbox; - } - return null; - } - - /** - * getSandboxes for this web project - * @return the sandboxes - */ - public ScriptableHashMap getSandboxes() - { - List si = getSandboxService().listSandboxes(webProjectRef); - - ScriptableHashMap result = new ScriptableHashMap(); - - for(SandboxInfo s : si) - { - Sandbox b = new Sandbox(this, s); - result.put(b.getSandboxRef(), b); - } - - return result; - } - - /** - * Gets a user's role on this site. - *

- * If the user is not a member of the site then null is returned. - * - * @param userName user name - * @return String user's role or null if not a member - */ - public String getMembersRole(String userName) - { - return getWebProjectService().getWebUserRole(webProjectRef, userName); - } - - /** - * Sets the membership details for a user. - *

- * If the user is not already a member of the web project then they are invited with the role - * given. - *

- * Only a content manager can modify memberships and there must be at least one conttent manager at - * all times. - * - * @param userName user name - * @param role site role - */ - public void addMembership(String userName, String role) - { - getWebProjectService().inviteWebUser(webProjectRef, userName, role); - } - - /** - * Removes a users membership of the web project. - * - * Note: this will cascade delete the user's sandboxes without warning (even if there are modified items) - *

- * - * @param userName user name - */ - public void removeMembership(String userName) - { - getWebProjectService().uninviteWebUser(webProjectRef, userName); - } - - /** - * Gets a map of members of the web project with their role within the web project. - *

- * @return ScriptableHashMap list of members of site with their roles - */ - public ScriptableHashMap listMembers() - { - Map members = getWebProjectService().listWebUsers(webProjectRef); - - ScriptableHashMap result = new ScriptableHashMap(); - result.putAll(members); - - return result; - } - - /** - * List the role (name) for a WCM project - * @return a map of roles for a WCM project (value, name) - */ - public ScriptableHashMap getRoles() - { - //TODO Role names should be I811N from webclient.properties - //ContentManager=Content Manager - //ContentPublisher=Content Publisher - //ContentContributor=Content Contributor - //ContentReviewer=Content Reviewer - ScriptableHashMap result = new ScriptableHashMap(); - result.put(ROLE_CONTENT_MANAGER, "Content Manager"); - result.put(ROLE_CONTENT_PUBLISHER, "Content Publisher"); - result.put(ROLE_CONTENT_REVIEWER, "Content Reviewer"); - result.put(ROLE_CONTENT_CONTRIBUTOR, "Content Contributor"); - - return result; - } - - public WebProjects getWebProjects() - { - return this.webprojects; - } - - public SandboxService getSandboxService() - { - return getWebProjects().getSandboxService(); - } - - public WebProjectService getWebProjectService() - { - return getWebProjects().getWebProjectService(); - } -} diff --git a/source/java/org/alfresco/wcm/webproject/script/WebProjects.java b/source/java/org/alfresco/wcm/webproject/script/WebProjects.java deleted file mode 100644 index 0741989cb2..0000000000 --- a/source/java/org/alfresco/wcm/webproject/script/WebProjects.java +++ /dev/null @@ -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 . - */ -package org.alfresco.wcm.webproject.script; - -import java.util.List; - -import org.alfresco.repo.jscript.BaseScopableProcessorExtension; -import org.alfresco.repo.model.Repository; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.wcm.asset.AssetService; -import org.alfresco.wcm.sandbox.SandboxService; -import org.alfresco.wcm.webproject.WebProjectInfo; -import org.alfresco.wcm.webproject.WebProjectService; - - -/** - * Script object representing the wcm web projects script object. - * - * This class is the root for the script api to use wcm web projects. - */ -public class WebProjects extends BaseScopableProcessorExtension -{ - /** Service Registry */ - private ServiceRegistry serviceRegistry; - - /** The web projects service */ - private WebProjectService webProjectService; - - /** The sandbox service */ - private SandboxService sandboxService; - - /** The asset service */ - private AssetService assetService; - - /** The namespace service */ - private NamespaceService namespaceService; - - /** - * Sets the Service Registry - * - * @param serviceRegistry - */ - public void setServiceRegistry(ServiceRegistry serviceRegistry) - { - this.serviceRegistry = serviceRegistry; - } - - public ServiceRegistry getServiceRegistry() - { - return serviceRegistry; - } - - /** - * Set the wcm web project service - * - * @param webProjectService the wcm web project service - */ - public void setWebProjectService(WebProjectService webProjectService) - { - this.webProjectService = webProjectService; - } - - public WebProjectService getWebProjectService() - { - return this.webProjectService; - } - - /** - * Set the wcm sandbox service - * - * @param webProjectService the wcm web project service - */ - public void setSandboxService(SandboxService sandboxService) - { - this.sandboxService = sandboxService; - } - - public SandboxService getSandboxService() - { - return this.sandboxService; - } - - /** - * Set the wcm asset service - * - * @param assetService the wcm asset service - */ - public void setAssetService(AssetService assetService) - { - this.assetService = assetService; - } - - public AssetService getAssetService() - { - return this.assetService; - } - - /** - * Set the alfresco namespace service - * - * @param namespace service - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - public NamespaceService getNamespaceService() - { - return this.namespaceService; - } - - /** - * create web project - * @param name - * @param title - * @param description - * @return - */ - public WebProject createWebProject(String dnsName, String name, String title, String description ) - { - WebProjectInfo info = webProjectService.createWebProject(dnsName, name, title, description); - return new WebProject(this, info); - } - - /** - * Get an existing wcm web project - * @param webProjectRef - * @return the wcm web project - */ - public WebProject getWebProject(String webProjectRef) - { - WebProjectInfo info = webProjectService.getWebProject(webProjectRef); - - if(info != null){ - WebProject retVal = new WebProject(this, info); - return retVal; - } - return null; - } - - /* - * list All Web Projects - */ - public WebProject[] listWebProjects() - { - - List projects = webProjectService.listWebProjects(); - - WebProject[] ret = new WebProject[projects.size()]; - - int i= 0; - for(WebProjectInfo info : projects) - { - ret[i++] = new WebProject(this, info); - } - return ret; - } - - /* - * list All Web Projects which have the userName as a member - */ - public WebProject[] listWebProjects(String userName) - { - - List projects = webProjectService.listWebProjects(userName); - - WebProject[] ret = new WebProject[projects.size()]; - - int i= 0; - for(WebProjectInfo info : projects) - { - ret[i++] = new WebProject(this, info); - } - return ret; - } -} diff --git a/source/test-java/org/alfresco/repo/content/cleanup/ContentStoreCleanerTest.java b/source/test-java/org/alfresco/repo/content/cleanup/ContentStoreCleanerTest.java index 8e999b9b5d..b2e5b6bcf7 100644 --- a/source/test-java/org/alfresco/repo/content/cleanup/ContentStoreCleanerTest.java +++ b/source/test-java/org/alfresco/repo/content/cleanup/ContentStoreCleanerTest.java @@ -33,7 +33,6 @@ import org.alfresco.model.ContentModel; import org.alfresco.repo.content.ContentStore; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.UnsupportedContentUrlException; -import org.alfresco.repo.domain.avm.AVMNodeDAO; import org.alfresco.repo.domain.contentdata.ContentDataDAO; import org.alfresco.repo.lock.JobLockService; import org.alfresco.repo.security.authentication.AuthenticationUtil; @@ -88,7 +87,6 @@ public class ContentStoreCleanerTest extends TestCase jobLockService = serviceRegistry.getJobLockService(); TransactionService transactionService = serviceRegistry.getTransactionService(); DictionaryService dictionaryService = serviceRegistry.getDictionaryService(); - AVMNodeDAO avmNodeDAO = (AVMNodeDAO) ctx.getBean("newAvmNodeDAO"); ContentDataDAO contentDataDAO = (ContentDataDAO) ctx.getBean("contentDataDAO"); // we need a store @@ -114,7 +112,6 @@ public class ContentStoreCleanerTest extends TestCase cleaner.setTransactionService(transactionService); cleaner.setDictionaryService(dictionaryService); cleaner.setContentService(contentService); - cleaner.setAvmNodeDAO(avmNodeDAO); } public void tearDown() throws Exception diff --git a/source/test-java/org/alfresco/repo/rendition/MockedTestServiceRegistry.java b/source/test-java/org/alfresco/repo/rendition/MockedTestServiceRegistry.java index fc22f0b4a7..d759875beb 100644 --- a/source/test-java/org/alfresco/repo/rendition/MockedTestServiceRegistry.java +++ b/source/test-java/org/alfresco/repo/rendition/MockedTestServiceRegistry.java @@ -22,7 +22,6 @@ import static org.mockito.Mockito.mock; import java.util.Collection; -import org.alfresco.mbeans.VirtServerRegistry; import org.alfresco.opencmis.dictionary.CMISDictionaryService; import org.alfresco.opencmis.search.CMISQueryService; import org.alfresco.repo.admin.SysAdminParams; @@ -36,10 +35,6 @@ import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.admin.RepoAdminService; import org.alfresco.service.cmr.attributes.AttributeService; import org.alfresco.service.cmr.audit.AuditService; -import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.avm.deploy.DeploymentService; -import org.alfresco.service.cmr.avm.locking.AVMLockingService; -import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.blog.BlogService; import org.alfresco.service.cmr.calendar.CalendarService; import org.alfresco.service.cmr.coci.CheckOutCheckInService; @@ -81,10 +76,6 @@ import org.alfresco.service.descriptor.DescriptorService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; -import org.alfresco.wcm.asset.AssetService; -import org.alfresco.wcm.preview.PreviewURIService; -import org.alfresco.wcm.sandbox.SandboxService; -import org.alfresco.wcm.webproject.WebProjectService; public class MockedTestServiceRegistry implements ServiceRegistry { @@ -117,20 +108,6 @@ public class MockedTestServiceRegistry implements ServiceRegistry return null; } - @Override - public WebProjectService getWebProjectService() - { - // A mock response - return null; - } - - @Override - public VirtServerRegistry getVirtServerRegistry() - { - // A mock response - return null; - } - @Override public VersionService getVersionService() { @@ -200,13 +177,6 @@ public class MockedTestServiceRegistry implements ServiceRegistry return null; } - @Override - public SandboxService getSandboxService() - { - // A mock response - return null; - } - @Override public RuleService getRuleService() { @@ -228,13 +198,6 @@ public class MockedTestServiceRegistry implements ServiceRegistry return null; } - @Override - public PreviewURIService getPreviewURIService() - { - // A mock response - return null; - } - @Override public PersonService getPersonService() { @@ -387,20 +350,6 @@ public class MockedTestServiceRegistry implements ServiceRegistry return null; } - @Override - public DeploymentService getDeploymentService() - { - // A mock response - return null; - } - - @Override - public CrossRepositoryCopyService getCrossRepositoryCopyService() - { - // A mock response - return null; - } - @Override public CopyService getCopyService() { @@ -478,13 +427,6 @@ public class MockedTestServiceRegistry implements ServiceRegistry return null; } - @Override - public AssetService getAssetService() - { - // A mock response - return null; - } - @Override public ActionService getActionService() { @@ -492,34 +434,6 @@ public class MockedTestServiceRegistry implements ServiceRegistry return actionService; } - @Override - public AVMSyncService getAVMSyncService() - { - // A mock response - return null; - } - - @Override - public AVMService getAVMService() - { - // A mock response - return null; - } - - @Override - public AVMLockingService getAVMLockingService() - { - // A mock response - return null; - } - - @Override - public AVMService getAVMLockingAwareService() - { - // A mock response - return null; - } - @Override public RepoAdminService getRepoAdminService() { diff --git a/source/test-java/org/alfresco/repo/security/permissions/impl/AbstractReadPermissionTest.java b/source/test-java/org/alfresco/repo/security/permissions/impl/AbstractReadPermissionTest.java index 67ba95d6a8..a07ec1c66e 100644 --- a/source/test-java/org/alfresco/repo/security/permissions/impl/AbstractReadPermissionTest.java +++ b/source/test-java/org/alfresco/repo/security/permissions/impl/AbstractReadPermissionTest.java @@ -11,7 +11,6 @@ import junit.framework.TestCase; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; -import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.domain.node.NodeDAO; import org.alfresco.repo.domain.permissions.AccessControlListDAO; @@ -28,8 +27,6 @@ import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.avm.AVMNodeDescriptor; -import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.repository.ContentWriter; @@ -47,8 +44,6 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; -import org.alfresco.wcm.util.WCMUtil; -import org.alfresco.wcm.webproject.WebProjectService; import org.springframework.context.ApplicationContext; import org.springframework.orm.hibernate3.LocalSessionFactoryBean; @@ -106,28 +101,17 @@ public class AbstractReadPermissionTest extends TestCase protected UserTransaction testTX; - protected AVMService fService; protected IndexerAndSearcher fIndexerAndSearcher; - protected WebProjectService wpService; protected boolean logToFile = false; protected String[] webAuthorities = new String[] {"Web1", "Web2", "Web3", "Web4", "Web5"}; - protected String[] authorities = new String[] {"Dynamic","1000","1001","Y","Z","X","10_1","avm","100","10","1","01","001","0001"}; - - protected String AVMStore = "main" + System.currentTimeMillis(); + protected String[] authorities = new String[] {"Dynamic","1000","1001","Y","Z","X","10_1","100","10","1","01","001","0001"}; final int WEB_COUNT = 100; - protected final String TEST_RUN = ""+System.currentTimeMillis(); - protected final String TEST_WEBPROJ_DNS = "testWP-"+TEST_RUN; - protected final String TEST_WEBPROJ_NAME = "testSandbox Web Project Display Name - "+TEST_RUN; - protected final String TEST_WEBPROJ_TITLE = "This is my title"; - protected final String TEST_WEBPROJ_DESCRIPTION = "This is my description"; - protected final String TEST_WEBPROJ_DEFAULT_WEBAPP = WCMUtil.DIR_ROOT; - protected final boolean TEST_WEBPROJ_USE_AS_TEMPLATE = true; - protected final boolean TEST_WEBPROJ_DONT_USE_AS_TEMPLATE = false; +// protected final String TEST_RUN = ""+System.currentTimeMillis(); protected class Counter { @@ -430,127 +414,6 @@ public class AbstractReadPermissionTest extends TestCase } } - - protected void setupBasicTree(final String authority) throws Exception - { - runAs("admin"); - - final String[] dirs = new String[] {"a", "a/b", "a/b/c", "a/b/c/d", "e", "e/f", "e/f/g", "e/f/g/h", "x", "x/y"}; - - for(int j = 0; j < dirs.length; j++) - { - String path = dirs[j]; - String dir; - String file; - int k = path.lastIndexOf('/'); - if(k == -1) - { - dir = ""; - file = path; - } - else - { - dir = path.substring(0, k); - file = path.substring(k+1); - } - fService.createDirectory(AVMStore + ":/" + dir, file); - } - -// fService.createDirectory("main:/", "a"); -// fService.createDirectory("main:/a", "b"); -// fService.createDirectory("main:/a/b", "c"); -// fService.createDirectory("main:/", "d"); -// fService.createDirectory("main:/d", "e"); -// fService.createDirectory("main:/d/e", "f"); - -// desc = avmService.lookup(-1, storeName + ":/base"); -// nodeRef = AVMNodeConverter.ToNodeRef(-1, desc.getPath()); -// permissionService.setPermission(nodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.ALL_PERMISSIONS, true); -// permissionService.deletePermission(nodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.ALL_PERMISSIONS); - - AVMNodeDescriptor nodeDesc = fService.lookup(-1, AVMStore + ":/"); - NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, nodeDesc.getPath()); - //permissionService.setPermission(nodeRef, "1", PermissionService.READ, true); - -// for(int ii = 0; ii < COUNT; ii++) -// { -// final int i = ii; -// final int j = -// if(ii % 100 == 0) -// { -// System.out.println("Loop " + i); -// } - RetryingTransactionCallback cb = new RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - for(int i = 0; i < WEB_COUNT; i++) - { - if(i % 100 == 0) - { - System.out.println("Loop " + i); - } - int j = i % webAuthorities.length; - - String dir = AVMStore + ":/" + dirs[i % 10]; - String file = "foo" + i; - String path = dir + "/" + file; - - fService.createFile(dir, file).close(); - ContentWriter writer = fService.getContentWriter(path, true); - writer.setEncoding("UTF-8"); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - //writer.putContent("I am " + path); - writer.putContent("I am main"); - - //String authority = webAuthorities[j]; - NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, path); - permissionService.setPermission(nodeRef, authority, PermissionService.READ, true); - permissionService.setInheritParentPermissions(nodeRef, false); - } - - return null; - } - }; - retryingTransactionHelper.doInTransaction(cb, false, false); - //} - -// fService.createDirectory("main:/", "a"); -// fService.createDirectory("main:/a", "b"); -// fService.createDirectory("main:/a/b", "c"); -// fService.createDirectory("main:/", "d"); -// fService.createDirectory("main:/d", "e"); -// fService.createDirectory("main:/d/e", "f"); -// -// AVMNodeDescriptor nodeDesc = fService.lookup(-1, "main:/"); -// NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, nodeDesc.getPath()); -// permissionService.setPermission(nodeRef, "1", PermissionService.READ, true); - -// fService.createFile("main:/a/b/c", "foo").close(); -// ContentWriter writer = fService.getContentWriter("main:/a/b/c/foo", true); -// writer.setEncoding("UTF-8"); -// writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); -// writer.putContent("I am main:/a/b/c/foo"); - -// AVMNodeDescriptor nodeDesc = fService.lookup(-1, "main:/a/b/c/foo"); -// NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, nodeDesc.getPath()); -// permissionService.setPermission(nodeRef, "1", PermissionService.READ, true); - -// fService.createFile("main:/a/b/c", "bar").close(); -// writer = fService.getContentWriter("main:/a/b/c/bar", true); -// writer.setEncoding("UTF-8"); -// writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); -// writer.putContent("I am main:/a/b/c/bar"); - -// nodeDesc = fService.lookup(-1, "main:/a/b/c/foo"); -// nodeRef = AVMNodeConverter.ToNodeRef(-1, nodeDesc.getPath()); -// permissionService.setPermission(nodeRef, "1", PermissionService.READ, true); - - fService.createSnapshot(AVMStore, null, null); - - //testTX.commit(); - } - protected void deleteAuthentication(String name) { if(authenticationDAO.userExists(name)) @@ -636,15 +499,7 @@ public class AbstractReadPermissionTest extends TestCase } authenticationService.createAuthentication(AuthenticationUtil.getAdminUserName(), "admin".toCharArray()); - fService = (AVMService)applicationContext.getBean("AVMService"); fIndexerAndSearcher = (IndexerAndSearcher)applicationContext.getBean("indexerAndSearcherFactory"); - wpService = (WebProjectService)applicationContext.getBean("WebProjectService"); - - if (fService.getStore(AVMStore) != null) - { - fService.purgeStore(AVMStore); - } - fService.createStore(AVMStore); for(String authority : authorities) { diff --git a/source/test-java/org/alfresco/repo/security/permissions/impl/ReadPermissionTest.java b/source/test-java/org/alfresco/repo/security/permissions/impl/ReadPermissionTest.java index a743eb390a..2c0eaf567f 100644 --- a/source/test-java/org/alfresco/repo/security/permissions/impl/ReadPermissionTest.java +++ b/source/test-java/org/alfresco/repo/security/permissions/impl/ReadPermissionTest.java @@ -1,7 +1,6 @@ package org.alfresco.repo.security.permissions.impl; import org.alfresco.model.ContentModel; -import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.repository.NodeRef; @@ -65,60 +64,6 @@ public class ReadPermissionTest extends AbstractReadPermissionTest results.close(); } - public void testAVM() throws Exception - { - try - { - runAs("admin"); - - setupBasicTree("Web1"); - - runAs("Web1"); - - StoreRef storeRef = AVMNodeConverter.ToStoreRef(AVMStore); - long start; - long end; - SearchParameters sp; - ResultSet results; - - // Text index - sp = new SearchParameters(); - sp.addStore(storeRef); - sp.setLanguage(SearchService.LANGUAGE_LUCENE); - sp.setQuery("TYPE:\"cm:content\""); - sp.setMaxItems(Integer.MAX_VALUE); - sp.setMaxPermissionChecks(Integer.MAX_VALUE); - sp.setMaxPermissionCheckTimeMillis(Integer.MAX_VALUE); - start = System.nanoTime(); - results = serviceRegistry.getSearchService().query(sp); - assertEquals(WEB_COUNT, results.length()); - results.close(); - end = System.nanoTime(); - System.out.println("AVM in "+((end-start)/1e9)); - - sp = new SearchParameters(); - sp.addStore(storeRef); - sp.setLanguage(SearchService.LANGUAGE_LUCENE); - // sp.setQuery("TEXT:\"I am\""); - sp.setQuery("TYPE:\"cm:content\""); - sp.setMaxItems(Integer.MAX_VALUE); - sp.setMaxPermissionChecks(Integer.MAX_VALUE); - sp.setMaxPermissionCheckTimeMillis(Integer.MAX_VALUE); - start = System.nanoTime(); - results = serviceRegistry.getSearchService().query(sp); - assertEquals(WEB_COUNT, results.length()); - results.close(); - end = System.nanoTime(); - System.out.println("AVM in "+((end-start)/1e9)); - - } - catch (Exception e) - { - e.printStackTrace(); - throw e; - } - } - public void testReadDeny() { SearchParameters sp;