[ 
https://issues.apache.org/jira/browse/MRM-2004?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16975316#comment-16975316
 ] 

Martin Stockhammer commented on MRM-2004:
-----------------------------------------

>From the mailing list:
Hi,

I am trying to use the rest service copyArtifact, but I can't get it to
work. Feels like I have tried everything. I am trying to do this with
groovy and this is how my code looks at the moment. The info in
artifactTransferRequest is from the response of searchArtifacts

def copyArtifact() {
  def baseUrl = "..."
  def request = new RESTClient(baseUrl + "
_/restServices/archivaServices/_
")
  request.headers['Authorization'] = "Basic " +
("username:pass".bytes.encodeBase64().toString())
  request.handler.failure = \{ response ->
    println "Unexpected failure: ${response.status}"
  }
  def copyArtifactResponse = request.post(
    path: "repositoriesService/copyArtifact",
    contentType: JSON,
    requestContentType: XML,
    body: \{
      artifactTransferRequest {
        targetRepositoryId  "tagged-releases"
        packaging           "dll"
        fileExtension       "dll"
        type                "dll"
        artifactId          "bla4"
        groupId             "se..."
        version             "2020.1"
        repositoryId        "release"
        context             "release"
        url                 "..."
      }
    }
  )

  println "Status: " + copyArtifactResponse.status
  if (copyArtifactResponse.data) \{
    println("Content Type: " + copyArtifactResponse.contentType)
    println("Headers: " + copyArtifactResponse.getAllHeaders())
    println("Body:\n" +
JsonOutput.prettyPrint(JsonOutput.toJson(copyArtifactResponse.data)))
  }
}


Here is the response I get:
Unexpected failure: 500
Caught: java.lang.NullPointerException: Cannot get property 'status' on
null object
java.lang.NullPointerException: Cannot get property 'status' on null
object
 

> Rest call for copyArtifact throws NullpointerException if destination exists
> ----------------------------------------------------------------------------
>
>                 Key: MRM-2004
>                 URL: https://issues.apache.org/jira/browse/MRM-2004
>             Project: Archiva
>          Issue Type: Bug
>          Components: rest services
>    Affects Versions: 2.2.4
>            Reporter: Martin Stockhammer
>            Assignee: Martin Stockhammer
>            Priority: Major
>             Fix For: 3.0.0
>
>
> The rest service copyArtifact throws NullpointerException, if the destination 
> artifact exists already.
> Should either overwrite, or return a proper error response.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to