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 */ 016package org.ametys.web.administration.welcome; 017 018import org.apache.avalon.framework.service.ServiceException; 019import org.apache.avalon.framework.service.ServiceManager; 020import org.apache.avalon.framework.service.Serviceable; 021 022import org.ametys.web.repository.site.SiteManager; 023import org.ametys.web.site.SiteConfigurationExtensionPoint; 024 025/** 026 * This step indicates that there is at least one well configured site. 027 */ 028public class CompleteSiteStep extends AbstractWelcomeStep implements Serviceable 029{ 030 private ServiceManager _manager; 031 private SiteManager _siteManager; 032 private SiteConfigurationExtensionPoint _siteConfiguration; 033 034 @Override 035 public void service(ServiceManager manager) throws ServiceException 036 { 037 _manager = manager; 038 } 039 040 @Override 041 public boolean isPerformed() 042 { 043 if (_siteManager == null) 044 { 045 try 046 { 047 _siteManager = (SiteManager) _manager.lookup(SiteManager.ROLE); 048 } 049 catch (ServiceException e) 050 { 051 // The component cannot be looked up in safe mode 052 return false; 053 } 054 } 055 if (_siteConfiguration == null) 056 { 057 try 058 { 059 _siteConfiguration = (SiteConfigurationExtensionPoint) _manager.lookup(SiteConfigurationExtensionPoint.ROLE); 060 } 061 catch (ServiceException e) 062 { 063 // The component cannot be looked up in safe mode 064 return false; 065 } 066 } 067 068 return _siteManager.getSiteNames().stream().anyMatch(_siteConfiguration::isValid); 069 } 070}