001/* 002 * Copyright 2010 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.odf.orgunit; 017 018import javax.jcr.Node; 019 020import org.apache.avalon.framework.service.ServiceException; 021import org.apache.avalon.framework.service.ServiceManager; 022 023import org.ametys.cms.repository.ContentFactory; 024import org.ametys.cms.repository.ModifiableContentFactory; 025import org.ametys.odf.cdmfr.ExportCDMfrManager; 026import org.ametys.plugins.repository.AmetysRepositoryException; 027import org.ametys.plugins.repository.RepositoryConstants; 028 029/** 030 * {@link ContentFactory} for handling {@link OrgUnit} 031 */ 032public class OrgUnitFactory extends ModifiableContentFactory 033{ 034 /** {@link OrgUnit} nodetype for resources collection */ 035 public static final String ORGUNIT_NODETYPE = RepositoryConstants.NAMESPACE_PREFIX + ":orgunitContent"; 036 037 /** {@link OrgUnit} content type */ 038 public static final String ORGUNIT_CONTENT_TYPE = "org.ametys.plugins.odf.Content.orgunit"; 039 040 /** The root OrgUnit node name */ 041 public static final String ODF_ORGUNIT_ROOT_NODE = "root-orgunit"; 042 043 private RootOrgUnitProvider _rootOrgUnitProvider; 044 private ExportCDMfrManager _exportCDMfrManager; 045 046 @Override 047 public void service(ServiceManager manager) throws ServiceException 048 { 049 super.service(manager); 050 _rootOrgUnitProvider = (RootOrgUnitProvider) manager.lookup(RootOrgUnitProvider.ROLE); 051 _exportCDMfrManager = (ExportCDMfrManager) manager.lookup(ExportCDMfrManager.ROLE); 052 } 053 054 @Override 055 public OrgUnit getAmetysObject(Node node, String parentPath) throws AmetysRepositoryException 056 { 057 return new OrgUnit(node, parentPath, this); 058 } 059 060 String _getRootOrgUnitUAI() 061 { 062 return _rootOrgUnitProvider.getRoot().getUAICode(); 063 } 064 065 ExportCDMfrManager _getExportCDMfrManager() 066 { 067 return _exportCDMfrManager; 068 } 069}