From: Nicolas De Loof Date: Thu, 13 Dec 2007 11:36:18 +0000 (+0000) Subject: MRM-594 support for custom legacy-path-2-artifact-reference resolution X-Git-Tag: archiva-1.0.1~43 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=95271f756ed86f6740ee8c9e3d395c404af129cc;p=archiva.git MRM-594 support for custom legacy-path-2-artifact-reference resolution Web UI to register new exceptions to the artifact resolution algorithm. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@603891 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction.java new file mode 100644 index 000000000..8f2c0d3c1 --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction.java @@ -0,0 +1,111 @@ +package org.apache.maven.archiva.web.action.admin.legacy; + +/* + * 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.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; +import org.apache.maven.archiva.configuration.LegacyArtifactPath; +import org.apache.maven.archiva.repository.ManagedRepositoryContent; +import org.codehaus.plexus.registry.RegistryException; +import org.codehaus.plexus.xwork.action.PlexusActionSupport; + +import com.opensymphony.xwork.Preparable; + +/** + * Add a LegacyArtifactPath to archiva configuration + * + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="addLegacyArtifactPathAction" + */ +public class AddLegacyArtifactPathAction + extends PlexusActionSupport + implements Preparable +{ + /** + * @plexus.requirement + */ + private ArchivaConfiguration archivaConfiguration; + + /** + * @plexus.requirement role-hint="legacy" + */ + private ManagedRepositoryContent repositoryContent; + + + private LegacyArtifactPath legacyArtifactPath; + + + public void prepare() + { + this.legacyArtifactPath = new LegacyArtifactPath(); + } + + public String input() + { + return INPUT; + } + + public String commit() + { + ArtifactReference artifact = this.legacyArtifactPath.getArtifactReference(); + String path = repositoryContent.toPath( artifact ); + if ( ! path.equals( this.legacyArtifactPath.getPath() ) ) + { + addActionError( "artifact reference does not match the initial path : " + path ); + return ERROR; + } + + Configuration configuration = archivaConfiguration.getConfiguration(); + configuration.addLegacyArtifactPath( legacyArtifactPath ); + return saveConfiguration( configuration ); + } + + public LegacyArtifactPath getLegacyArtifactPath() + { + return legacyArtifactPath; + } + + public void setLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath ) + { + this.legacyArtifactPath = legacyArtifactPath; + } + + protected String saveConfiguration( Configuration configuration ) + { + try + { + archivaConfiguration.save( configuration ); + addActionMessage( "Successfully saved configuration" ); + } + catch ( IndeterminateConfigurationException e ) + { + addActionError( e.getMessage() ); + return INPUT; + } + catch ( RegistryException e ) + { + addActionError( "Configuration Registry Exception: " + e.getMessage() ); + return INPUT; + } + + return SUCCESS; + } +} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/DeleteLegacyArtifactPathAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/DeleteLegacyArtifactPathAction.java new file mode 100644 index 000000000..028af2929 --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/DeleteLegacyArtifactPathAction.java @@ -0,0 +1,92 @@ +package org.apache.maven.archiva.web.action.admin.legacy; + +/* + * 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 java.util.Iterator; + +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; +import org.apache.maven.archiva.configuration.LegacyArtifactPath; +import org.codehaus.plexus.registry.RegistryException; +import org.codehaus.plexus.xwork.action.PlexusActionSupport; + +/** + * Delete a LegacyArtifactPath to archiva configuration + * + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="deleteLegacyArtifactPathAction" + */ +public class DeleteLegacyArtifactPathAction + extends PlexusActionSupport +{ + /** + * @plexus.requirement + */ + private ArchivaConfiguration archivaConfiguration; + + private String path; + + public String delete() + { + getLogger().info( "remove [" + path + "] from legacy artifact path resolution" ); + Configuration configuration = archivaConfiguration.getConfiguration(); + for ( Iterator iterator = configuration.getLegacyArtifactPaths().iterator(); iterator.hasNext(); ) + { + LegacyArtifactPath legacyArtifactPath = (LegacyArtifactPath) iterator.next(); + if (legacyArtifactPath.match( path )) + { + iterator.remove(); + } + } + return saveConfiguration( configuration ); + } + + protected String saveConfiguration( Configuration configuration ) + { + try + { + archivaConfiguration.save( configuration ); + addActionMessage( "Successfully saved configuration" ); + } + catch ( IndeterminateConfigurationException e ) + { + addActionError( e.getMessage() ); + return INPUT; + } + catch ( RegistryException e ) + { + addActionError( "Configuration Registry Exception: " + e.getMessage() ); + return INPUT; + } + + return SUCCESS; + } + + public String getPath() + { + return path; + } + + public void setPath( String path ) + { + this.path = path; + } +} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/LegacyArtifactPathAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/LegacyArtifactPathAction.java new file mode 100644 index 000000000..6fb0c5376 --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/LegacyArtifactPathAction.java @@ -0,0 +1,96 @@ +package org.apache.maven.archiva.web.action.admin.legacy; + +/* + * 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 java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.configuration.LegacyArtifactPath; +import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.maven.archiva.web.util.ContextUtils; +import org.codehaus.plexus.redback.rbac.Resource; +import org.codehaus.plexus.redback.xwork.interceptor.SecureAction; +import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle; +import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException; +import org.codehaus.plexus.xwork.action.PlexusActionSupport; + +import com.opensymphony.webwork.interceptor.ServletRequestAware; +import com.opensymphony.xwork.Preparable; + +/** + * Shows the LegacyArtifactPath Tab for the administrator. + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="legacyArtifactPathAction" + */ +public class LegacyArtifactPathAction + extends PlexusActionSupport + implements SecureAction, ServletRequestAware, Preparable +{ + /** + * @plexus.requirement + */ + private ArchivaConfiguration archivaConfiguration; + + private List legacyArtifactPaths; + + /** + * Used to construct the repository WebDAV URL in the repository action. + */ + private String baseUrl; + + public void setServletRequest( HttpServletRequest request ) + { + // TODO: is there a better way to do this? + this.baseUrl = ContextUtils.getBaseURL( request, "repository" ); + } + + public SecureActionBundle getSecureActionBundle() + throws SecureActionException + { + SecureActionBundle bundle = new SecureActionBundle(); + + bundle.setRequiresAuthentication( true ); + bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, + Resource.GLOBAL ); + + return bundle; + } + + public void prepare() + { + Configuration config = archivaConfiguration.getConfiguration(); + + legacyArtifactPaths = new ArrayList( config.getLegacyArtifactPaths() ); + } + + public List getLegacyArtifactPaths() + { + return legacyArtifactPaths; + } + + public String getBaseUrl() + { + return baseUrl; + } +} diff --git a/archiva-web/archiva-webapp/src/main/resources/xwork.xml b/archiva-web/archiva-webapp/src/main/resources/xwork.xml index 53c8596cd..7ca72136b 100644 --- a/archiva-web/archiva-webapp/src/main/resources/xwork.xml +++ b/archiva-web/archiva-webapp/src/main/resources/xwork.xml @@ -82,7 +82,7 @@ - + index index @@ -303,13 +303,13 @@ proxyConnectors - + /WEB-INF/jsp/admin/editProxyConnector.jsp proxyConnectors - + /WEB-INF/jsp/admin/deleteProxyConnector.jsp proxyConnectors @@ -399,6 +399,30 @@ /admin + + + + + /WEB-INF/jsp/admin/legacyArtifactPath.jsp + + legacyArtifactPath + + + + + /WEB-INF/jsp/admin/addLegacyArtifactPath.jsp + /WEB-INF/jsp/admin/addLegacyArtifactPath.jsp + legacyArtifactPath + + + + + /WEB-INF/jsp/admin/legacyArtifactPath.jsp + /WEB-INF/jsp/admin/legacyArtifactPath.jsp + legacyArtifactPath + + + diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addLegacyArtifactPath.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addLegacyArtifactPath.jsp new file mode 100644 index 000000000..9750395c8 --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addLegacyArtifactPath.jsp @@ -0,0 +1,110 @@ +<%-- + ~ 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" %> + + + + Admin: Add Legacy artifact path + + + + + +

Admin: Add Legacy artifact path

+ +
+ + + + + + + + + + + + + + + + + + +
+ + + diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/legacyArtifactPath.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/legacyArtifactPath.jsp new file mode 100644 index 000000000..97df9c7ed --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/legacyArtifactPath.jsp @@ -0,0 +1,117 @@ +<%-- + ~ 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="redback" uri="http://plexus.codehaus.org/redback/taglib-1.0" %> +<%@ taglib prefix="archiva" uri="http://maven.apache.org/archiva" %> + + + + Administration - Legacy support + + + + + +

Administration - Legacy artifacts path resolution

+ +
+ + + + +
+
+ + + + " alt="" width="16" height="16"/> + Add + + +
+

Legacy artifacts path resolution

+ + + + <%-- No Managed Repositories. --%> + There are no legacy artifact path configured yet. + + +<%-- Display the repositories. --%> + + + + + + + + + + + +
+ +
+ <%-- TODO: make some icons --%> + + + + + + " alt="" width="16" height="16"/> + Delete + + +
+ +
+ " alt="" width="32" height="32"/> +
+ + + + + + + + + + +
Path + ${legacyArtifactPath.path} +
Artifact + ${legacyArtifactPath.artifact} +
+ +
+
+ +
+
+ + + +
+ +
+ + + diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp index 0ddc11584..73e232074 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp @@ -136,6 +136,9 @@
  • Proxy Connectors
  • +
  • + Legacy support +
  • Network Proxies