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