EMMA Coverage Report (generated Sun Sep 18 11:34:27 PHT 2011)
[all classes][org.apache.maven.continuum.web.action.admin]

COVERAGE SUMMARY FOR SOURCE FILE [ConfigureAppearanceAction.java]

nameclass, %method, %block, %line, %
ConfigureAppearanceAction.java0%   (0/1)0%   (0/7)0%   (0/128)0%   (0/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ConfigureAppearanceAction0%   (0/1)0%   (0/7)0%   (0/128)0%   (0/28)
ConfigureAppearanceAction (): void 0%   (0/1)0%   (0/3)0%   (0/1)
execute (): String 0%   (0/1)0%   (0/7)0%   (0/2)
getCompanyModel (): Model 0%   (0/1)0%   (0/3)0%   (0/1)
getModel (): Object 0%   (0/1)0%   (0/3)0%   (0/1)
getSecureActionBundle (): SecureActionBundle 0%   (0/1)0%   (0/13)0%   (0/4)
input (): String 0%   (0/1)0%   (0/2)0%   (0/1)
prepare (): void 0%   (0/1)0%   (0/97)0%   (0/18)

1package org.apache.maven.continuum.web.action.admin;
2 
3/*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements.  See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership.  The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License.  You may obtain a copy of the License at
11 *
12 *   http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied.  See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21 
22import java.io.IOException;
23import java.util.ArrayList;
24import java.util.List;
25import java.util.Map;
26 
27import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
28import org.apache.maven.artifact.repository.ArtifactRepository;
29import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
30import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
31import org.apache.maven.continuum.execution.maven.m2.MavenBuilderHelper;
32import org.apache.maven.continuum.execution.maven.m2.SettingsConfigurationException;
33import org.apache.maven.continuum.security.ContinuumRoleConstants;
34import org.apache.maven.continuum.web.action.component.AbstractFooterAction;
35import org.apache.maven.continuum.web.appareance.AppareanceConfiguration;
36import org.apache.maven.model.Model;
37import org.apache.maven.project.ProjectBuildingException;
38import org.apache.maven.settings.MavenSettingsBuilder;
39import org.apache.maven.settings.Profile;
40import org.apache.maven.settings.Repository;
41import org.apache.maven.settings.Settings;
42import org.apache.maven.shared.app.company.CompanyPomHandler;
43import org.apache.maven.shared.app.configuration.Configuration;
44import org.apache.maven.shared.app.configuration.MavenAppConfiguration;
45import org.codehaus.plexus.redback.rbac.Resource;
46import org.codehaus.plexus.registry.RegistryException;
47import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
48import org.codehaus.redback.integration.interceptor.SecureAction;
49import org.codehaus.redback.integration.interceptor.SecureActionBundle;
50import org.codehaus.redback.integration.interceptor.SecureActionException;
51 
52import com.opensymphony.xwork2.ModelDriven;
53 
54/**
55 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
56 * @version $Id: ConfigureAppearanceAction.java 729461 2008-12-26 08:38:10Z olamy $
57 * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="configureAppearance"
58 */
59public class ConfigureAppearanceAction
60    extends AbstractFooterAction
61    implements ModelDriven, SecureAction
62{
63    /**
64     * @plexus.requirement
65     */
66    private MavenAppConfiguration appConfiguration;
67 
68    /**
69     * The configuration.
70     */
71    private Configuration configuration;
72 
73    private Model companyModel;
74 
75    /**
76     * @plexus.requirement
77     */
78    private CompanyPomHandler companyPomHandler;
79 
80    /**
81     * @plexus.requirement
82     */
83    private MavenBuilderHelper helper;
84 
85    /**
86     * @plexus.requirement
87     */
88    private MavenSettingsBuilder mavenSettingsBuilder;
89 
90    /**
91     * @plexus.requirement
92     */
93    private ArtifactRepositoryFactory artifactRepositoryFactory;
94 
95    /**
96     * @plexus.requirement role-hint="default"
97     */
98    private ArtifactRepositoryLayout layout;
99 
100    /**
101     * @plexus.requirement
102     */
103    private AppareanceConfiguration appareanceConfiguration;
104 
105    public String execute()
106        throws IOException, RegistryException
107    {
108        appConfiguration.save( configuration );
109 
110        return SUCCESS;
111    }
112 
113    public String input()
114        throws IOException, RegistryException
115    {
116        return INPUT;
117    }
118 
119    public Object getModel()
120    {
121        return configuration;
122    }
123 
124    public void prepare()
125        throws ProjectBuildingException, ArtifactMetadataRetrievalException, SettingsConfigurationException,
126        XmlPullParserException, IOException
127    {
128 
129        Settings settings = mavenSettingsBuilder.buildSettings( false );
130 
131        // Load extra repositories from active profiles
132        List<String> profileIds = settings.getActiveProfiles();
133        List<Profile> profiles = settings.getProfiles();
134        List<ArtifactRepository> remoteRepositories = new ArrayList<ArtifactRepository>();
135        Map<String, Profile> profilesAsMap = settings.getProfilesAsMap();
136        if ( profileIds != null && !profileIds.isEmpty() )
137        {
138            for ( String profileId : profileIds )
139            {
140                Profile profile = profilesAsMap.get( profileId );
141                if ( profile != null )
142                {
143                    List<Repository> repos = profile.getRepositories();
144                    if ( repos != null && !repos.isEmpty() )
145                    {
146                        for ( Repository repo : repos )
147                        {
148                            remoteRepositories.add(
149                                artifactRepositoryFactory.createArtifactRepository( repo.getId(), repo
150                                    .getUrl(), layout, null, null ) );
151                        }
152                    }
153                }
154            }
155        }
156        configuration = appConfiguration.getConfiguration();
157 
158        companyModel = companyPomHandler.getCompanyPomModel( configuration.getCompanyPom(), helper.getLocalRepository(),
159                                                             remoteRepositories );
160 
161        this.setFooter( appareanceConfiguration.getFooter() );
162    }
163 
164    public Model getCompanyModel()
165    {
166        return companyModel;
167    }
168 
169    public SecureActionBundle getSecureActionBundle()
170        throws SecureActionException
171    {
172        SecureActionBundle bundle = new SecureActionBundle();
173        bundle.setRequiresAuthentication( true );
174        bundle.addRequiredAuthorization( ContinuumRoleConstants.CONTINUUM_MANAGE_CONFIGURATION, Resource.GLOBAL );
175 
176        return bundle;
177    }
178 
179}

[all classes][org.apache.maven.continuum.web.action.admin]
EMMA 2.0.5312 (C) Vladimir Roubtsov