001/* 002 * Copyright 2010 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.odfweb.repository; 018 019import org.ametys.odf.program.AbstractProgram; 020import org.ametys.odf.program.Program; 021import org.ametys.plugins.repository.AmetysRepositoryException; 022import org.ametys.plugins.repository.metadata.CompositeMetadata; 023import org.ametys.web.repository.page.Zone; 024import org.ametys.web.repository.page.ZoneItem; 025 026/** 027 * {@link ZoneItem} holding a {@link Program}. 028 */ 029public class ProgramZoneItem implements ZoneItem 030{ 031 private ProgramPage _page; 032 033 /** 034 * Constructor. 035 * @param page the parent {@link ProgramPage}. 036 */ 037 public ProgramZoneItem(ProgramPage page) 038 { 039 _page = page; 040 } 041 042 @SuppressWarnings("unchecked") 043 @Override 044 public AbstractProgram getContent() throws AmetysRepositoryException 045 { 046 AbstractProgram program = _page.getProgram(); 047 program.setContextPath(_page.getPathInSitemap()); 048 return program; 049 } 050 051 @Override 052 public String getMetadataSetName() throws AmetysRepositoryException 053 { 054 return "main"; 055 } 056 057 @Override 058 public String getServiceId() throws AmetysRepositoryException 059 { 060 throw new UnsupportedOperationException("getServiceId not supported on virtual odf pages"); 061 } 062 063 @Override 064 public CompositeMetadata getServiceParameters() throws AmetysRepositoryException 065 { 066 throw new UnsupportedOperationException("getServiceParameters not supported on virtual odf pages"); 067 } 068 069 @Override 070 public ZoneType getType() throws AmetysRepositoryException 071 { 072 return ZoneType.CONTENT; 073 } 074 075 @Override 076 public Zone getZone() 077 { 078 return new ProgramZone(_page); 079 } 080 081 @Override 082 public CompositeMetadata getMetadataHolder() 083 { 084 return new StaticCompositeMetadata(); 085 } 086 087 @Override 088 public String getId() throws AmetysRepositoryException 089 { 090 return "programZoneItem://unused?pageId=" + _page.getId(); 091 } 092 093 @Override 094 public String getName() throws AmetysRepositoryException 095 { 096 return "default"; 097 } 098 099 @SuppressWarnings("unchecked") 100 @Override 101 public ProgramZone getParent() throws AmetysRepositoryException 102 { 103 return new ProgramZone(_page); 104 } 105 106 @Override 107 public String getParentPath() throws AmetysRepositoryException 108 { 109 return _page.getPath() + "/default"; 110 } 111 112 @Override 113 public String getPath() throws AmetysRepositoryException 114 { 115 return _page.getPath() + "/default/default"; 116 } 117}