001/* 002 * Copyright 2017 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.workspaces.cmis; 017 018import org.apache.avalon.framework.component.Component; 019import org.apache.avalon.framework.service.ServiceException; 020import org.apache.avalon.framework.service.ServiceManager; 021import org.apache.avalon.framework.service.Serviceable; 022import org.apache.chemistry.opencmis.commons.impl.server.AbstractServiceFactory; 023import org.apache.chemistry.opencmis.commons.server.CallContext; 024import org.apache.chemistry.opencmis.commons.server.CmisService; 025import org.apache.excalibur.source.SourceResolver; 026 027import org.ametys.core.authentication.token.AuthenticationTokenManager; 028import org.ametys.core.user.CurrentUserProvider; 029import org.ametys.core.user.UserManager; 030import org.ametys.plugins.explorer.resources.actions.AddOrUpdateResourceHelper; 031import org.ametys.plugins.repository.AmetysObjectResolver; 032import org.ametys.plugins.workspaces.documents.DocumentWorkspaceModule; 033import org.ametys.plugins.workspaces.documents.WorkspaceExplorerResourceDAO; 034import org.ametys.plugins.workspaces.project.ProjectManager; 035import org.ametys.plugins.workspaces.project.modules.WorkspaceModuleExtensionPoint; 036import org.ametys.web.repository.site.SiteManager; 037 038/** 039 * Factory for {@link CmisServiceImpl} 040 */ 041public class CmisServiceFactory extends AbstractServiceFactory implements Component, Serviceable 042{ 043 /** The avalon role */ 044 public static final String ROLE = CmisServiceFactory.class.getName(); 045 private ProjectManager _projectManager; 046 private WorkspaceExplorerResourceDAO _workspaceExplorerResourceDAO; 047 private DocumentWorkspaceModule _documentModule; 048 private AmetysObjectResolver _resolver; 049 private CmisTypeManager _typeManager; 050 private UserManager _userManager; 051 private AuthenticationTokenManager _authenticationTokenManager; 052 private SourceResolver _sourceResolver; 053 private CurrentUserProvider _currentUserProvider; 054 private SiteManager _siteManager; 055 private AddOrUpdateResourceHelper _addOrUpdateResourceHelper; 056 057 @Override 058 public CmisService getService(CallContext context) 059 { 060 return new CmisServiceImpl(context, this); 061 } 062 063 public void service(ServiceManager manager) throws ServiceException 064 { 065 _projectManager = (ProjectManager) manager.lookup(ProjectManager.ROLE); 066 _resolver = (AmetysObjectResolver) manager.lookup(AmetysObjectResolver.ROLE); 067 _userManager = (UserManager) manager.lookup(UserManager.ROLE); 068 _workspaceExplorerResourceDAO = (WorkspaceExplorerResourceDAO) manager.lookup(WorkspaceExplorerResourceDAO.ROLE); 069 070 WorkspaceModuleExtensionPoint moduleManagerEP = (WorkspaceModuleExtensionPoint) manager.lookup(WorkspaceModuleExtensionPoint.ROLE); 071 _documentModule = moduleManagerEP.getModule(DocumentWorkspaceModule.DODUMENT_MODULE_ID); 072 073 _authenticationTokenManager = (AuthenticationTokenManager) manager.lookup(AuthenticationTokenManager.ROLE); 074 _sourceResolver = (SourceResolver) manager.lookup(SourceResolver.ROLE); 075 _currentUserProvider = (CurrentUserProvider) manager.lookup(CurrentUserProvider.ROLE); 076 _siteManager = (SiteManager) manager.lookup(SiteManager.ROLE); 077 _addOrUpdateResourceHelper = (AddOrUpdateResourceHelper) manager.lookup(AddOrUpdateResourceHelper.ROLE); 078 _typeManager = new CmisTypeManager(); 079 } 080 081 /** 082 * ProjectManager 083 * @return ProjectManager 084 */ 085 public ProjectManager getProjectManager() 086 { 087 return _projectManager; 088 } 089 090 /** 091 * WorkspaceExplorerResourceDAO 092 * @return WorkspaceExplorerResourceDAO 093 */ 094 public WorkspaceExplorerResourceDAO getWorkspaceExplorerResourceDAO() 095 { 096 return _workspaceExplorerResourceDAO; 097 } 098 099 /** 100 * AmetysObjectResolver 101 * @return AmetysObjectResolver 102 */ 103 public AmetysObjectResolver getResolver() 104 { 105 return _resolver; 106 } 107 108 /** 109 * CmisTypeManager 110 * @return CmisTypeManager 111 */ 112 public CmisTypeManager getTypeManager() 113 { 114 return _typeManager; 115 } 116 117 /** 118 * UserManager 119 * @return UserManager 120 */ 121 public UserManager getUserManager() 122 { 123 return _userManager; 124 } 125 126 /** 127 * AuthenticationTokenManager 128 * @return AuthenticationTokenManager 129 */ 130 public AuthenticationTokenManager getAuthenticationTokenManager() 131 { 132 return _authenticationTokenManager; 133 } 134 135 /** 136 * SourceResolver 137 * @return SourceResolver 138 */ 139 public SourceResolver getSourceResolver() 140 { 141 return _sourceResolver; 142 } 143 144 /** 145 * CurrentUserProvider 146 * @return CurrentUserProvider 147 */ 148 public CurrentUserProvider getCurrentUserProvider() 149 { 150 return _currentUserProvider; 151 } 152 153 /** 154 * SiteManager 155 * @return SiteManager 156 */ 157 public SiteManager getSiteManager() 158 { 159 return _siteManager; 160 } 161 162 /** 163 * DocumentWorkspaceModule 164 * @return DocumentWorkspaceModule 165 */ 166 public DocumentWorkspaceModule getDocumentModule() 167 { 168 return _documentModule; 169 } 170 171 /** 172 * AddOrUpdateResourceHelper 173 * @return AddOrUpdateResourceHelper 174 */ 175 public AddOrUpdateResourceHelper getAddOrUpdateResourceHelper() 176 { 177 return _addOrUpdateResourceHelper; 178 } 179 180 181}