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.plugins.blog.repository; 018 019import java.util.ArrayList; 020 021import org.ametys.cms.repository.Content; 022import org.ametys.plugins.repository.AmetysObjectIterable; 023import org.ametys.plugins.repository.AmetysRepositoryException; 024import org.ametys.plugins.repository.CollectionIterable; 025import org.ametys.plugins.repository.metadata.CompositeMetadata; 026import org.ametys.web.repository.page.Page; 027import org.ametys.web.repository.page.Zone; 028import org.ametys.web.repository.page.ZoneItem; 029 030/** 031 * {@link Zone} holding a post {@link Content}. 032 */ 033public class PostZone implements Zone 034{ 035 private VirtualPostPage _page; 036 037 /** 038 * Constructor 039 * @param page the parent {@link VirtualPostPage}. 040 */ 041 public PostZone(VirtualPostPage page) 042 { 043 _page = page; 044 } 045 046 @Override 047 public Page getPage() 048 { 049 return _page; 050 } 051 052 @Override 053 public AmetysObjectIterable<? extends ZoneItem> getZoneItems() throws AmetysRepositoryException 054 { 055 ArrayList<ZoneItem> zoneItems = new ArrayList<>(); 056 zoneItems.add(new PostZoneItem(_page)); 057 return new CollectionIterable<>(zoneItems); 058 } 059 060 @Override 061 public CompositeMetadata getMetadataHolder() 062 { 063 return new StaticCompositeMetadata(); 064 } 065 066 @Override 067 public String getId() throws AmetysRepositoryException 068 { 069 return "postZone://unused?pageId=" + _page.getId(); 070 } 071 072 @Override 073 public String getName() throws AmetysRepositoryException 074 { 075 return "default"; 076 } 077 078 @SuppressWarnings("unchecked") 079 @Override 080 public Page getParent() throws AmetysRepositoryException 081 { 082 return _page; 083 } 084 085 @Override 086 public String getParentPath() throws AmetysRepositoryException 087 { 088 return _page.getPath(); 089 } 090 091 @Override 092 public String getPath() throws AmetysRepositoryException 093 { 094 return _page.getPath() + "/default"; 095 } 096}