use of org.eclipse.egit.github.core.GistFile in project jbpm-work-items by kiegroup.
the class CreateGistWorkitemHandler method executeWorkItem.
public void executeWorkItem(WorkItem workItem, WorkItemManager workItemManager) {
try {
Document content = (Document) workItem.getParameter("Content");
String description = (String) workItem.getParameter("Description");
String isPublicStr = (String) workItem.getParameter("IsPublic");
if (content != null) {
Map<String, Object> results = new HashMap<String, Object>();
GistService gistService = auth.getGistService(this.userName, this.password);
Gist gist = new Gist();
gist.setPublic(Boolean.parseBoolean(isPublicStr));
gist.setDescription(description);
GistFile file = new GistFile();
file.setContent(new String(content.getContent(), StandardCharsets.UTF_8));
file.setFilename(content.getName());
gist.setFiles(Collections.singletonMap(file.getFilename(), file));
gist = gistService.createGist(gist);
results.put(RESULTS_VALUE, gist.getHtmlUrl());
workItemManager.completeWorkItem(workItem.getId(), results);
} else {
logger.error("Missing gist content information.");
throw new IllegalArgumentException("Missing gist content information.");
}
} catch (Exception e) {
handleException(e);
}
}
Aggregations