You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2019/08/26 16:34:51 UTC

[sling-org-apache-sling-committer-cli] branch master updated (4545273 -> 3dfa95d)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-committer-cli.git.


    from 4545273  trivial: corrected name in README.md
     new 4bc0019  SLING-8661 - Moving Jira issues to next version fails with 405 status code
     new 3dfa95d  Add a commented-out HTTP debug config.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/sling/cli/impl/jira/VersionClient.java  | 26 ++++++++++++++--------
 src/main/resources/conf/logback-default.xml        |  3 +++
 2 files changed, 20 insertions(+), 9 deletions(-)


[sling-org-apache-sling-committer-cli] 01/02: SLING-8661 - Moving Jira issues to next version fails with 405 status code

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-committer-cli.git

commit 4bc0019292b6f091ac44811191ae40ee913ceed4
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Mon Aug 26 18:20:20 2019 +0200

    SLING-8661 - Moving Jira issues to next version fails with 405 status code
    
    Fixed multiple issues:
    - use an HTTP context with authentication enabled
    - use PUT instead of POST
    - actually send the request body
---
 .../apache/sling/cli/impl/jira/VersionClient.java  | 26 ++++++++++++++--------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/sling/cli/impl/jira/VersionClient.java b/src/main/java/org/apache/sling/cli/impl/jira/VersionClient.java
index 642761b..b62599e 100644
--- a/src/main/java/org/apache/sling/cli/impl/jira/VersionClient.java
+++ b/src/main/java/org/apache/sling/cli/impl/jira/VersionClient.java
@@ -30,6 +30,7 @@ import java.util.function.Predicate;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
 import org.apache.http.client.utils.URIBuilder;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
@@ -164,6 +165,13 @@ public class VersionClient {
         return post;
     }
     
+    private HttpPut newPut(String suffix) {
+        HttpPut put = new HttpPut(jiraUrlPrefix + suffix);
+        put.addHeader("Content-Type", CONTENT_TYPE_JSON);
+        put.addHeader("Accept", CONTENT_TYPE_JSON);
+        return put;
+    }
+    
     public List<Issue> findUnresolvedIssues(Release release) throws IOException {
         
         try {
@@ -332,17 +340,18 @@ public class VersionClient {
             IssueUpdate update = new IssueUpdate();
             update.recordAdd("fixVersions", newVersion.getName());
             update.recordRemove("fixVersions", oldVersion.getName());
+            Gson gson = new Gson();
+            gson.toJson(update, w);
             
-            HttpPost post = newPost("issue/" + issue.getKey());
-            post.setEntity(new StringEntity(w.toString(), StandardCharsets.UTF_8));
+            HttpPut put = newPut("issue/" + issue.getKey());
+            put.setEntity(new StringEntity(w.toString(), StandardCharsets.UTF_8));
 
             try (CloseableHttpClient client = httpClientFactory.newClient()) {
-                try (CloseableHttpResponse response = client.execute(post)) {
-                    try (InputStream content = response.getEntity().getContent();
-                            InputStreamReader reader = new InputStreamReader(content)) {
-                        
-                        if (response.getStatusLine().getStatusCode() != 204) {
-                            throw newException(response, reader);
+                try (CloseableHttpResponse response = client.execute(put, httpClientFactory.newPreemptiveAuthenticationContext())) {
+                    if (response.getStatusLine().getStatusCode() != 204) {
+                        try (InputStream content = response.getEntity().getContent();
+                                InputStreamReader reader = new InputStreamReader(content)) {
+                                throw newException(response, reader);
                         }
                     }
                 }
@@ -350,6 +359,5 @@ public class VersionClient {
         } catch (IOException e) {
             throw new RuntimeException(e);
         }
-        // '{"update":{"fixVersions":[{"add":{"name":"6.5 L19"}},{"remove":{"name":"6.5 L17"}}]}}'
     }
 }


[sling-org-apache-sling-committer-cli] 02/02: Add a commented-out HTTP debug config.

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-committer-cli.git

commit 3dfa95d6880407ec9f1138b720952e31767baba0
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Mon Aug 26 18:34:32 2019 +0200

    Add a commented-out HTTP debug config.
---
 src/main/resources/conf/logback-default.xml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/main/resources/conf/logback-default.xml b/src/main/resources/conf/logback-default.xml
index 8f2963f..d726870 100644
--- a/src/main/resources/conf/logback-default.xml
+++ b/src/main/resources/conf/logback-default.xml
@@ -16,6 +16,9 @@
     </appender>
 
     <logger name="org.apache.sling.cli" level="INFO" />
+    <!--
+    <logger name="org.apache.http" level="DEBUG" />
+     -->
 
     <root level="WARN">
         <appender-ref ref="STDOUT" />