@triggeredBy({DEFINED_BY, MIRRORED_BY, SERVICED_BY})
  public void definitionChanged() throws Exception {
    ObjectConnection active = getObjectConnection();
    final Logger logger = LoggerFactory.getLogger(DomainSupport.class);
    final ObjectRepository repository = active.getRepository();
    final Resource resource = getResource();
    executor.schedule(
        new Runnable() {
          public String toString() {
            return "refresh " + resource;
          }

          public void run() {
            try {
              logger.info("Refreshing {}", resource);
              ObjectConnection con = repository.getConnection();
              try {
                Domain domain = con.getObject(Domain.class, resource);
                domain.refreshGraphs();
              } finally {
                con.close();
              }
            } catch (Exception e) {
              logger.warn("Could not refresh " + resource, e);
              executor.schedule(this, 5, TimeUnit.MINUTES);
            }
          }
        },
        30,
        TimeUnit.SECONDS);
  }
 public void refreshGraphs() throws Exception {
   Object graph = getPurlDefinedBy();
   if (graph != null && !(graph instanceof RemoteGraph)) {
     ObjectConnection con = getObjectConnection();
     RemoteGraph rg = con.addDesignation(graph, RemoteGraph.class);
     rg.load(getResource().stringValue());
   }
 }
示例#3
0
 public void testBadRollback() throws Exception {
   try {
     client.path("/").queryParam("bad", "").post(String.class, "input");
     fail();
   } catch (UniformInterfaceException e) {
     assertEquals(400, e.getResponse().getStatus());
   }
   ObjectConnection con = repository.getConnection();
   try {
     Brake brake = (Brake) con.getObject(client.path("/").toString());
     assertNull(brake.getInvalid());
   } finally {
     con.close();
   }
 }
示例#4
0
  @Test
  public void testMotivationBookmarking() throws Exception {
    // Create test annotation
    Annotation annotation = new Annotation();

    // Create and add motivation
    Motivation motivation = new Bookmarking();
    annotation.setMotivatedBy(motivation);

    // Persist annotation
    connection.addObject(annotation);

    // Query persisted object
    List<Bookmarking> result = connection.getObjects(Bookmarking.class).asList();

    // Tests
    assertEquals(1, result.size());

    assertEquals(motivation.getResource().toString(), result.get(0).getResource().toString());
  }
示例#5
0
 @After
 public void tearDown() throws Exception {
   connection.close();
 }