Created
April 17, 2012 20:14
-
-
Save aruld/2408710 to your computer and use it in GitHub Desktop.
Scheduling Flux workflow using Jersey Java API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.sun.jersey.api.client.Client; | |
| import com.sun.jersey.api.client.ClientResponse; | |
| import com.sun.jersey.api.client.WebResource; | |
| import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; | |
| import com.sun.jersey.api.client.filter.LoggingFilter; | |
| import com.sun.jersey.multipart.FormDataBodyPart; | |
| import com.sun.jersey.multipart.FormDataMultiPart; | |
| import com.sun.jersey.multipart.file.FileDataBodyPart; | |
| import javax.ws.rs.core.MediaType; | |
| import java.io.File; | |
| public class ScheduleFluxWorkflow { | |
| private static final String HTTP_ENDPOINT = "http://localhost:7186/cluster"; | |
| private static final String PUT_WITH_VARIABLES_URI = "flowCharts/putWithVariables"; | |
| public static void main(String[] args) { | |
| Client client = Client.create(); | |
| client.addFilter(new LoggingFilter()); | |
| client.addFilter(new HTTPBasicAuthFilter("admin", "admin")); | |
| WebResource resource = client.resource(HTTP_ENDPOINT); | |
| File file = new File("/Users/arul/flux-7-11-3/project/custom workflow.ffc"); | |
| FormDataMultiPart multipart = new FormDataMultiPart(); | |
| FileDataBodyPart fileDataBodyPart = new FileDataBodyPart("xml", file, MediaType.APPLICATION_XML_TYPE); | |
| multipart.bodyPart(fileDataBodyPart); | |
| FormDataBodyPart bodyPart = new FormDataBodyPart("category", "media clips", MediaType.TEXT_PLAIN_TYPE); | |
| multipart.bodyPart(bodyPart); | |
| ClientResponse response = resource.path(PUT_WITH_VARIABLES_URI).type(MediaType.MULTIPART_FORM_DATA).post(ClientResponse.class, multipart); | |
| String name = response.getEntity(String.class); | |
| System.out.println("Scheduled job via HTTP request = " + name); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment