001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.loader;
029
030import org.opencms.file.CmsObject;
031import org.opencms.file.CmsPropertyDefinition;
032import org.opencms.file.CmsResource;
033import org.opencms.main.CmsException;
034import org.opencms.xml.I_CmsXmlDocument;
035import org.opencms.xml.page.CmsXmlPageFactory;
036
037import javax.servlet.ServletRequest;
038
039/**
040 * OpenCms loader for resources of type <code>{@link org.opencms.file.types.CmsResourceTypeXmlPage}</code>.<p>
041 *
042 * @since 6.0.0
043 */
044public class CmsXmlPageLoader extends A_CmsXmlDocumentLoader {
045
046    /** The id of this loader. */
047    public static final int RESOURCE_LOADER_ID = 9;
048
049    /**
050     * @see org.opencms.loader.I_CmsResourceLoader#getLoaderId()
051     */
052    public int getLoaderId() {
053
054        return RESOURCE_LOADER_ID;
055    }
056
057    /**
058     * Returns a String describing this resource loader, which is (localized to the system default locale)
059     * <code>"The OpenCms default resource loader for xml pages"</code>.<p>
060     *
061     * @return a describing String for the ResourceLoader
062     */
063    public String getResourceLoaderInfo() {
064
065        return Messages.get().getBundle().key(Messages.GUI_LOADER_XMLPAGE_DEFAULT_DESC_0);
066    }
067
068    /**
069     * @see org.opencms.loader.A_CmsXmlDocumentLoader#unmarshalXmlDocument(org.opencms.file.CmsObject, org.opencms.file.CmsResource, javax.servlet.ServletRequest)
070     */
071    @Override
072    protected I_CmsXmlDocument unmarshalXmlDocument(CmsObject cms, CmsResource resource, ServletRequest req)
073    throws CmsException {
074
075        return CmsXmlPageFactory.unmarshal(cms, resource, req);
076    }
077
078    /**
079     * @see org.opencms.loader.A_CmsXmlDocumentLoader#getTemplatePropertyDefinition()
080     */
081    @Override
082    protected String getTemplatePropertyDefinition() {
083
084        return CmsPropertyDefinition.PROPERTY_TEMPLATE;
085    }
086}