001/*
002 *  Copyright 2013 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.queriesdirectory;
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.contenttype.ContentTypeExtensionPoint;
024import org.ametys.core.group.GroupManager;
025import org.ametys.plugins.repository.AmetysObjectFactory;
026import org.ametys.plugins.repository.AmetysRepositoryException;
027import org.ametys.plugins.repository.RepositoryConstants;
028import org.ametys.plugins.repository.jcr.DefaultAmetysObjectFactory;
029
030
031/**
032 * {@link AmetysObjectFactory} for handling {@link Query}s.
033 */
034public class QueryFactory extends DefaultAmetysObjectFactory
035{
036    
037    /** JCR nodetype for query */
038    public static final String QUERY_NODETYPE = RepositoryConstants.NAMESPACE_PREFIX + ":query";
039    
040    /** Group manager */
041    protected GroupManager _groupManager;
042    
043    /** Content type extension point */
044    protected ContentTypeExtensionPoint _cTypeEP;
045    
046    @Override
047    public void service(ServiceManager manager) throws ServiceException
048    {
049        super.service(manager);
050        _cTypeEP = (ContentTypeExtensionPoint) manager.lookup(ContentTypeExtensionPoint.ROLE);
051        _groupManager = (GroupManager) manager.lookup(GroupManager.ROLE);
052    }
053    
054    @Override
055    public Query getAmetysObject(Node node, String parentPath) throws AmetysRepositoryException
056    {
057        return new Query(node, parentPath, this);
058    }
059    
060    /**
061     * Group manager getter.
062     * @return The group manager
063     */
064    GroupManager _getGroupManager()
065    {
066        return _groupManager;
067    }
068    
069    /**
070     * Getter for the content type extension point
071     * @return The content type EP.
072     */
073    ContentTypeExtensionPoint _getContentTypeExtensionPoint()
074    {
075        return _cTypeEP;
076    }
077    
078    
079    
080}