View Javadoc

1   /*
2    * Copyright 2007 Hippo
3    *
4    * Licensed under the Apache License, Version 2.0 (the  "License"); 
5    * you may not use this file except in compliance with the License. 
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" 
12   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License.
15   */
16  package nl.hippo.portal.cms;
17  
18  import java.util.Collection;
19  import java.util.HashMap;
20  import java.util.Iterator;
21  import java.util.List;
22  import java.util.Map;
23  
24  /***
25   * @version $Id: CMSDomainImpl.java 6122 2007-04-18 14:34:48Z pduin $
26   *
27   */
28  public class CMSDomainImpl implements CMSDomain
29  {
30      private String name;
31      private int    port = 80;
32      private String fullName;
33      private String defaultSite;
34      private Map    sites = new HashMap();
35  
36      /***
37       * @return the name
38       */
39      public String getName()
40      {
41          return name;
42      }
43      
44      /***
45       * @param name the name to set
46       */
47      public void setName(String name)
48      {
49          this.name = name;
50      }
51      
52      /***
53       * @return the port
54       */
55      public int getPort()
56      {
57          return port;
58      }
59      
60      /***
61       * @param port the port to set
62       */
63      public void setPort(int port)
64      {
65          this.port = port;
66      }
67      
68      /***
69       * @return the name of the default Site
70       */
71      public String getDefaultSite()
72      {
73          return defaultSite;
74      }
75  
76      /***
77       * @param defaultSite the name of the default Site to set
78       */
79      public void setDefaultSite(String defaultSite)
80      {
81          this.defaultSite = defaultSite;
82      }
83  
84      public String getFullName()
85      {
86          if ( fullName == null )
87          {
88              fullName = buildFullName(name,port);
89          }
90          return fullName;
91      }
92      
93      public static String buildFullName(String name, int port)
94      {
95          if ( port == 80 )
96          {
97              return name;
98          }
99          else
100         {
101             return name + ":" + Integer.toString(port);
102         }
103     }
104     
105     /***
106      * @return the sites
107      */
108     public CMSSite getSite(String name)
109     {
110         return (CMSSite)sites.get(name);
111     }
112     
113     public Collection sites()
114     {
115         return sites.values();
116     }
117     
118     /***
119      * @param sites the sites to set
120      */
121     public void setSites(List sites)
122     {
123         Iterator iter = sites.iterator();
124         while ( iter.hasNext() )
125         {
126             CMSSiteImpl site = (CMSSiteImpl)iter.next();            
127             this.sites.put(site.getName(), site);
128         }
129     }
130 }