1. Don Brown
  2. bamboo-continuous-plugin-deployment

Commits

Charles O'Farrell  committed 11e62c7

Extract checking of WebSudo

This is because Bamboo doesn't support this header

  • Participants
  • Parent commits 845903f
  • Branches master

Comments (0)

Files changed (1)

File src/main/java/com/atlassian/bamboo/plugins/confdeploy/UniversalPluginUploader.java

View file
             HttpResponse response = client.execute(webSudoPost);
             buildLogger.addBuildLogEntry(response.getStatusLine().toString());
 
-            Header[] webSudoHeaders = response.getHeaders("X-Atlassian-WebSudo");
-            if (webSudoHeaders == null || webSudoHeaders.length != 1)
-            {
-                final String message = "WebSudo response did not contain the 'X-Atlassian-WebSudo' reponse header.";
-                buildLogger.addErrorLogEntry(message);
-                throw new TaskException(message);
-            }
-            String webSudoHeader = webSudoHeaders[0].getValue();
-            if (!webSudoHeader.equals("Has-Authentication"))
-            {
-                String message = "WebSudo response did not have 'Has-Authentication' header response.";
-                buildLogger.addErrorLogEntry(message);
-                throw new TaskException(message);
-            }
+            checkWebSudo(response);
 
             EntityUtils.consume(response.getEntity());
         }
         }
     }
 
+    private void checkWebSudo(HttpResponse response) throws TaskException
+    {
+        Header[] webSudoHeaders = response.getHeaders("X-Atlassian-WebSudo");
+        if (webSudoHeaders == null || webSudoHeaders.length != 1)
+        {
+            final String message = "WebSudo response did not contain the 'X-Atlassian-WebSudo' reponse header.";
+            buildLogger.addErrorLogEntry(message);
+            throw new TaskException(message);
+        }
+        String webSudoHeader = webSudoHeaders[0].getValue();
+        if (!webSudoHeader.equals("Has-Authentication"))
+        {
+            String message = "WebSudo response did not have 'Has-Authentication' header response.";
+            buildLogger.addErrorLogEntry(message);
+            throw new TaskException(message);
+        }
+    }
+
     private static String getUpmPluginsRestURL(String baseURL)
     {
         final String upmRestRelativeURL = "rest/plugins/1.0/";