001/* 002 * Copyright 2011 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 */ 016 017package org.ametys.web.repository.dom; 018 019import java.util.HashMap; 020import java.util.Map; 021 022import org.w3c.dom.Element; 023 024import org.ametys.cms.tag.TagProviderExtensionPoint; 025import org.ametys.core.right.RightManager; 026import org.ametys.core.user.UserIdentity; 027import org.ametys.core.util.dom.AmetysAttribute; 028import org.ametys.web.renderingcontext.RenderingContextHandler; 029import org.ametys.web.repository.page.PagesContainer; 030import org.ametys.web.repository.sitemap.Sitemap; 031 032/** 033 * DOM {@link Element} wrapping a {@link Sitemap}. 034 */ 035public class SitemapElement extends AbstractPagesContainerElement<Sitemap> 036{ 037 /** 038 * Constructor. 039 * @param sitemap the wrapped {@link Sitemap}. 040 * @param currentPagePath the path of the current page, or null if none. 041 * @param rightManager the right manager 042 * @param renderingContextHandler the {@link RenderingContextHandler}. 043 * @param userIdentity the identity of the current user, or null if none. 044 * @param depth The depth to get. 1 for root pages, 0 for this node only, -1 for infinite. 045 * @param includeInvisiblePages Should return child invisible pages 046 * @param tagProviderExtensionPoint the tag provider extension point 047 */ 048 public SitemapElement(Sitemap sitemap, String currentPagePath, RightManager rightManager, RenderingContextHandler renderingContextHandler, UserIdentity userIdentity, long depth, boolean includeInvisiblePages, TagProviderExtensionPoint tagProviderExtensionPoint) 049 { 050 this(sitemap, null, rightManager, renderingContextHandler, currentPagePath, userIdentity, depth, includeInvisiblePages, tagProviderExtensionPoint); 051 } 052 053 /** 054 * Constructor. 055 * @param sitemap the wrapped {@link Sitemap}. 056 * @param parent the parent container. 057 * @param rightManager the right manager 058 * @param currentPagePath the path of the current page, or null if none. 059 * @param renderingContextHandler the {@link RenderingContextHandler}. 060 * @param userIdentity the identity of the current user, or null if none. 061 * @param depth The depth to get. 1 for root pages, 0 for this node only, -1 for infinite. 062 * @param includeInvisiblePages Should return child invisible pages 063 * @param tagProviderExtensionPoint the tag provider extension point 064 */ 065 public SitemapElement(Sitemap sitemap, AbstractPagesContainerElement<PagesContainer> parent, RightManager rightManager, RenderingContextHandler renderingContextHandler, String currentPagePath, UserIdentity userIdentity, long depth, boolean includeInvisiblePages, TagProviderExtensionPoint tagProviderExtensionPoint) 066 { 067 super(sitemap, parent, rightManager, renderingContextHandler, currentPagePath, userIdentity, depth, includeInvisiblePages, tagProviderExtensionPoint); 068 } 069 070 @Override 071 public String getTagName() 072 { 073 return "sitemap"; 074 } 075 076 @Override 077 protected Map<String, AmetysAttribute> _lookupAttributes() 078 { 079 Map<String, AmetysAttribute> result = new HashMap<>(); 080 081 result.put("xmlns:sitemap", new AmetysAttribute("xmlns:sitemap", "xmlns:sitemap", null, NAMESPACE_URI, this)); 082 result.put(NAMESPACE_PREFIX + ":site", new AmetysAttribute("site", NAMESPACE_PREFIX + ":site", NAMESPACE_URI, _object.getSiteName(), this)); 083 result.put(NAMESPACE_PREFIX + ":lang", new AmetysAttribute("lang", NAMESPACE_PREFIX + ":lang", NAMESPACE_URI, _object.getName(), this)); 084 result.put(NAMESPACE_PREFIX + ":id", new AmetysAttribute("id", NAMESPACE_PREFIX + ":id", NAMESPACE_URI, _object.getId(), this)); 085 086 result.putAll(super._lookupAttributes()); 087 088 return result; 089 } 090}