Execute the requested operation. @exception BuildException if an error occurs
()
| 171 | * @exception BuildException if an error occurs |
| 172 | */ |
| 173 | @Override |
| 174 | public void execute() throws BuildException { |
| 175 | super.execute(); |
| 176 | if (path == null) { |
| 177 | throw new BuildException("Must specify 'path' attribute"); |
| 178 | } |
| 179 | if ((war == null) && (localWar == null) && (config == null) && (tag == null)) { |
| 180 | throw new BuildException("Must specify either 'war', 'localWar', 'config', or 'tag' attribute"); |
| 181 | } |
| 182 | // Building an input stream on the WAR to upload, if any |
| 183 | BufferedInputStream stream = null; |
| 184 | String contentType = null; |
| 185 | long contentLength = -1; |
| 186 | if (war != null) { |
| 187 | if (PROTOCOL_PATTERN.matcher(war).lookingAt()) { |
| 188 | try { |
| 189 | URI uri = new URI(war); |
| 190 | URLConnection conn = uri.toURL().openConnection(); |
| 191 | contentLength = conn.getContentLengthLong(); |
| 192 | stream = new BufferedInputStream(conn.getInputStream(), 1024); |
| 193 | } catch (IOException | URISyntaxException e) { |
| 194 | throw new BuildException(e); |
| 195 | } |
| 196 | } else { |
| 197 | FileInputStream fsInput = null; |
| 198 | try { |
| 199 | fsInput = new FileInputStream(war); |
| 200 | FileChannel fsChannel = fsInput.getChannel(); |
| 201 | contentLength = fsChannel.size(); |
| 202 | stream = new BufferedInputStream(fsInput, 1024); |
| 203 | } catch (IOException ioe) { |
| 204 | if (fsInput != null) { |
| 205 | try { |
| 206 | fsInput.close(); |
| 207 | } catch (IOException ignore) { |
| 208 | // Ignore |
| 209 | } |
| 210 | } |
| 211 | throw new BuildException(ioe); |
| 212 | } |
| 213 | } |
| 214 | contentType = "application/octet-stream"; |
| 215 | } |
| 216 | // Building URL |
| 217 | StringBuilder sb = createQueryString("/deploy"); |
| 218 | try { |
| 219 | if ((war == null) && (config != null)) { |
| 220 | sb.append("&config="); |
| 221 | sb.append(URLEncoder.encode(config, getCharset())); |
| 222 | } |
| 223 | if ((war == null) && (localWar != null)) { |
| 224 | sb.append("&war="); |
| 225 | sb.append(URLEncoder.encode(localWar, getCharset())); |
| 226 | } |
| 227 | if (update) { |
| 228 | sb.append("&update=true"); |
| 229 | } |
| 230 | if (tag != null) { |
nothing calls this directly
no test coverage detected