aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-05-30 16:05:28 +0000
committerOlivier Lamy <olamy@apache.org>2012-05-30 16:05:28 +0000
commitbbadcdcf91b5a6d00e1f533cb3ec055745509271 (patch)
tree997c696612e206d179b788f4ea0aec903932e065 /archiva-modules/archiva-web
parente9c63be0d2a9cd36b41922ee7b4ca5360312fe1d (diff)
downloadarchiva-bbadcdcf91b5a6d00e1f533cb3ec055745509271.tar.gz
archiva-bbadcdcf91b5a6d00e1f533cb3ec055745509271.zip
start work on deleting artifacts tru the ui
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1344323 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-web')
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java9
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java3
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties1
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js193
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js8
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html4
6 files changed, 126 insertions, 92 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java
index 92662b78e..b82ee5d16 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java
@@ -19,11 +19,11 @@ package org.apache.archiva.rest.api.services;
* under the License.
*/
+import org.apache.archiva.redback.authorization.RedbackAuthorization;
import org.apache.archiva.repository.scanner.RepositoryScanStatistics;
import org.apache.archiva.rest.api.model.Artifact;
import org.apache.archiva.rest.api.model.ArtifactTransferRequest;
import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.archiva.redback.authorization.RedbackAuthorization;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
@@ -111,20 +111,21 @@ public interface RepositoriesService
@Path( "deleteArtifact" )
- @GET
+ @POST
+ @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
@RedbackAuthorization( noPermission = true )
/**
* <b>permissions are checked in impl</b>
* @since 1.4-M2
*/
- Boolean deleteArtifact( @QueryParam( "" ) Artifact artifact, @QueryParam( "repositoryId" ) String repositoryId )
+ Boolean deleteArtifact( Artifact artifact )
throws ArchivaRestServiceException;
@Path( "isAuthorizedToDeleteArtifacts/{repositoryId}" )
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
- @RedbackAuthorization( noPermission = true, noRestriction = true)
+ @RedbackAuthorization( noPermission = true, noRestriction = true )
Boolean isAuthorizedToDeleteArtifacts( @PathParam( "repositoryId" ) String repoId )
throws ArchivaRestServiceException;
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
index 4a25b5f87..3890a4cf3 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
@@ -620,10 +620,11 @@ public class DefaultRepositoriesService
}
}
- public Boolean deleteArtifact( Artifact artifact, String repositoryId )
+ public Boolean deleteArtifact( Artifact artifact )
throws ArchivaRestServiceException
{
+ String repositoryId = artifact.getContext();
if ( StringUtils.isEmpty( repositoryId ) )
{
throw new ArchivaRestServiceException( "repositoryId cannot be null", 400, null );
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
index 305d3f38b..7a047e59a 100644
--- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
+++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
@@ -264,6 +264,7 @@ artifact.detail.tab.header.dependency.tree=Dependency Tree
artifact.detail.tab.header.used.by=Used By
artifact.detail.tab.header.file.content=Artifacts Content
artifact.detail.tab.header.file.download=Artifacts
+artifact.deleted=Artifact deleted.
browse.artifact.version=Version
browse.artifact.pom.snippet=POM Snippet
browse.artifact.parent=Parent
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
index dd0ab4a7a..31f1394ee 100644
--- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
+++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
@@ -273,95 +273,21 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
}
if ($(e.target).attr("href")=="#artifact-details-download-content") {
- $.log("artifact metadata");
- //
mainContent.find("#artifact-details-download-content" ).html(smallSpinnerImg());
var artifactDownloadInfosUrl = "restServices/archivaServices/browseService/artifactDownloadInfos/"+encodeURIComponent(self.groupId);
artifactDownloadInfosUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
artifactDownloadInfosUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
$.get(artifactDownloadInfosUrl,function(data){
- $("#artifact-details-download-content" ).html($("#artifact-details-download-content_tmpl").tmpl({artifactDownloadInfos:data}));
+ var artifactDetailsDownloadViewModel = new ArtifactDetailsDownloadViewModel(mapArtifacts(data));
+ mainContent.find("#artifact-details-download-content" ).attr("data-bind",'template:{name:"artifact-details-download-content_tmpl"}');
+ ko.applyBindings(artifactDetailsDownloadViewModel,mainContent.find("#artifact-details-download-content" ).get(0));
});
return;
}
if ($(e.target).attr("href")=="#artifact-details-files-content") {
- mainContent.find("#artifact-details-files-content" ).html(smallSpinnerImg());
- var artifactDownloadInfosUrl = "restServices/archivaServices/browseService/artifactDownloadInfos/"+encodeURIComponent(self.groupId);
- artifactDownloadInfosUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
- artifactDownloadInfosUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
-
- $.get(artifactDownloadInfosUrl,function(data){
- $("#artifact-details-files-content" ).html($("#artifact-details-files-content_tmpl").tmpl({artifactDownloadInfos:data}));
- mainContent.find("#artifact-content-list-files li" ).on("click",function(){
- mainContent.find("#artifact_content_tree").html("");
- mainContent.find("#artifact-content-text" ).html("");
- var idValue = $(this ).attr("id");
- var splitted = idValue.split(":");
-
- var classifier=splitted[0];//idValue.substringBeforeLast(":");
- var version=splitted[1];
- var type = splitted[2];
-
- $.log("click:" + idValue + " -> " + classifier + ":" + type + ":" + version);
- if (type=="pom"){
- $.log("show pom");
- var pomContentUrl = "restServices/archivaServices/browseService/artifactContentText/"+encodeURIComponent(self.groupId);
- pomContentUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(version);
- pomContentUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
- pomContentUrl+="&t=pom";
- mainContent.find("#artifact-content-text" ).html(smallSpinnerImg());
- $.ajax({
- url: pomContentUrl,
- success: function(data) {
- var text = data.content.replace(/</g,'&lt;');
- text=text.replace(/>/g,"&gt;");
- mainContent.find("#artifact-content-text" ).html(text);
- prettyPrint();
- goToAnchor("artifact-content-text-header");
- }
- });
- return;
- }
- var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
- entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(version);
- entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
- if(classifier){
- entriesUrl+="&c="+encodeURIComponent(classifier);
- }
- $("#main-content #artifact_content_tree").fileTree({
- script: entriesUrl,
- root: ""
- },function(file) {
- $.log("file:"+file.substringBeforeLast("/")+',classifier:'+classifier);
- var fileContentUrl = "restServices/archivaServices/browseService/artifactContentText/"+encodeURIComponent(self.groupId);
- fileContentUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(version);
- fileContentUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
- if(type){
- fileContentUrl+="&t="+encodeURIComponent(type);
- }
- if(classifier){
- fileContentUrl+="&c="+encodeURIComponent(classifier);
- }
- fileContentUrl+="&p="+encodeURIComponent(file.substringBeforeLast("/"));
- $.ajax({
- url: fileContentUrl,
- success: function(data) {
- var text = data.content.replace(/</g,'&lt;');
- text=text.replace(/>/g,"&gt;");
- mainContent.find("#artifact-content-text" ).html(smallSpinnerImg());
- mainContent.find("#artifact-content-text" ).html(text);
- prettyPrint();
- goToAnchor("artifact-content-text-header");
- }
- });
- }
- );
- });
-
- });
-
+ displayArtifactFilesContent(self);
}
});
}
@@ -461,6 +387,109 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
}
+ ArtifactDetailsDownloadViewModel=function(artifacts){
+ this.artifacts=ko.observableArray(artifacts);
+ var self=this;
+ deleteArtifact=function(artifact){
+ $.log("deleteArtifact");
+ clearUserMessages();
+ $.ajax({
+ url:"restServices/archivaServices/repositoriesService/deleteArtifact",
+ type:"POST",
+ dataType:"json",
+ contentType: 'application/json',
+ data: ko.toJSON(artifact),
+ success:function(data){
+ self.artifacts.remove(artifact);
+ displaySuccessMessage( $.i18n.prop('artifact.deleted'));
+ },
+ error:function(data){
+ displayRestError(data,"user-messages");
+ }
+ });
+
+ }
+ }
+
+ displayArtifactFilesContent=function(self){
+ var mainContent = $("#main-content");
+ mainContent.find("#artifact-details-files-content" ).html(smallSpinnerImg());
+ var artifactDownloadInfosUrl = "restServices/archivaServices/browseService/artifactDownloadInfos/"+encodeURIComponent(self.groupId);
+ artifactDownloadInfosUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
+ artifactDownloadInfosUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
+
+ $.get(artifactDownloadInfosUrl,function(data){
+ $("#artifact-details-files-content" ).html($("#artifact-details-files-content_tmpl").tmpl({artifactDownloadInfos:data}));
+ mainContent.find("#artifact-content-list-files li" ).on("click",function(){
+ mainContent.find("#artifact_content_tree").html("");
+ mainContent.find("#artifact-content-text" ).html("");
+ var idValue = $(this ).attr("id");
+ var splitted = idValue.split(":");
+
+ var classifier=splitted[0];//idValue.substringBeforeLast(":");
+ var version=splitted[1];
+ var type = splitted[2];
+
+ $.log("click:" + idValue + " -> " + classifier + ":" + type + ":" + version);
+ if (type=="pom"){
+ $.log("show pom");
+ var pomContentUrl = "restServices/archivaServices/browseService/artifactContentText/"+encodeURIComponent(self.groupId);
+ pomContentUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(version);
+ pomContentUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
+ pomContentUrl+="&t=pom";
+ mainContent.find("#artifact-content-text" ).html(smallSpinnerImg());
+ $.ajax({
+ url: pomContentUrl,
+ success: function(data) {
+ var text = data.content.replace(/</g,'&lt;');
+ text=text.replace(/>/g,"&gt;");
+ mainContent.find("#artifact-content-text" ).html(text);
+ prettyPrint();
+ goToAnchor("artifact-content-text-header");
+ }
+ });
+ return;
+ }
+ var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
+ entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(version);
+ entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
+ if(classifier){
+ entriesUrl+="&c="+encodeURIComponent(classifier);
+ }
+ $("#main-content #artifact_content_tree").fileTree({
+ script: entriesUrl,
+ root: ""
+ },function(file) {
+ $.log("file:"+file.substringBeforeLast("/")+',classifier:'+classifier);
+ var fileContentUrl = "restServices/archivaServices/browseService/artifactContentText/"+encodeURIComponent(self.groupId);
+ fileContentUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(version);
+ fileContentUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
+ if(type){
+ fileContentUrl+="&t="+encodeURIComponent(type);
+ }
+ if(classifier){
+ fileContentUrl+="&c="+encodeURIComponent(classifier);
+ }
+ fileContentUrl+="&p="+encodeURIComponent(file.substringBeforeLast("/"));
+ $.ajax({
+ url: fileContentUrl,
+ success: function(data) {
+ var text = data.content.replace(/</g,'&lt;');
+ text=text.replace(/>/g,"&gt;");
+ mainContent.find("#artifact-content-text" ).html(smallSpinnerImg());
+ mainContent.find("#artifact-content-text" ).html(text);
+ prettyPrint();
+ goToAnchor("artifact-content-text-header");
+ }
+ });
+ }
+ );
+ });
+
+ });
+
+ }
+
ArtifactContentEntry=function(path,file,depth){
this.path=path;
this.file=file;
@@ -1016,7 +1045,7 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
//-----------------------------------------
Artifact=function(context,url,groupId,artifactId,repositoryId,version,prefix,goals,bundleVersion,bundleSymbolicName,
bundleExportPackage,bundleExportService,bundleDescription,bundleName,bundleLicense,bundleDocUrl,
- bundleImportPackage,bundleRequireBundle,classifier,packaging,fileExtension){
+ bundleImportPackage,bundleRequireBundle,classifier,packaging,fileExtension,size){
var self=this;
@@ -1095,6 +1124,8 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
//private String fileExtension;
this.fileExtension=fileExtension;
+ this.size=size;
+
this.crumbEntries=function(){
return calculateCrumbEntries(self.groupId,self.artifactId,self.version);
}
@@ -1126,7 +1157,7 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
mapArtifacts=function(data){
if (data){
- return $.isArray(data )? $.map(data,function(item){return mapArtifact(item)}) : [data];
+ return $.isArray(data)? $.map(data,function(item){return mapArtifact(item)}) : [data];
}
return [];
}
@@ -1137,7 +1168,7 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
data.goals,data.bundleVersion,data.bundleSymbolicName,
data.bundleExportPackage,data.bundleExportService,data.bundleDescription,data.bundleName,
data.bundleLicense,data.bundleDocUrl,
- data.bundleImportPackage,data.bundleRequireBundle,data.classifier,data.packaging,data.fileExtension);
+ data.bundleImportPackage,data.bundleRequireBundle,data.classifier,data.packaging,data.fileExtension,data.size);
}
return null;
}
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js
index 605b7a5fd..4f2c10c69 100644
--- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js
+++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js
@@ -293,10 +293,10 @@ define("utils",["jquery","i18n","jquery.tmpl"], function() {
}
if (data.errorKey && data.errorKey.length>0){
- displayErrorMessage($.i18n.prop( data.errorKey ),idToAppend);
- } else {
- $.log("data.errorMessage:"+data.errorMessage);
- displayErrorMessage(data.errorMessage,idToAppend);
+ displayErrorMessage($.i18n.prop( data.errorKey ),idToAppend);
+ } else {
+ $.log("data.errorMessage:"+data.errorMessage);
+ displayErrorMessage(data.errorMessage,idToAppend);
}
}
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html
index ffd93c668..2a656b4b1 100644
--- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html
+++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html
@@ -835,9 +835,9 @@
<script id="artifact-details-download-content_tmpl" type="text/html">
<ul id="artifact-download-list-files">
- {{each artifactDownloadInfos}}
+ {{each(i, row) artifacts()}}
<li>
- <a href="${$value.url}">${$value.packaging}:${$value.version}&nbsp;-&nbsp;${$value.size}</a>
+ <a href="#" data-bind="click: function(){deleteArtifact(row)}">del</a>:<a href="${row.url}">${row.packaging}:${row.version}&nbsp;-&nbsp;${row.size}</a>
</li>
{{/each}}
</ul>