Esempio n. 1
0
 private static void checkForDefaultInstances(Widget w) {
   for (DefaultInstance di : w.getDefaultInstances()) {
     if (!defaultExists(di)) {
       WidgetInstance.createFromDefault(di);
     }
   }
 }
Esempio n. 2
0
  public static boolean defaultExists(DefaultInstance i) {
    String key = "WidgetManager-default-" + i.generator + "-exists";
    if (Cache.get(key) != null) return true;

    WidgetInstance wi = WidgetInstance.find("byGenerator", i.generator).first();

    if (wi != null) Cache.set(key, true, "1h");

    return (wi != null);
  }
Esempio n. 3
0
 public static List<String> deleteInvalidInstances() {
   List<WidgetInstance> all = WidgetInstance.findAll();
   List<String> deleted = new ArrayList();
   for (WidgetInstance w : all) {
     try {
       w.getWidget();
     } catch (InvalidWidgetException e) {
       deleted.add(w.name + " (" + w.getProvider() + ")");
       Logger.info("Removing instance of invalid widget:" + w.getProvider());
       w.delete();
     }
   }
   return deleted;
 }