* Adding 'mysql' profile to webapp for testing under mysql. (see jetty-env-mysql.xml for setup instructions)

* Fixing many plexus role/role-hint issues.
* Enabling (previously disabled) appearance actions.
* Adding appserver-base/logs to prevent huge stacktrace during jetty:run



git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@532916 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joakim Erdfelt 2007-04-26 23:55:51 +00:00
parent 383e27a7bf
commit 8b132cd183
25 changed files with 863 additions and 429 deletions

View File

@ -49,7 +49,7 @@ public class LocationArtifactsReport
private String name;
/**
* @plexus.requirement
* @plexus.requirement role-hint="jdo"
*/
private ArchivaDAO dao;

View File

@ -46,7 +46,7 @@ public class OldArtifactReport
private String name;
/**
* @plexus.requirement
* @plexus.requirement role-hint="jdo"
*/
private ArchivaDAO dao;

View File

@ -46,7 +46,7 @@ public class OldSnapshotArtifactReport
private String name;
/**
* @plexus.requirement
* @plexus.requirement role-hint="jdo"
*/
private ArchivaDAO dao;

View File

@ -49,7 +49,7 @@ public class MetadataReport
private String name;
/**
* @plexus.requirement
* @plexus.requirement role-hint="jdo"
*/
private ArchivaDAO dao;

View File

@ -49,7 +49,7 @@ public class MissingDependenciesReport
private String name;
/**
* @plexus.requirement
* @plexus.requirement role-hint="jdo"
*/
private ArchivaDAO dao;

View File

@ -28,6 +28,9 @@ import java.util.Map;
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
* @version $Id$
*
* @plexus.component role="org.apache.maven.archiva.reporting.ReportingManager"
* role-hint="default"
*/
public class DefaultReportingManager
extends AbstractLogEnabled

View File

@ -48,6 +48,7 @@
<requirements>
<requirement>
<role>org.codehaus.plexus.security.rbac.RBACManager</role>
<role-hint>cached</role-hint>
</requirement>
<requirement>
<role>org.codehaus.plexus.PlexusContainer</role>
@ -62,6 +63,7 @@
<requirements>
<requirement>
<role>org.codehaus.plexus.security.rbac.RBACManager</role>
<role-hint>cached</role-hint>
</requirement>
<requirement>
<role>org.codehaus.plexus.PlexusContainer</role>
@ -76,6 +78,7 @@
<requirements>
<requirement>
<role>org.codehaus.plexus.security.rbac.RBACManager</role>
<role-hint>cached</role-hint>
</requirement>
<requirement>
<role>org.codehaus.plexus.PlexusContainer</role>
@ -90,6 +93,7 @@
<requirements>
<requirement>
<role>org.codehaus.plexus.security.rbac.RBACManager</role>
<role-hint>cached</role-hint>
</requirement>
<requirement>
<role>org.codehaus.plexus.PlexusContainer</role>
@ -104,6 +108,7 @@
<requirements>
<requirement>
<role>org.codehaus.plexus.security.rbac.RBACManager</role>
<role-hint>cached</role-hint>
</requirement>
<requirement>
<role>org.codehaus.plexus.PlexusContainer</role>
@ -118,6 +123,7 @@
<requirements>
<requirement>
<role>org.codehaus.plexus.security.rbac.RBACManager</role>
<role-hint>cached</role-hint>
</requirement>
</requirements>
</component>
@ -128,6 +134,7 @@
<requirements>
<requirement>
<role>org.codehaus.plexus.security.rbac.RBACManager</role>
<role-hint>cached</role-hint>
</requirement>
</requirements>
</component>

View File

@ -100,12 +100,6 @@
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-app-configuration-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
@ -371,4 +365,27 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>mysql</id>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<jettyEnvXml>src/jetty-env-mysql.xml</jettyEnvXml>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,160 @@
<?xml version="1.0"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<New id="validation_mail" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>mail/Session</Arg>
<Arg>
<New class="org.mortbay.naming.factories.MailSessionReference">
<Set name="user"></Set>
<Set name="password"></Set>
<Set name="properties">
<New class="java.util.Properties">
<Put name="mail.smtp.host">localhost</Put>
<Put name="mail.smtp.port">25</Put>
</New>
</Set>
</New>
</Arg>
</New>
<!--
In order to use this jetty-env, you need to setup your mysql locally.
1) Connect to mysql
$ mysql -u root -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 62
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
2) Create the databases.
mysql> create database archiva;
Query OK, 1 row affected (0.00 sec)
mysql> create database redback;
Query OK, 1 row affected (0.00 sec)
3) Create the archiva user / permissions to (archiva and redback) tables.
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX
-> ON archiva.*
-> TO 'archiva'@'localhost'
-> IDENTIFIED BY 'sa';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX
-> ON redback.*
-> TO 'archiva'@'localhost'
-> IDENTIFIED BY 'sa';
Query OK, 0 rows affected (0.00 sec)
mysql>
4) Quit from mysql command shell, and verify the user creation.
$ mysql -u archiva -p sa
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 77
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use archiva;
Database changed
mysql> use redback;
Database changed
mysql> use mysql;
ERROR 1044 (42000): Access denied for user 'archiva'@'localhost' to database 'mysql'
mysql>
5) Done with mysql server setup. To use this jetty-env.xml use the following command line.
$ mvn -Pmysql clean jetty:run
-->
<!-- Archiva database -->
<New id="archiva" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/archiva</Arg>
<Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
<Set name="serverName">localhost</Set>
<Set name="databaseName">archiva</Set>
<Set name="user">archiva</Set>
<Set name="password">sa</Set>
</New>
</Arg>
</New>
<New id="archivaShutdown" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/archivaShutdown</Arg>
<Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
<!-- <Set name="url">jdbc:mysql://localhost/archiva</Set> -->
<Set name="serverName">localhost</Set>
<Set name="databaseName">archiva</Set>
<Set name="user">archiva</Set>
<Set name="password">sa</Set>
</New>
</Arg>
</New>
<!-- users / Security Database -->
<New id="users" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/users</Arg>
<Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
<!-- <Set name="url">jdbc:mysql://localhost/redback</Set> -->
<Set name="serverName">localhost</Set>
<Set name="databaseName">redback</Set>
<Set name="user">archiva</Set>
<Set name="password">sa</Set>
</New>
</Arg>
</New>
<New id="usersShutdown" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/usersShutdown</Arg>
<Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
<Set name="url">jdbc:mysql://localhost/redback</Set>
<Set name="user">archiva</Set>
<Set name="password">sa</Set>
</New>
</Arg>
</New>
</Configure>

View File

@ -52,7 +52,7 @@ public class ShowArtifactAction
/* .\ Not Exposed \._____________________________________________ */
/**
* @plexus.requirement
* @plexus.requirement role-hint="jdo"
*/
private ArchivaDAO dao;

View File

@ -0,0 +1,96 @@
package org.apache.maven.archiva.web.action.admin;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
import org.apache.maven.archiva.model.RepositoryURL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* AdminModel
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
* @version $Id$
*/
public class AdminModel
{
private String baseUrl;
private List managedRepositories = new ArrayList();
private List remoteRepositories = new ArrayList();
public AdminModel()
{
/* do nothing */
}
public AdminModel( Configuration configuration )
{
Iterator it = configuration.getRepositories().iterator();
while ( it.hasNext() )
{
RepositoryConfiguration repoconfig = (RepositoryConfiguration) it.next();
RepositoryURL repourl = new RepositoryURL( repoconfig.getUrl() );
if ( "file".equals( repourl.getProtocol() ) )
{
managedRepositories.add( repoconfig );
}
else
{
remoteRepositories.add( repoconfig );
}
}
}
public List getManagedRepositories()
{
return managedRepositories;
}
public void setManagedRepositories( List managedRepositories )
{
this.managedRepositories = managedRepositories;
}
public List getRemoteRepositories()
{
return remoteRepositories;
}
public void setRemoteRepositories( List remoteRepositories )
{
this.remoteRepositories = remoteRepositories;
}
public String getBaseUrl()
{
return baseUrl;
}
public void setBaseUrl( String baseUrl )
{
this.baseUrl = baseUrl;
}
}

View File

@ -28,7 +28,6 @@ import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.InvalidConfigurationException;
import org.apache.maven.archiva.indexer.RepositoryIndexException;
import org.apache.maven.archiva.indexer.RepositoryIndexSearchException;
//import org.apache.maven.archiva.repositories.ActiveManagedRepositories;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
import org.codehaus.plexus.registry.RegistryException;
import org.codehaus.plexus.scheduler.CronExpressionValidator;
@ -38,9 +37,7 @@ import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
import java.io.File;
import java.io.IOException;
import java.util.Date;
/**
* Configures the application.
@ -56,43 +53,14 @@ public class ConfigureAction
*/
private ArchivaConfiguration archivaConfiguration;
// /**
// * @plexus.requirement
// */
// private ActiveManagedRepositories activeRepositories;
/**
* The configuration.
*/
private Configuration configuration;
private CronExpressionValidator cronValidator;
private String second = "0";
private String minute = "0";
private String hour = "*";
private String dayOfMonth = "*";
private String month = "*";
private String dayOfWeek = "?";
private String year;
private String lastIndexingTime;
public void validate()
{
//validate cron expression
cronValidator = new CronExpressionValidator();
if ( !cronValidator.validate( getCronExpression() ) )
{
addActionError( "Invalid Cron Expression" );
}
}
public String execute()
@ -101,75 +69,61 @@ public class ConfigureAction
{
// TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded
// TODO: if this is changed, do we move the index or recreate it?
// configuration.setDataRefreshCronExpression( getCronExpression() );
// Normalize the path
// File file = new File( configuration.getIndexPath() );
// configuration.setIndexPath( file.getCanonicalPath() );
// if ( !file.exists() )
// {
// file.mkdirs();
// // TODO: error handling when this fails, or is not a directory!
// }
// Just double checking that our validation routines line up with what is expected in the configuration
// assert configuration.isValid();
archivaConfiguration.save( configuration );
// TODO: if the repository has changed, we need to check if indexing is needed!
addActionMessage( "Successfully saved configuration" );
return SUCCESS;
}
public String input()
{
// String[] cronEx = configuration.getDataRefreshCronExpression().split( " " );
String[] cronEx = new String[]{"0","0","*","*","*","*","*"};
int i = 0;
while ( i < cronEx.length )
{
switch ( i )
{
case 0:
second = cronEx[i];
break;
case 1:
minute = cronEx[i];
break;
case 2:
hour = cronEx[i];
break;
case 3:
dayOfMonth = cronEx[i];
break;
case 4:
month = cronEx[i];
break;
case 5:
dayOfWeek = cronEx[i];
break;
case 6:
year = cronEx[i];
break;
}
i++;
}
// if ( activeRepositories.getLastDataRefreshTime() != 0 )
// public String input()
// {
//// String[] cronEx = configuration.getDataRefreshCronExpression().split( " " );
// String[] cronEx = new String[]{"0","0","*","*","*","*","*"};
// int i = 0;
//
// while ( i < cronEx.length )
// {
// lastIndexingTime = new Date( activeRepositories.getLastDataRefreshTime() ).toString();
// switch ( i )
// {
// case 0:
// second = cronEx[i];
// break;
// case 1:
// minute = cronEx[i];
// break;
// case 2:
// hour = cronEx[i];
// break;
// case 3:
// dayOfMonth = cronEx[i];
// break;
// case 4:
// month = cronEx[i];
// break;
// case 5:
// dayOfWeek = cronEx[i];
// break;
// case 6:
// year = cronEx[i];
// break;
// }
// i++;
// }
// else
{
lastIndexingTime = "Never been run.";
}
return INPUT;
}
//
//// if ( activeRepositories.getLastDataRefreshTime() != 0 )
//// {
//// lastIndexingTime = new Date( activeRepositories.getLastDataRefreshTime() ).toString();
//// }
//// else
// {
// lastIndexingTime = "Never been run.";
// }
//
// return INPUT;
// }
public Object getModel()
{
@ -181,91 +135,11 @@ public class ConfigureAction
configuration = archivaConfiguration.getConfiguration();
}
public String getLastIndexingTime()
{
return lastIndexingTime;
}
public void setLastIndexingTime( String lastIndexingTime )
{
this.lastIndexingTime = lastIndexingTime;
}
public String getSecond()
{
return second;
}
public void setSecond( String second )
{
this.second = second;
}
public String getMinute()
{
return minute;
}
public void setMinute( String minute )
{
this.minute = minute;
}
public String getHour()
{
return hour;
}
public void setHour( String hour )
{
this.hour = hour;
}
public String getDayOfMonth()
{
return dayOfMonth;
}
public void setDayOfMonth( String dayOfMonth )
{
this.dayOfMonth = dayOfMonth;
}
public String getYear()
{
return year;
}
public void setYear( String year )
{
this.year = year;
}
public String getMonth()
{
return month;
}
public void setMonth( String month )
{
this.month = month;
}
public String getDayOfWeek()
{
return dayOfWeek;
}
public void setDayOfWeek( String dayOfWeek )
{
this.dayOfWeek = dayOfWeek;
}
private String getCronExpression()
{
return ( second + " " + minute + " " + hour + " " + dayOfMonth + " " + month + " " + dayOfWeek + " " +
year ).trim();
}
// private String getCronExpression()
// {
// return ( second + " " + minute + " " + hour + " " + dayOfMonth + " " + month + " " + dayOfWeek + " " +
// year ).trim();
// }
public SecureActionBundle getSecureActionBundle()
throws SecureActionException

View File

@ -1,125 +0,0 @@
package org.apache.maven.archiva.web.action.admin;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import com.opensymphony.xwork.ModelDriven;
import com.opensymphony.xwork.Preparable;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
//import org.apache.maven.artifact.installer.ArtifactInstallationException;
//import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
//import org.apache.maven.model.Model;
//import org.apache.maven.project.ProjectBuildingException;
//import org.apache.maven.shared.app.company.CompanyPomHandler;
//import org.apache.maven.shared.app.configuration.CompanyPom;
//import org.apache.maven.shared.app.configuration.Configuration;
//import org.apache.maven.shared.app.configuration.MavenAppConfiguration;
import org.codehaus.plexus.security.rbac.Resource;
import org.codehaus.plexus.security.ui.web.interceptor.SecureAction;
import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
import java.io.IOException;
/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id: ConfigurationAction.java 480950 2006-11-30 14:58:35Z evenisse $
* @TODO plexus.component role="com.opensymphony.xwork.Action"
* role-hint="editPom"
*/
public class EditPomAction
extends PlexusActionSupport
implements ModelDriven, SecureAction, Preparable
{
/**
* @plexus.requirement
*/
// private MavenAppConfiguration appConfigurationStore;
/**
* The configuration.
*/
// private Configuration configuration;
/**
* @plexus.requirement
*/
// private CompanyPomHandler companyPomHandler;
// private Model companyModel;
public String execute()
// throws IOException, ArtifactInstallationException
{
// TODO: hack for passed in String[]
// String[] logo = (String[]) companyModel.getProperties().get( "organization.logo" );
// if ( logo != null )
// {
// companyModel.getProperties().put( "organization.logo", logo[0] );
// }
//
// companyPomHandler.save( companyModel, createLocalRepository() );
return SUCCESS;
}
public Object getModel()
{
// return companyModel;
return new Object();
}
public void prepare()
// throws ProjectBuildingException, ArtifactMetadataRetrievalException
{
// configuration = appConfigurationStore.getConfiguration();
//
// CompanyPom companyPom = configuration.getCompanyPom();
// companyModel = companyPomHandler.getCompanyPomModel( companyPom, createLocalRepository() );
//
// if ( companyModel == null )
// {
// companyModel = new Model();
// companyModel.setModelVersion( "4.0.0" );
// companyModel.setPackaging( "pom" );
//
// if ( companyPom != null )
// {
// companyModel.setGroupId( companyPom.getGroupId() );
// companyModel.setArtifactId( companyPom.getArtifactId() );
// }
// }
}
public SecureActionBundle getSecureActionBundle()
throws SecureActionException
{
SecureActionBundle bundle = new SecureActionBundle();
bundle.setRequiresAuthentication( true );
bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
return bundle;
}
// public Model getCompanyModel()
// {
// return companyModel;
// }
}

View File

@ -0,0 +1,111 @@
package org.apache.maven.archiva.web.action.admin;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.xwork.ModelDriven;
import com.opensymphony.xwork.Preparable;
import com.opensymphony.xwork.Validateable;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.database.ArchivaDAO;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
import org.codehaus.plexus.security.rbac.Resource;
import org.codehaus.plexus.security.ui.web.interceptor.SecureAction;
import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
import javax.servlet.http.HttpServletRequest;
/**
* Shows the Repositories Tab for the administrator.
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
* @version $Id$
*
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="repositoriesAction"
*/
public class RepositoriesAction
extends PlexusActionSupport
implements ModelDriven, Preparable, Validateable, SecureAction, ServletRequestAware
{
/**
* @plexus.requirement
*/
private ArchivaConfiguration archivaConfiguration;
/**
* @plexus.requirement role-hint="jdo"
*/
private ArchivaDAO dao;
private HttpServletRequest request;
private AdminModel model;
public Object getModel()
{
return model;
}
public void prepare()
throws Exception
{
model = new AdminModel( archivaConfiguration.getConfiguration() );
}
public void validate()
{
super.validate();
}
public SecureActionBundle getSecureActionBundle()
throws SecureActionException
{
SecureActionBundle bundle = new SecureActionBundle();
bundle.setRequiresAuthentication( true );
bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
return bundle;
}
public void setServletRequest( HttpServletRequest request )
{
this.request = request;
StringBuffer baseUrl = new StringBuffer();
baseUrl.append( request.getScheme() );
baseUrl.append( request.getServerName() );
int portnum = request.getServerPort();
// Only add port if non-standard.
if ( ( "https".equalsIgnoreCase( request.getScheme() ) && ( portnum != 443 ) )
|| ( "http".equalsIgnoreCase( request.getScheme() ) && ( portnum != 80 ) ) )
{
baseUrl.append( ":" ).append( String.valueOf( portnum ) );
}
baseUrl.append( request.getContextPath() );
baseUrl.append( "/repository" );
model.setBaseUrl( baseUrl.toString() );
}
}

View File

@ -0,0 +1,70 @@
package org.apache.maven.archiva.web.action.admin.appearance;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.commons.lang.StringUtils;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
import java.io.File;
import java.util.Map;
/**
* AbstractAppearanceAction
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
* @version $Id$
*/
public abstract class AbstractAppearanceAction
extends PlexusActionSupport
{
/**
* @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
*/
private Map repositoryLayouts;
/**
* @plexus.requirement
*/
private ArtifactRepositoryFactory repoFactory;
protected ArtifactRepository createLocalRepository()
{
String id = "archiva-local-repo";
String layout = "default";
String directory = System.getProperty( "user.home" ) + ".m2/archiva";
ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) repositoryLayouts.get( layout );
File repository = new File( directory );
repository.mkdirs();
String repoDir = repository.toURI().toString();
//workaround for spaces non converted by PathUtils in wagon
//TODO: remove it when PathUtils will be fixed
if ( repoDir.indexOf( "%20" ) >= 0 )
{
repoDir = StringUtils.replace( repoDir, "%20", " " );
}
return repoFactory.createArtifactRepository( id, repoDir, repositoryLayout, null, null );
}
}

View File

@ -1,4 +1,4 @@
package org.apache.maven.archiva.web.action.component;
package org.apache.maven.archiva.web.action.admin.appearance;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -19,18 +19,17 @@ package org.apache.maven.archiva.web.action.component;
* under the License.
*/
// TODO import org.apache.maven.model.Model;
// import org.apache.maven.shared.app.company.CompanyPomHandler;
// import org.apache.maven.shared.app.configuration.MavenAppConfiguration;
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
import org.apache.maven.model.Model;
import org.apache.maven.shared.app.company.CompanyPomHandler;
import org.apache.maven.shared.app.configuration.MavenAppConfiguration;
/**
* Stores the company information for displaying on the page.
*
* @TODO plexus.component role="com.opensymphony.xwork.Action" role-hint="companyInfo"
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="companyInfo"
*/
public class CompanyInfoAction
extends PlexusActionSupport
extends AbstractAppearanceAction
{
private String companyLogo;
@ -39,19 +38,18 @@ public class CompanyInfoAction
private String companyName;
/**
* @TODO plexus.requirement
* @plexus.requirement
*/
// private CompanyPomHandler handler;
private CompanyPomHandler handler;
/**
* @TODO plexus.requirement
* @plexus.requirement
*/
// private MavenAppConfiguration appConfigurationStore;
private MavenAppConfiguration appConfigurationStore;
public String execute()
throws Exception
{
/* TODO
Model model = handler.getCompanyPomModel( appConfigurationStore.getConfiguration().getCompanyPom(),
createLocalRepository() );
@ -64,7 +62,7 @@ public class CompanyInfoAction
}
companyLogo = model.getProperties().getProperty( "organization.logo" );
}*/
}
return SUCCESS;
}

View File

@ -1,4 +1,4 @@
package org.apache.maven.archiva.web.action.admin;
package org.apache.maven.archiva.web.action.admin.appearance;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -21,70 +21,68 @@ package org.apache.maven.archiva.web.action.admin;
import com.opensymphony.xwork.ModelDriven;
import com.opensymphony.xwork.Preparable;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
//import org.apache.maven.archiva.web.action.AbstractConfiguredAction;
//import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
//import org.apache.maven.model.Model;
//import org.apache.maven.project.ProjectBuildingException;
//import org.apache.maven.shared.app.company.CompanyPomHandler;
//import org.apache.maven.shared.app.configuration.Configuration;
//import org.apache.maven.shared.app.configuration.MavenAppConfiguration;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.model.Model;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.shared.app.company.CompanyPomHandler;
import org.apache.maven.shared.app.configuration.Configuration;
import org.apache.maven.shared.app.configuration.MavenAppConfiguration;
import org.codehaus.plexus.registry.RegistryException;
import org.codehaus.plexus.security.rbac.Resource;
import org.codehaus.plexus.security.ui.web.interceptor.SecureAction;
import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
import java.io.IOException;
/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id: ConfigurationAction.java 480950 2006-11-30 14:58:35Z evenisse $
* @TODO plexus.component role="com.opensymphony.xwork.Action"
* role-hint="configureAppearance"
* @plexus.component role="com.opensymphony.xwork.Action"
* role-hint="configureAppearance"
*/
public class ConfigureAppearanceAction
extends PlexusActionSupport
extends AbstractAppearanceAction
implements ModelDriven, SecureAction, Preparable
{
// /**
// * @plexus.requirement
// */
// private MavenAppConfiguration appConfigurationStore;
//
// /**
// * The configuration.
// */
// private Configuration configuration;
//
// private Model companyModel;
//
// /**
// * @plexus.requirement
// */
// private CompanyPomHandler companyPomHandler;
//
/**
* @plexus.requirement
*/
private MavenAppConfiguration appConfigurationStore;
/**
* The configuration.
*/
private Configuration configuration;
private Model companyModel;
/**
* @plexus.requirement
*/
private CompanyPomHandler companyPomHandler;
public String execute()
throws IOException, RegistryException
{
// appConfigurationStore.save( configuration );
appConfigurationStore.save( configuration );
return SUCCESS;
}
public Object getModel()
{
return new Object();
// return configuration;
return configuration;
}
public void prepare()
// throws ProjectBuildingException, ArtifactMetadataRetrievalException
throws ProjectBuildingException, ArtifactMetadataRetrievalException
{
// configuration = appConfigurationStore.getConfiguration();
//
// companyModel = companyPomHandler.getCompanyPomModel( configuration.getCompanyPom(), createLocalRepository() );
configuration = appConfigurationStore.getConfiguration();
companyModel = companyPomHandler.getCompanyPomModel( configuration.getCompanyPom(), createLocalRepository() );
}
public SecureActionBundle getSecureActionBundle()
@ -96,9 +94,9 @@ public class ConfigureAppearanceAction
return bundle;
}
//
// public Model getCompanyModel()
// {
// return companyModel;
// }
public Model getCompanyModel()
{
return companyModel;
}
}

View File

@ -0,0 +1,125 @@
package org.apache.maven.archiva.web.action.admin.appearance;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import com.opensymphony.xwork.ModelDriven;
import com.opensymphony.xwork.Preparable;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
import org.apache.maven.artifact.installer.ArtifactInstallationException;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.model.Model;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.shared.app.company.CompanyPomHandler;
import org.apache.maven.shared.app.configuration.CompanyPom;
import org.apache.maven.shared.app.configuration.Configuration;
import org.apache.maven.shared.app.configuration.MavenAppConfiguration;
import org.codehaus.plexus.security.rbac.Resource;
import org.codehaus.plexus.security.ui.web.interceptor.SecureAction;
import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
import java.io.IOException;
/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id: ConfigurationAction.java 480950 2006-11-30 14:58:35Z evenisse $
*
* @plexus.component role="com.opensymphony.xwork.Action"
* role-hint="editPom"
*/
public class EditPomAction
extends AbstractAppearanceAction
implements ModelDriven, SecureAction, Preparable
{
/**
* @plexus.requirement
*/
private MavenAppConfiguration appConfigurationStore;
/**
* The configuration.
*/
private Configuration configuration;
/**
* @plexus.requirement
*/
private CompanyPomHandler companyPomHandler;
private Model companyModel;
public String execute()
throws IOException, ArtifactInstallationException
{
// TODO: hack for passed in String[]
String[] logo = (String[]) companyModel.getProperties().get( "organization.logo" );
if ( logo != null )
{
companyModel.getProperties().put( "organization.logo", logo[0] );
}
companyPomHandler.save( companyModel, createLocalRepository() );
return SUCCESS;
}
public Object getModel()
{
return companyModel;
}
public void prepare()
throws ProjectBuildingException, ArtifactMetadataRetrievalException
{
configuration = appConfigurationStore.getConfiguration();
CompanyPom companyPom = configuration.getCompanyPom();
companyModel = companyPomHandler.getCompanyPomModel( companyPom, createLocalRepository() );
if ( companyModel == null )
{
companyModel = new Model();
companyModel.setModelVersion( "4.0.0" );
companyModel.setPackaging( "pom" );
if ( companyPom != null )
{
companyModel.setGroupId( companyPom.getGroupId() );
companyModel.setArtifactId( companyPom.getArtifactId() );
}
}
}
public SecureActionBundle getSecureActionBundle()
throws SecureActionException
{
SecureActionBundle bundle = new SecureActionBundle();
bundle.setRequiresAuthentication( true );
bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
return bundle;
}
public Model getCompanyModel()
{
return companyModel;
}
}

View File

@ -49,7 +49,7 @@ public class RoleExistanceEnvironmentCheck
implements EnvironmentCheck
{
/**
* @plexus.requirement
* @plexus.requirement role-hint="jdo"
*/
private ArchivaDAO dao;

View File

@ -41,7 +41,7 @@ public class ConfigurationInterceptor
implements Interceptor
{
/**
* @plexus.requirement
* @plexus.requirement role-hint="jdo"
*/
private ArchivaDAO dao;

View File

@ -50,7 +50,7 @@ public class ConfigurationSynchronization
implements RegistryListener, Initializable
{
/**
* @plexus.requirement
* @plexus.requirement role-hint="jdo"
*/
private ArchivaDAO dao;

View File

@ -59,7 +59,7 @@ public class DownloadArtifact
extends Component
{
/**
* @plexus.requirement
* @plexus.requirement role-hint="jdo"
*/
private ArchivaDAO dao;

View File

@ -70,7 +70,7 @@
<!-- TODO: can we send them back to the original location afterwards? -->
<result name="config-needed" type="redirect-action">
<param name="namespace">/admin</param>
<param name="actionName">configure</param>
<param name="actionName">repositories</param>
</result>
<!-- This redirect is triggered by the configuration interceptor -->
@ -208,13 +208,13 @@
<!-- Configuration for the admin package. -->
<package name="admin" namespace="/admin" extends="base">
<action name="index" class="configureAction" method="input">
<result name="input">/WEB-INF/jsp/admin/index.jsp</result>
<action name="index" class="repositoriesAction" method="input">
<result name="input">/WEB-INF/jsp/admin/repositories.jsp</result>
</action>
<action name="managedRepositories" class="configureAction" method="input">
<result name="input">/WEB-INF/jsp/admin/managedRepositories.jsp</result>
<action name="repositories" class="repositoriesAction" method="input">
<result name="input">/WEB-INF/jsp/admin/repositories.jsp</result>
</action>
<action name="addRepository" class="configureRepositoryAction" method="add">
@ -234,54 +234,6 @@
<result type="redirect-action">managedRepositories</result>
</action>
<action name="proxiedRepositories" class="configureAction" method="input">
<result name="input">/WEB-INF/jsp/admin/proxiedRepositories.jsp</result>
</action>
<action name="addProxiedRepository" class="configureProxiedRepositoryAction" method="add">
<result name="input">/WEB-INF/jsp/admin/addProxiedRepository.jsp</result>
<result type="redirect-action">proxiedRepositories</result>
</action>
<action name="editProxiedRepository" class="configureProxiedRepositoryAction" method="edit">
<result name="input">/WEB-INF/jsp/admin/editProxiedRepository.jsp</result>
<result type="redirect-action">proxiedRepositories</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
<action name="deleteProxiedRepository" class="deleteProxiedRepositoryAction">
<result name="input">/WEB-INF/jsp/admin/deleteProxiedRepository.jsp</result>
<result type="redirect-action">proxiedRepositories</result>
</action>
<action name="syncedRepositories" class="configureAction" method="input">
<result name="input">/WEB-INF/jsp/admin/syncedRepositories.jsp</result>
</action>
<action name="addSyncedRepository" class="configureSyncedRepositoryAction">
<result name="input">/WEB-INF/jsp/admin/selectSyncedRepository.jsp</result>
<result type="chain">
<param name="actionName">addSelectedSyncedRepository</param>
<param name="method">input</param>
</result>
</action>
<action name="addSelectedSyncedRepository" class="configureSyncedRepositoryAction" method="add">
<result name="input">/WEB-INF/jsp/admin/addSyncedRepository.jsp</result>
<result type="redirect-action">syncedRepositories</result>
</action>
<action name="editSyncedRepository" class="configureSyncedRepositoryAction" method="edit">
<result name="input">/WEB-INF/jsp/admin/editSyncedRepository.jsp</result>
<result type="redirect-action">syncedRepositories</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
<action name="deleteSyncedRepository" class="deleteSyncedRepositoryAction">
<result name="input">/WEB-INF/jsp/admin/deleteSyncedRepository.jsp</result>
<result type="redirect-action">syncedRepositories</result>
</action>
<action name="configure" class="configureAction" method="input">
<result name="input">/WEB-INF/jsp/admin/configure.jsp</result>
<interceptor-ref name="unconfiguredStack"/>
@ -293,10 +245,6 @@
<interceptor-ref name="unconfiguredStack"/>
</action>
<action name="runIndexer" class="runRepositoryTaskAction" method="runRefresh">
<result type="redirect-action">index</result>
</action>
<action name="reports" class="reportsAction">
<result>/WEB-INF/jsp/reports/reports.jsp</result>
</action>
@ -307,6 +255,8 @@
<result name="wait" type="redirect">/admin/reports.action?reportGroup=${reportGroup}&amp;repositoryId=${repositoryId}&amp;filter=${filter}</result>
<result name="success" type="redirect">/admin/reports.action?reportGroup=${reportGroup}&amp;repositoryId=${repositoryId}&amp;filter=${filter}</result>
</action>
<!-- The following are needed by the maven-app-configuration-web artifact -->
<action name="configureAppearance" class="configureAppearance" method="input">
<result name="input">/WEB-INF/jsp/admin/appearance.jsp</result>

View File

@ -0,0 +1,150 @@
<%--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
--%>
<%@ taglib prefix="ww" uri="/webwork" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="pss" uri="/plexusSecuritySystem" %>
<html>
<head>
<title>Administration - Repositories</title>
<ww:head/>
</head>
<body>
<h1>Administration - Repositories</h1>
<div id="contentArea">
<div>
<div style="float: right">
<%-- TODO replace with icons --%>
<pss:ifAuthorized permission="archiva-manage-configuration">
<ww:url id="addRepositoryUrl" action="addRepository" method="input"/>
<ww:a href="%{addRepositoryUrl}">Add Repository</ww:a>
</pss:ifAuthorized>
</div>
<h2>Managed Repositories</h2>
</div>
<ww:set name="repositories" value="model.repositories"/>
<c:if test="${empty(repositories)}">
<strong>There are no managed repositories configured yet.</strong>
</c:if>
<%--
<c:forEach items="${repositories}" var="repository" varStatus="i">
<div>
<div style="float: right">
<pss:ifAnyAuthorized permissions="archiva-manage-configuration">
<ww:url id="editRepositoryUrl" action="editRepository" method="input">
<ww:param name="repoId" value="%{'${repository.id}'}"/>
</ww:url>
<ww:url id="deleteRepositoryUrl" action="deleteRepository" method="input">
<ww:param name="repoId" value="%{'${repository.id}'}"/>
</ww:url>
<ww:a href="%{editRepositoryUrl}">Edit Repository</ww:a>
<ww:a href="%{deleteRepositoryUrl}">Delete Repository</ww:a>
</pss:ifAnyAuthorized>
</div>
<h3>${repository.name}</h3>
<table class="infoTable">
<tr>
<th>Identifier</th>
<td>
<code>${repository.id}</code>
</td>
</tr>
<tr>
<th>Directory</th>
<td>${repository.directory}</td>
</tr>
<tr>
<th>WebDAV URL</th>
<td><a href="${urlbase}${repository.urlName}/">${urlbase}${repository.urlName}/</a></td>
</tr>
<tr>
<th>Type</th>
<% - - TODO: can probably just use layout appended to a key prefix in i18n to simplify this - - %>
<td>
<c:choose>
<c:when test="${repository.layout == 'default'}">
Maven 2.x Repository
</c:when>
<c:otherwise>
Maven 1.x Repository
</c:otherwise>
</c:choose>
</td>
</tr>
<tr>
<th>Snapshots Included</th>
<td class="${repository.includeSnapshots ? 'donemark' : 'errormark'} booleanIcon"> ${repository.includeSnapshots}</td>
</tr>
<tr>
<th>Indexed</th>
<td class="${repository.indexed ? 'donemark' : 'errormark'} booleanIcon"> ${repository.indexed}</td>
</tr>
<tr>
<th>POM Snippet</th>
<td><a href="#" onclick="Effect.toggle('repoPom${repository.id}','slide'); return false;">Show POM Snippet</a><br/>
<% - - DO NOT REFORMAT THIS SECTION - - %>
<pre class="pom" style="display: none;" id="repoPom${repository.id}"><code>&lt;project>
...
&lt;distributionManagement>
&lt;${repository.includeSnapshots ? 'snapshotRepository' : 'repository'}>
&lt;id>${repository.id}&lt;/id>
&lt;url>dav:${urlbase}${repository.urlName}&lt;/url>
<c:if test="${repository.layout != 'default'}">
&lt;layout>${repository.layout}&lt;/layout>
</c:if>
&lt;/${repository.includeSnapshots ? 'snapshotRepository' : 'repository'}>
&lt;/distributionManagement>
&lt;repositories>
&lt;repository>
&lt;id>${repository.id}&lt;/id>
&lt;name>${repository.name}&lt;/name>
&lt;url>${urlbase}${repository.urlName}/&lt;/url>
<c:if test="${repository.layout != 'default'}">
&lt;layout>${repository.layout}&lt;/layout>
</c:if>
&lt;releases>
&lt;enabled>${repository.includeSnapshots ? 'false' : 'true'}&lt;/enabled>
&lt;/releases>
&lt;snapshots>
&lt;enabled>${repository.includeSnapshots ? 'true' : 'false'}&lt;/enabled>
&lt;/snapshots>
&lt;/repository>
&lt;/repositories>
...
&lt;/project>
</code></pre>
</td>
</tr>
</table>
</div>
</c:forEach>
--%>
</div>
</body>
</html>