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.ArrayList;
19  import java.util.Iterator;
20  import java.util.List;
21  import java.util.Properties;
22  
23  /***
24   * @version $Id: CMSApplicationImpl.java 6258 2007-04-24 16:04:41Z ddam $
25   *
26   */
27  public class CMSApplicationImpl implements CMSApplication
28  {
29      private String name;
30      private CMSApplicationRegistration registration;
31      private Properties appProperties;
32      
33      private List sites = new ArrayList();
34      
35      public void available(CMSApplicationRegistration registration)
36      {
37          this.registration = registration;
38          boolean available = registration != null;
39          Iterator iter = sites.iterator();
40          while ( iter.hasNext() )
41          {
42              ((CMSSiteImpl)iter.next()).setAvailable(available);
43          }
44      }
45      
46      public void unavailable()
47      {
48          this.registration = null;
49      }
50      
51      public CMSApplicationRegistration getRegistration()
52      {
53          return registration;
54      }
55      
56      public boolean isActive()
57      {
58          return registration != null;
59      }
60      
61      public void setName(String name)
62      {
63          this.name = name;
64      }
65      
66      /* (non-Javadoc)
67       * @see nl.hippo.portal.cms.CMSApplication#getName()
68       */
69      public String getName()
70      {
71          return name;
72      }
73  
74      public void setSites(List sites)
75      {
76          Iterator iter = sites.iterator();
77          while ( iter.hasNext() )
78          {
79              CMSSiteImpl site = (CMSSiteImpl)iter.next();            
80              site.setApplication(this);
81              this.sites.add(site);
82          }
83      }
84  
85      public void setProperties(Properties properties){
86          this.appProperties = properties;
87      }
88      
89      public String getProperty(String name) {
90          if (this.appProperties!=null){
91              return appProperties.getProperty(name);
92          }   
93          return null;
94      }
95  }