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.site; 017 018import java.util.List; 019import java.util.Map; 020 021import org.ametys.plugins.site.SiteInformationCache.SignupPage; 022 023 024/** 025 * Site's informations. 026 */ 027public class Site 028{ 029 private String _name; 030 private String _title; 031 private List<SiteUrl> _urls; 032 private List<String> _languages; 033 private List<String> _populationIds; 034 private Map<String, List<SignupPage>> _signupPages; 035 private Map<String, String> _weakPasswordUrls; 036 037 /** 038 * Constructor. 039 * @param name the site name 040 * @param title the site title 041 * @param urls the front-office server URLs. 042 * @param languages the languages handle by the site 043 * @param populationIds the IDs of populations attached to the site 044 * @param signupPages The sign-up page local URL 045 * @param weakPasswordUrls The weak password urls 046 */ 047 public Site(String name, String title, List<SiteUrl> urls, List<String> languages, List<String> populationIds, Map<String , List<SignupPage>> signupPages, Map<String , String> weakPasswordUrls) 048 { 049 _name = name; 050 _title = title; 051 _urls = urls; 052 _languages = languages; 053 _populationIds = populationIds; 054 _signupPages = signupPages; 055 _weakPasswordUrls = weakPasswordUrls; 056 } 057 058 /** 059 * Returns the site name. 060 * @return the site name. 061 */ 062 public String getName() 063 { 064 return _name; 065 } 066 067 /** 068 * Returns the site title. 069 * @return the site title. 070 */ 071 public String getTitle() 072 { 073 return _title; 074 } 075 076 /** 077 * Get the URLs of the site 078 * @return A non null list of URLs of the site 079 */ 080 public List<SiteUrl> getSiteUrls() 081 { 082 return _urls; 083 } 084 085 /** 086 * Get the languages of the site 087 * @return A non null list of languages of the site 088 */ 089 public List<String> getLanguages() 090 { 091 return _languages; 092 } 093 094 /** 095 * Get the populations IDs associated to the site 096 * @return The non null lists 097 */ 098 public List<String> getPopulationIds() 099 { 100 return _populationIds; 101 } 102 103 /** 104 * Return the sign-up pages 105 * @param lang Language of the pages 106 * @return The sign-up pages of the language 107 */ 108 public List<SignupPage> getSignupPages(String lang) 109 { 110 return _signupPages.get(lang); 111 } 112 113 /** 114 * Get the weak password url for a language 115 * @param lang the language 116 * @return the weak password url or null if not available 117 */ 118 public String getWeakPasswordUrl(String lang) 119 { 120 return _weakPasswordUrls.get(lang); 121 } 122 123 @Override 124 public String toString() 125 { 126 SiteUrl mainUrl = _urls.get(0); 127 128 return "Site " + _name + "[serverName=" + mainUrl.getServerName() + "; serverPort=" + mainUrl.getServerPort() + "; _serverPath=" + mainUrl.getServerPath() + "]"; 129 } 130}