Package sample.util

Examples of sample.util.SimpleCommandLineParser


    this.feedName = feedName;
  }

  public void execute(GttService service, String[] args)
      throws IOException, ServiceException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    String entryId = parser.getValue("id");

    if (parser.containsKey("list")) {
      URL feedUrl = FeedUris.getAclFeedUrl(feedName, entryId);

      System.out.println("Listing all accessors for " + feedName
          + " with id" + entryId + "  ...");
      // Get the list of accessors for this entry
      AclFeed aclFeed = service.getFeed(feedUrl, AclFeed.class);
      printAclInfo(aclFeed);

    } else if (parser.containsKey("changetype")) {
      String changeType = parser.getValue("changetype");
      String emailId = parser.getValue("email");

      if ("add".equals(changeType)) {
        AclScope scope = new AclScope(AclScope.Type.USER, emailId);
        AclRole role = new AclRole(parser.getValue("role"));

        // Add a new accessor for this entry
        AclEntry entry = new AclEntry();
        entry.setRole(role);
        entry.setScope(scope);

        System.out.println("Adding user " + emailId + " as " + role.getValue()
            + " to " + feedName + " with id " + entryId + " ...");
        URL feedUrl = FeedUris.getAclFeedUrl(feedName, entryId);
        service.insert(feedUrl, entry);
        System.out.println("...done");

      } else if ("change".equals(changeType)) {
        AclScope scope = new AclScope(AclScope.Type.USER, emailId);
        AclRole role = new AclRole(parser.getValue("role"));

        // Change the role of an accessor for this entry
        AclEntry entry = new AclEntry();
        entry.setRole(role);
        entry.setScope(scope);
View Full Code Here


    printResults(resultEntry);
  }

  private TranslationMemoryEntry createEntryFromArgs(String[] args)
      throws IOException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    System.out.println("You asked to add translation memory...");

    TranslationMemoryEntry entry = new TranslationMemoryEntry();

    String title = parser.getValue("title");
    System.out.println("...with title " + title);
    entry.setTitle(new PlainTextConstruct(title));

    if (parser.containsKey("file")) {
      String filename = parser.getValue("file");
      System.out.println("...with contents from " + filename);
      File file = new File(filename);
      String mimeType = "text/xml";

      MediaFileSource fileSource = new MediaFileSource(file, mimeType);
      MediaContent content = new MediaContent();
      content.setMediaSource(fileSource);
      content.setMimeType(new ContentType(mimeType));

      entry.setContent(content);
    }

    if (parser.containsKey("private")) {
      System.out.println("...with private access");
      entry.setScope(new ScopeEntry(ScopeEntry.Value.PRIVATE));
    } else {
      System.out.println("...with public access");
      entry.setScope(new ScopeEntry(ScopeEntry.Value.PUBLIC));
View Full Code Here

  private DeleteGlossaryCommand() {
  }

  public void execute(GttService service, String[] args)
      throws IOException, ServiceException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    String id = parser.getValue("id");
    URL feedUrl = FeedUris.getGlossaryFeedUrl(id);

    System.out.print("Deleting glossary with id: " + id + " ....");
    System.out.flush();
View Full Code Here

    printResults(resultFeed);
  }

  private TranslationMemoryQuery createQueryFromArgs(String[] args)
      throws IOException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    URL feedUrl = FeedUris.getTranslationMemoriesFeedUrl();
    TranslationMemoryQuery query = new TranslationMemoryQuery(feedUrl);

    if (parser.containsKey("onlyprivate")) {
      System.out.println("You asked to list all private translation "
          + "memories...");
      query.setScope(ScopeEntry.Value.PRIVATE.toString());
    } else if (parser.containsKey("onlypublic")) {
      System.out.println("You asked to list all public translation "
          + "memories...");
      query.setScope(ScopeEntry.Value.PUBLIC.toString());
    } else {
      System.out.println("You asked to list all translation "
View Full Code Here

  private DeleteTranslationMemoryCommand() {
  }

  public void execute(GttService service, String[] args)
      throws IOException, ServiceException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    String id = parser.getValue("id");
    URL feedUrl = FeedUris.getTranslationMemoryFeedUrl(id);

    System.out.print("Deleting translation memory with id: " + id + " ....");
    System.out.flush();
View Full Code Here

    printResults(resultEntry);
  }

  private GlossaryEntry createEntryFromArgs(String[] args)
      throws IOException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    System.out.println("You asked to add a glossary...");

    GlossaryEntry entry = new GlossaryEntry();

    String title = parser.getValue("title");
    System.out.println("...with title " + title);
    entry.setTitle(new PlainTextConstruct(title));

    String filename = parser.getValue("file");
    System.out.println("...with contents from " + filename);
    File file = new File(filename);
    String mimeType = "text/csv";
    MediaFileSource fileSource = new MediaFileSource(file, mimeType);
    MediaContent content = new MediaContent();
View Full Code Here

TOP

Related Classes of sample.util.SimpleCommandLineParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.