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 [EditPomAction.java]

nameclass, %method, %block, %line, %
EditPomAction.java0%   (0/1)0%   (0/7)0%   (0/98)0%   (0/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class EditPomAction0%   (0/1)0%   (0/7)0%   (0/98)0%   (0/24)
EditPomAction (): void 0%   (0/1)0%   (0/3)0%   (0/1)
execute (): String 0%   (0/1)0%   (0/29)0%   (0/5)
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/45)0%   (0/11)

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;
23 
24import org.apache.maven.artifact.installer.ArtifactInstallationException;
25import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
26import org.apache.maven.continuum.execution.maven.m2.MavenBuilderHelper;
27import org.apache.maven.continuum.execution.maven.m2.SettingsConfigurationException;
28import org.apache.maven.continuum.security.ContinuumRoleConstants;
29import org.apache.maven.continuum.web.action.ContinuumActionSupport;
30import org.apache.maven.model.Model;
31import org.apache.maven.project.ProjectBuildingException;
32import org.apache.maven.shared.app.company.CompanyPomHandler;
33import org.apache.maven.shared.app.configuration.CompanyPom;
34import org.apache.maven.shared.app.configuration.Configuration;
35import org.apache.maven.shared.app.configuration.MavenAppConfiguration;
36import org.codehaus.plexus.redback.rbac.Resource;
37import org.codehaus.redback.integration.interceptor.SecureAction;
38import org.codehaus.redback.integration.interceptor.SecureActionBundle;
39import org.codehaus.redback.integration.interceptor.SecureActionException;
40 
41import com.opensymphony.xwork2.ModelDriven;
42 
43/**
44 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
45 * @version $Id: EditPomAction.java 765340 2009-04-15 20:22:00Z evenisse $
46 * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="editPom"
47 */
48public class EditPomAction
49    extends ContinuumActionSupport
50    implements ModelDriven, SecureAction
51{
52    /**
53     * @plexus.requirement
54     */
55    private MavenAppConfiguration appConfiguration;
56 
57    /**
58     * @plexus.requirement
59     */
60    private CompanyPomHandler companyPomHandler;
61 
62    private Model companyModel;
63 
64    /**
65     * @plexus.requirement
66     */
67    private MavenBuilderHelper helper;
68 
69    public String execute()
70        throws IOException, ArtifactInstallationException, SettingsConfigurationException
71    {
72        // TODO: hack for passed in String[]
73        String[] logo = (String[]) companyModel.getProperties().get( "organization.logo" );
74        if ( logo != null )
75        {
76            companyModel.getProperties().put( "organization.logo", logo[0] );
77        }
78 
79        companyPomHandler.save( companyModel, helper.getLocalRepository() );
80 
81        return SUCCESS;
82    }
83 
84    public String input()
85    {
86        return INPUT;
87    }
88 
89    public Object getModel()
90    {
91        return companyModel;
92    }
93 
94    public void prepare()
95        throws ProjectBuildingException, ArtifactMetadataRetrievalException, SettingsConfigurationException
96    {
97        Configuration configuration = appConfiguration.getConfiguration();
98 
99        CompanyPom companyPom = configuration.getCompanyPom();
100        companyModel = companyPomHandler.getCompanyPomModel( companyPom, helper.getLocalRepository() );
101 
102        if ( companyModel == null )
103        {
104            companyModel = new Model();
105            companyModel.setModelVersion( "4.0.0" );
106            companyModel.setPackaging( "pom" );
107 
108            if ( companyPom != null )
109            {
110                companyModel.setGroupId( companyPom.getGroupId() );
111                companyModel.setArtifactId( companyPom.getArtifactId() );
112            }
113        }
114    }
115 
116    public Model getCompanyModel()
117    {
118        return companyModel;
119    }
120 
121    public SecureActionBundle getSecureActionBundle()
122        throws SecureActionException
123    {
124        SecureActionBundle bundle = new SecureActionBundle();
125        bundle.setRequiresAuthentication( true );
126        bundle.addRequiredAuthorization( ContinuumRoleConstants.CONTINUUM_MANAGE_CONFIGURATION, Resource.GLOBAL );
127 
128        return bundle;
129    }
130}

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