Package com.antonytrupe.shared

Examples of com.antonytrupe.shared.Page


  }

  @Override
  public void save() {
    // do the save
    Page p = new Page(this.pageName, getContent(), getUpdate());
    this.pageService.save(p, new AsyncCallback<Void>() {

      @Override
      public void onFailure(Throwable caught) {
      }
View Full Code Here


    try {
      cache = CacheManager.getInstance().getCacheFactory()
          .createCache(Collections.emptyMap());
      // Get the value from the cache.
      Page value = (Page) cache.get(name);
      if (value != null) {
        return value;
      }
    } catch (CacheException e) {
      // ...
    }

    DatastoreService datastore = DatastoreServiceFactory
        .getDatastoreService();
    Page page = new Page(name);
    try {
      Entity e = datastore.get(KeyFactory.createKey(
          Page.class.getSimpleName(), name));
      page = new Page(e.getKey().getName(),
          ((Text) e.getProperty(Page.CONTENT)).getValue());
      // Text style = (Text) e.getProperty(Page.STYLE);
      // if (style != null) {
      // page.setStyle(style.getValue());
      // }
      Text diff = (Text) e.getProperty(Page.DIFF);
      if (diff != null) {
        page.setDiff(diff.getValue());
      }

    } catch (EntityNotFoundException e) {
      // e.printStackTrace();
    }
View Full Code Here

          .getValue();
      // String style = ((Text)
      // result.getProperty(Page.STYLE)).getValue();
      Date date = (Date) result.getProperty(Page.DATE);
      String ipaddress = (String) result.getProperty(Page.REMOTE_IP);
      Page e = new Page(name, content, date, ipaddress);
      e.setUser((String) result.getProperty(Page.USER));
      Text diff = (Text) result.getProperty(Page.DIFF);
      if (diff != null) {
        e.setDiff(diff.getValue());
      }
      pages.add(e);
    }
    return pages;
  }
View Full Code Here

    AsyncDatastoreService datastore = DatastoreServiceFactory
        .getAsyncDatastoreService();

    // start the query to get the original page
    Page oldPage = new Page();
    Future<Entity> oldPageFuture;
    {
      oldPageFuture = datastore.get(KeyFactory.createKey(
          Page.class.getSimpleName(), p.getName()));

    }

    try {
      Date now = new Date();
      // create the page entity
      {
        Entity page = new Entity(KeyFactory.createKey(Page.PAGE,
            URLDecoder.decode(p.getName(), "UTF-8")));

        // ... set properties ...
        page.setProperty(Page.CONTENT, new Text(p.getContent()));
        // page.setProperty(Page.STYLE, new Text(p.getStyle()));
        page.setProperty(Page.REMOTE_IP, getThreadLocalRequest()
            .getRemoteAddr());
        page.setProperty(Page.DATE, now);
        page.setProperty(Page.USER, identity);

        try {
          // block on retrieving previous version
          Entity e = oldPageFuture.get();
          oldPage = new Page(e.getKey().getName(),
              ((Text) e.getProperty(Page.CONTENT)).getValue());
        } catch (InterruptedException e) {
          e.printStackTrace();
        } catch (ExecutionException e) {
          e.printStackTrace();
        }
        datastore.put(page);
      }
      // create the pagehistory entity
      {
        Entity history = new Entity(
            KeyFactory.createKey(
                Page.PAGEHISTORY,
                URLDecoder.decode(p.getName(), "UTF-8")
                    + now.getTime()));

        // ... set properties ...
        history.setProperty(Page.NAME,
            URLDecoder.decode(p.getName(), "UTF-8"));
        history.setProperty(Page.CONTENT, new Text(p.getContent()));
        // history.setProperty(Page.STYLE, new Text(p.getStyle()));
        history.setProperty(Page.REMOTE_IP, getThreadLocalRequest()
            .getRemoteAddr());
        history.setProperty(Page.DATE, now);
        history.setProperty(Page.UPDATE, p.isUpdate());
        history.setProperty(Page.USER, identity);

        // create the diff
        diff_match_patch dmp = new diff_match_patch();
        // create the diff
        LinkedList<Diff> diffs = dmp.diff_main(oldPage.getContent(),
            p.getContent());
        // make the diff human readable
        dmp.diff_cleanupSemantic(diffs);
        // convert the diff to html
        String diff = dmp.diff_prettyHtml(diffs);
View Full Code Here

TOP

Related Classes of com.antonytrupe.shared.Page

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.