001/* 002 * Copyright 2016 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.userdirectory.page; 018 019import org.ametys.cms.repository.Content; 020import org.ametys.plugins.repository.AmetysRepositoryException; 021import org.ametys.plugins.repository.metadata.CompositeMetadata; 022import org.ametys.web.repository.page.Zone; 023import org.ametys.web.repository.page.ZoneItem; 024 025/** 026 * {@link ZoneItem} holding a content. 027 */ 028public class UserZoneItem implements ZoneItem 029{ 030 private UserPage _page; 031 032 /** 033 * Constructor. 034 * @param page the parent {@link UserPage}. 035 */ 036 public UserZoneItem(UserPage page) 037 { 038 _page = page; 039 } 040 041 @SuppressWarnings("unchecked") 042 @Override 043 public Content getContent() throws AmetysRepositoryException 044 { 045 Content content = _page.getSyncContent(); 046 return content; 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 user directory pages"); 059 } 060 061 @Override 062 public CompositeMetadata getServiceParameters() throws AmetysRepositoryException 063 { 064 throw new UnsupportedOperationException("getServiceParameters not supported on virtual user directory 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 UserZone(_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 "uduserzoneitem://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 UserZone getParent() throws AmetysRepositoryException 100 { 101 return new UserZone(_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}