Index: archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java =================================================================== --- archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java (revision 0) +++ archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java (revision 0) @@ -0,0 +1,151 @@ +package org.apache.maven.archiva.web.action; + +import org.codehaus.plexus.xwork.action.PlexusActionSupport; +import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.RepositoryConfiguration; +import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory; +import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout; +import org.apache.maven.archiva.repository.layout.LayoutException; +import org.apache.maven.archiva.model.ArchivaArtifact; + +import java.io.File; + +/** + * Upload an artifact. + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="uploadAction" + */ +public class UploadAction + extends PlexusActionSupport +{ + + private String groupId; + + private String artifactId; + + private String version; + + private String packaging; + + private String classifier; + + private File file; + + private String contentType; + + private String filename; + + private String repositoryId; + + /** + * @plexus.requirement role-hint="default" + */ + private ArchivaConfiguration configuration; + + /** + * @plexus.requirement role-hint="default" + */ + private BidirectionalRepositoryLayoutFactory layoutFactory; + + public void setUpload( File file ) + { + this.file = file; + } + + public void setUploadContentType( String contentType ) + { + this.contentType = contentType; + } + + public void setUploadFileName( String filename ) + { + this.filename = filename; + } + + public String getGroupId() + { + return groupId; + } + + public void setGroupId( String groupId ) + { + this.groupId = groupId; + } + + public String getArtifactId() + { + return artifactId; + } + + public void setArtifactId( String artifactId ) + { + this.artifactId = artifactId; + } + + public String getVersion() + { + return version; + } + + public void setVersion( String version ) + { + this.version = version; + } + + public String getPackaging() + { + return packaging; + } + + public void setPackaging( String packaging ) + { + this.packaging = packaging; + } + + public String getClassifier() + { + return classifier; + } + + public void setClassifier( String classifier ) + { + this.classifier = classifier; + } + + + public String getRepositoryId() + { + return repositoryId; + } + + public void setRepositoryId( String repositoryId ) + { + this.repositoryId = repositoryId; + } + + public String upload() + { + getLogger().debug( "upload" ); + return SUCCESS; + } + + public String doUpload() + throws LayoutException + { + // TODO: adapt to changes in RepositoryConfiguration from the MRM-462 branch + RepositoryConfiguration rc = configuration.getConfiguration().findRepositoryById( repositoryId ); + String layout = rc.getLayout(); + String url = rc.getUrl(); + ArchivaArtifact artifact = new ArchivaArtifact( groupId, artifactId, version, classifier, packaging ); + BidirectionalRepositoryLayout repositoryLayout = layoutFactory.getLayout( layout ); + + //output from getLogger().debug(...) not appearing in logs, so... + System.out.println( "doUpload, file: " + file.getAbsolutePath() ); + System.out.println( "doUpload, path: " + repositoryLayout.toPath( artifact ) ); + + return SUCCESS; + } + + +} Index: archiva-web/archiva-webapp/src/main/resources/xwork.xml =================================================================== --- archiva-web/archiva-webapp/src/main/resources/xwork.xml (revision 567346) +++ archiva-web/archiva-webapp/src/main/resources/xwork.xml (working copy) @@ -179,6 +179,16 @@ + + /WEB-INF/jsp/upload.jsp + + + + + + /WEB-INF/jsp/upload.jsp + + /WEB-INF/jsp/browse.jsp Index: archiva-web/archiva-webapp/src/main/resources/webwork.properties =================================================================== --- archiva-web/archiva-webapp/src/main/resources/webwork.properties (revision 567346) +++ archiva-web/archiva-webapp/src/main/resources/webwork.properties (working copy) @@ -22,6 +22,8 @@ webwork.objectFactory = org.codehaus.plexus.xwork.PlexusObjectFactory webwork.url.includeParams = none -# webwork.devMode = true +webwork.devMode = true +webwork.multipart.parser=jakarta + # TODO: package up a theme and share with Continuum. Should contain everything from xhtml, and set templateDir to WEB-INF/themes Index: archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/upload.jsp =================================================================== --- archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/upload.jsp (revision 0) +++ archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/upload.jsp (revision 0) @@ -0,0 +1,63 @@ +<%-- + ~ 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. + --%> + +<%-- http://www.opensymphony.com/webwork/wikidocs/File%20Upload%20Interceptor.html --%> + +<%@ taglib prefix="ww" uri="/webwork" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="archiva" uri="http://maven.apache.org/archiva" %> +<%@ taglib prefix="redback" uri="http://plexus.codehaus.org/redback/taglib-1.0" %> + + + + Upload Artifact + + + + + +

Upload Artifact

+ +
+ + + +

groupId:

+ +

artifactId:

+ +

version:

+ +

packaging:

+ +

classifier:

+ +

repositoryId:

+ +

+ + +

+ +
+ +
+ + + Index: archiva-web/archiva-webapp/pom.xml =================================================================== --- archiva-web/archiva-webapp/pom.xml (revision 567346) +++ archiva-web/archiva-webapp/pom.xml (working copy) @@ -218,6 +218,10 @@ 1.6.2 test + + commons-fileupload + commons-fileupload + Index: pom.xml =================================================================== --- pom.xml (revision 567346) +++ pom.xml (working copy) @@ -352,6 +352,11 @@ 3.2 + commons-fileupload + commons-fileupload + 1.2 + + commons-io commons-io 1.2