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