public AtlasImportResult importData(AtlasImportRequest request, InputStream stream) throws AtlasServiceException { return performImportData(getImportRequestBodyPart(request), new StreamDataBodyPart(IMPORT_DATA_PARAMETER, stream)); }
/** * upload from the given inputstream * * @param fileToUpload * @param filename * @param contents * @param comment * @throws Exception */ public synchronized void upload(InputStream fileToUpload, String filename, String contents, String comment) throws Exception { TokenResult token = getEditToken("File:" + filename, "edit"); final FormDataMultiPart multiPart = new FormDataMultiPart(); // http://stackoverflow.com/questions/5772225/trying-to-upload-a-file-to-a-jax-rs-jersey-server multiPart.bodyPart(new StreamDataBodyPart("file", fileToUpload)); multiPart.field("filename", filename); multiPart.field("ignorewarnings", "true"); multiPart.field("text", contents); if (!comment.isEmpty()) multiPart.field("comment", comment); String params = ""; Api api = this.getActionResult("upload", params, token, multiPart); handleError(api); }
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException { if (archive == null) { throw new IllegalArgumentException("archive must not be null"); } final String archiveName = archive.getName(); final ProtocolMetaData protocolMetaData = new ProtocolMetaData(); try { InputStream deployment = archive.as(ZipExporter.class).exportAsInputStream(); // Build up the POST form to send to Glassfish final FormDataMultiPart form = new FormDataMultiPart(); form.bodyPart(new StreamDataBodyPart("id", deployment, archiveName)); deploymentName = createDeploymentName(archiveName); addDeployFormFields(deploymentName, form); // Do Deploy the application on the remote GlassFish HTTPContext httpContext = glassFishClient.doDeploy(deploymentName, form); protocolMetaData.addContext(httpContext); } catch (GlassFishClientException e) { throw new DeploymentException("Could not deploy " + archiveName, e); } return protocolMetaData; }