From 66b00c3b3ee164584a2f223c61a1ad7658c9bb36 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Mon, 28 Jan 2008 15:02:17 +0000 Subject: [PATCH] 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 --- .../legacy/AddLegacyArtifactPathAction.java | 78 +++++++++++++++++-- ...AddLegacyArtifactPathAction-validation.xml | 50 ++++++++++++ .../jsp/admin/addLegacyArtifactPath.jsp | 20 +---- 3 files changed, 124 insertions(+), 24 deletions(-) create mode 100644 archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction-validation.xml 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 index 6dca666ea..71d6c3bc8 100644 --- 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 @@ -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; + } } diff --git a/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction-validation.xml b/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction-validation.xml new file mode 100644 index 000000000..1725a33ec --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction-validation.xml @@ -0,0 +1,50 @@ + + + + + + + + + You must enter a legacy path. + + + + + You must enter a groupId. + + + + + You must enter an artifactId. + + + + + You must enter a version. + + + + + You must enter a type. + + + \ No newline at end of file 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 index 4258e8cc9..6c647d426 100644 --- 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 @@ -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; - } - + - + - - + -- 2.39.5