import java.util.List;
/**
- * Upload an artifact using Jakarta file upload in webwork. If set by the user
- * a pom will also be generated. Metadata will also be updated if one exists,
- * otherwise it would be created.
+ * Upload an artifact using Jakarta file upload in webwork. If set by the user a pom will also be generated. Metadata
+ * will also be updated if one exists, otherwise it would be created.
*
* @author <a href="mailto:wsmoak@apache.org">Wendy Smoak</a>
* @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
- *
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="uploadAction"
*/
public class UploadAction
* Flag whether to generate a pom for the artifact or not.
*/
private boolean generatePom;
-
+
/**
* List of managed repositories to deploy to.
*/
new ArrayList<String>( configuration.getConfiguration().getManagedRepositoriesAsMap().keySet() );
}
- public String upload()
+ public String input()
{
- // TODO form validation
return INPUT;
}
}
updateMetadata( getMetadata( targetPath.getAbsolutePath() ) );
-
+
+ addActionMessage( "Artifact \'" + groupId + ":" + artifactId + ":" + version +
+ "\' was successfully deployed to repository \'" + repositoryId + "\'!" );
+
return SUCCESS;
}
catch ( RepositoryNotFoundException re )
{
availableVersions.add( version );
}
-
+
String latestVersion = availableVersions.get( availableVersions.size() - 1 );
metadata.setLatestVersion( latestVersion );
metadata.setAvailableVersions( availableVersions );
metadata.setLastUpdatedTimestamp( Calendar.getInstance().getTime() );
-
- if( !VersionUtil.isSnapshot( version ) )
+
+ if ( !VersionUtil.isSnapshot( version ) )
{
metadata.setReleasedVersion( latestVersion );
- }
+ }
// TODO:
- // what about the metadata checksums? re-calculate or
- // just leave it to the consumers to fix it?
+ // what about the metadata checksums? re-calculate or
+ // just leave it to the consumers to fix it? or just delete it
+ // and let the consumers create a new checksum file?
}
else
{
metadata.setLatestVersion( version );
metadata.setLastUpdatedTimestamp( Calendar.getInstance().getTime() );
metadata.setAvailableVersions( availableVersions );
-
- if( !VersionUtil.isSnapshot( version ) )
+
+ if ( !VersionUtil.isSnapshot( version ) )
{
metadata.setReleasedVersion( version );
}
- }
-
+ }
+
RepositoryMetadataWriter.write( metadata, metadataFile );
}
-
+
public void validate()
{
try
addActionError( "User is not authorized to upload in repository " + repositoryId );
}
- // TODO fix validation
- /*
if ( file == null || file.length() == 0 )
{
addActionError( "Please add a file to upload." );
}
-
+
if ( !VersionUtil.isVersion( version ) )
{
addActionError( "Invalid version." );
- }
- */
+ }
}
catch ( PrincipalNotFoundException pe )
{
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ 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 validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+ <field name="groupId">
+ <field-validator type="requiredstring">
+ <message>You must enter a groupId.</message>
+ </field-validator>
+ </field>
+ <field name="artifactId">
+ <field-validator type="requiredstring">
+ <message>You must enter an artifactId.</message>
+ </field-validator>
+ </field>
+ <field name="version">
+ <field-validator type="requiredstring">
+ <message>You must enter a version.</message>
+ </field-validator>
+ </field>
+ <field name="packaging">
+ <field-validator type="requiredstring">
+ <message>You must enter a packaging.</message>
+ </field-validator>
+ </field>
+</validators>
\ No newline at end of file
<result name="input">/WEB-INF/jsp/findArtifact.jsp</result>
</action>
- <action name="upload" class="uploadAction" method="upload">
+ <action name="upload" class="uploadAction" method="input">
<result name="input">/WEB-INF/jsp/upload.jsp</result>
- <result name="success">/WEB-INF/jsp/upload.jsp</result>
+ <result name="error">/WEB-INF/jsp/upload.jsp</result>
+ <result name="success" type="redirect-action">upload</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
<interceptor-ref name="fileUpload"/>
</action>