mirror of https://github.com/apache/archiva.git
fix MRM-670 - server-side validation and LegacyArtifactPath computation
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@615904 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ef81ce7ee6
commit
66b00c3b3e
|
@ -54,6 +54,16 @@ public class AddLegacyArtifactPathAction
|
|||
|
||||
private LegacyArtifactPath legacyArtifactPath;
|
||||
|
||||
private String groupId;
|
||||
|
||||
private String artifactId;
|
||||
|
||||
private String version;
|
||||
|
||||
private String classifier;
|
||||
|
||||
private String type;
|
||||
|
||||
|
||||
public void prepare()
|
||||
{
|
||||
|
@ -67,14 +77,18 @@ public class AddLegacyArtifactPathAction
|
|||
|
||||
public String commit()
|
||||
{
|
||||
this.legacyArtifactPath.setArtifact(
|
||||
this.groupId + ":" + this.artifactId + ":" + this.classifier + ":" + this.version + ":" + this.type );
|
||||
|
||||
// Check the proposed Artifact macthes the path
|
||||
ArtifactReference artifact = new ArtifactReference();
|
||||
|
||||
artifact.setGroupId( this.legacyArtifactPath.getGroupId() );
|
||||
artifact.setArtifactId( this.legacyArtifactPath.getArtifactId() );
|
||||
artifact.setClassifier( this.legacyArtifactPath.getClassifier() );
|
||||
artifact.setVersion( this.legacyArtifactPath.getVersion() );
|
||||
artifact.setType( this.legacyArtifactPath.getType() );
|
||||
|
||||
|
||||
artifact.setGroupId( this.groupId );
|
||||
artifact.setArtifactId( this.artifactId );
|
||||
artifact.setClassifier( this.classifier );
|
||||
artifact.setVersion( this.version );
|
||||
artifact.setType( this.type );
|
||||
|
||||
String path = repositoryContent.toPath( artifact );
|
||||
if ( ! path.equals( this.legacyArtifactPath.getPath() ) )
|
||||
{
|
||||
|
@ -117,4 +131,54 @@ public class AddLegacyArtifactPathAction
|
|||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
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 getClassifier()
|
||||
{
|
||||
return classifier;
|
||||
}
|
||||
|
||||
public void setClassifier( String classifier )
|
||||
{
|
||||
this.classifier = classifier;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType( String type )
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
<?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="legacyArtifactPath.path">
|
||||
<field-validator type="requiredstring">
|
||||
<message>You must enter a legacy path.</message>
|
||||
</field-validator>
|
||||
</field>
|
||||
<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="type">
|
||||
<field-validator type="requiredstring">
|
||||
<message>You must enter a type.</message>
|
||||
</field-validator>
|
||||
</field>
|
||||
</validators>
|
|
@ -63,31 +63,17 @@
|
|||
|
||||
}
|
||||
}
|
||||
function computeArtifactReference()
|
||||
{
|
||||
document.getElementById("addLegacyArtifactPath_legacyArtifactPath_artifact").value
|
||||
= document.getElementById("addLegacyArtifactPath_groupId").value
|
||||
+ ":"
|
||||
+ document.getElementById("addLegacyArtifactPath_artifactId").value
|
||||
+ ":"
|
||||
+ document.getElementById("addLegacyArtifactPath_version").value
|
||||
+ ":"
|
||||
+ document.getElementById("addLegacyArtifactPath_classifier").value
|
||||
+ ":"
|
||||
+ document.getElementById("addLegacyArtifactPath_type").value;
|
||||
}
|
||||
</script>
|
||||
|
||||
<ww:actionmessage/>
|
||||
<ww:actionerror/>
|
||||
<ww:form method="post" action="addLegacyArtifactPath!commit" namespace="/admin" validate="true" onsubmit="computeArtifactReference()">
|
||||
<ww:form method="post" action="addLegacyArtifactPath!commit" namespace="/admin" validate="true">
|
||||
<ww:textfield name="legacyArtifactPath.path" label="Path" size="50" required="true" onchange="parse( this.value )"/>
|
||||
<ww:textfield name="groupId" label="GroupId" size="20" required="true" disabled="true"/>
|
||||
<ww:textfield name="groupId" label="GroupId" size="20" required="true"/>
|
||||
<ww:textfield name="artifactId" label="ArtifactId" size="20" required="true"/>
|
||||
<ww:textfield name="version" label="Version" size="20" required="true"/>
|
||||
<ww:textfield name="classifier" label="Classifier" size="20" required="false"/>
|
||||
<ww:textfield name="type" label="Type" size="20" required="true" disabled="true"/>
|
||||
<ww:hidden name="legacyArtifactPath.artifact"/>
|
||||
<ww:textfield name="type" label="Type" size="20" required="true"/>
|
||||
<ww:submit value="Add Legacy Artifact Path"/>
|
||||
</ww:form>
|
||||
|
||||
|
|
Loading…
Reference in New Issue