SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
String id = parser.getValue("id");
URL feedUrl = FeedUris.getGlossaryFeedUrl(id);
GlossaryEntry requestEntry = service.getEntry(feedUrl, GlossaryEntry.class);
System.out.println("You want to update glossary with id:" + id + " ...");
if (parser.containsKey("title")) {
String title = parser.getValue("title");
System.out.println("...by changing title to " + title);
requestEntry.setTitle(new PlainTextConstruct(title));
}
if (parser.containsKey("file")) {
String filename = parser.getValue("file");
System.out.println("...by appending contents from file " + filename);
File file = new File(filename);
String mimeType = "text/csv";
MediaFileSource fileSource = new MediaFileSource(file, mimeType);
MediaContent content = new MediaContent();
content.setMediaSource(fileSource);
content.setMimeType(new ContentType(mimeType));
requestEntry.setContent(content);
}
System.out.print("Updating glossaries....");
System.out.flush();
GlossaryEntry resultEntry = null;
if (requestEntry.getContent() == null) {
resultEntry = service.update(feedUrl, requestEntry);
} else {
resultEntry = service.updateMedia(feedUrl, requestEntry);
}