private UpdateDocumentCommand() {
}
public void execute(GttService service, String[] args)
throws IOException, ServiceException {
SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
String id = parser.getValue("id");
URL feedUrl = FeedUris.getDocumentFeedUrl(id);
DocumentEntry requestEntry = service.getEntry(feedUrl, DocumentEntry.class);
requestEntry.setLastModifiedBy(null);
System.out.println("You want to update document 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("tmids")) {
String tmIds = parser.getValue("tmids");
System.out.println("...by adding translation memories with ids: "
+ tmIds);
TmsElement tm = new TmsElement();
for (String tmId : tmIds.split(",")) {
String tmHref = FeedUris.getTranslationMemoryFeedUrl(tmId).toString();
Link tmLink = new Link();
tmLink.setHref(tmHref);
tm.addLink(tmLink);
}
requestEntry.setTranslationMemory(tm);
}
if (parser.containsKey("glids")) {
String glIds = parser.getValue("glids");
System.out.println("...by adding glossaries with ids: "
+ glIds);
GlossariesElement gl = new GlossariesElement();
for (String glId : glIds.split(",")) {
String glHref = FeedUris.getGlossaryFeedUrl(glId).toString();