/plugin-module-codegen-engine/src/main/resources/templates/stash/ssh/SshScmRequest.java.vtl
https://bitbucket.org/mmeinhold/amps · Unknown · 50 lines · 40 code · 10 blank · 0 comment · 0 complexity · f50e6d629706a09b0ec8df0d6f1df158 MD5 · raw file
- package ${PACKAGE};
- import com.atlassian.stash.scm.ssh.AbstractSshRequest;
- import com.atlassian.stash.scm.ssh.ExitCodeCallback;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
- public class ${REQUEST_CLASSNAME} extends AbstractSshRequest
- {
- private static final Logger log = LoggerFactory.getLogger(${REQUEST_CLASSNAME}.class);
- private static final int BUFFER_SIZE = 1024;
- private final InputStream in;
- private final OutputStream out;
- private final ExitCodeCallback exitCodeCallback;
- public ${REQUEST_CLASSNAME}(InputStream in, OutputStream out, ExitCodeCallback exitCodeCallback)
- {
- this.in = in;
- this.out = out;
- this.exitCodeCallback = exitCodeCallback;
- }
- @Override
- public void handleRequest() throws IOException
- {
- // example code (simply echoing the input stream back to client)
- final byte[] buffer = new byte[BUFFER_SIZE];
- long bytesCopied = 0;
- int n;
- while (-1 != (n = in.read(buffer)))
- {
- out.write(buffer, 0, n);
- out.flush();
- bytesCopied += n;
- }
- log.trace(bytesCopied + " bytes copied");
- // end example code
- // mark the request as successful
- exitCodeCallback.onExit(0);
- }
- }