Package org.exoplatform.application.gadget

Examples of org.exoplatform.application.gadget.Gadget


     *
     * @return url of gadget application, such as "http://www.google.com/ig/modules/horoscope.xml"
     */
    public String getUrl() {
        if (url_ == null) {
            Gadget gadget = getApplication();
            url_ = GadgetUtil.reproduceUrl(gadget.getUrl(), gadget.isLocal());
        }
        return url_;
    }
View Full Code Here


    public List<Gadget> getAllGadgets(Comparator<Gadget> sortComparator) {
        GadgetRegistry registry = getRegistry();
        List<Gadget> gadgets = new ArrayList<Gadget>();
        for (GadgetDefinition def : registry.getGadgets()) {
            Gadget gadget = loadGadget(def);
            gadgets.add(gadget);
        }
        if (sortComparator != null) {
            Collections.sort(gadgets, sortComparator);
        }
View Full Code Here

                + "/app:resources/" + data.getFileName();
    }

    private Gadget loadGadget(GadgetDefinition def) {
        GadgetData data = def.getData();
        Gadget gadget = new Gadget();

        //
        if (data instanceof LocalGadgetData) {
            try {
                String gadgetName = def.getName();
                LocalGadgetData localData = (LocalGadgetData) data;
                Resource resource = localData.getResources().getFile(localData.getFileName()).getContentResource();
                String content = new String(resource.getData(), resource.getEncoding());
                GadgetSpec gadgetSpec = new GadgetSpec(Uri.parse(getGadgetURL(gadgetName)), content);
                ModulePrefs prefs = gadgetSpec.getModulePrefs();

                String title = prefs.getDirectoryTitle();
                if (title == null || title.trim().length() < 1) {
                    title = prefs.getTitle();
                }
                if (title == null || title.trim().length() < 1) {
                    title = gadgetName;
                }
                gadget.setName(def.getName());
                gadget.setDescription(prefs.getDescription());
                gadget.setLocal(true);
                gadget.setTitle(title);
                gadget.setReferenceUrl(prefs.getTitleUrl().toString());
                gadget.setThumbnail(prefs.getThumbnail().toString());
                gadget.setUrl(getJCRGadgetURL(localData));
            } catch (Exception ex) {
                log.error("Error while loading the content of local gadget " + def.getName(), ex);
            }
        } else {
            RemoteGadgetData remoteData = (RemoteGadgetData) data;
            gadget.setName(def.getName());
            gadget.setDescription(def.getDescription());
            gadget.setLocal(false);
            gadget.setTitle(def.getTitle());
            gadget.setReferenceUrl(def.getReferenceURL());
            gadget.setThumbnail(def.getThumbnail());
            gadget.setUrl(remoteData.getURL());
        }
        //
        return gadget;
    }
View Full Code Here

   {
      GadgetRegistry registry = getRegistry();
      List<Gadget> gadgets = new ArrayList<Gadget>();
      for (GadgetDefinition def : registry.getGadgets())
      {
         Gadget gadget = loadGadget(def);
         gadgets.add(gadget);
      }
      if (sortComparator != null)
      {
         Collections.sort(gadgets, sortComparator);
View Full Code Here

         RemoteGadgetData remoteData = (RemoteGadgetData)data;
         url = remoteData.getURL();
      }

      //
      Gadget gadget = new Gadget();
      gadget.setName(def.getName());
      gadget.setDescription(def.getDescription());
      gadget.setLocal(def.isLocal());
      gadget.setTitle(def.getTitle());
      gadget.setReferenceUrl(def.getReferenceURL());
      gadget.setThumbnail(def.getThumbnail());
      gadget.setUrl(url);
      return gadget;
   }
View Full Code Here

         if (!url.matches(URLValidator.URL_REGEX))
         {
            uiApplication.addMessage(new ApplicationMessage("UIDashboard.msg.notUrl", null));
            return;
         }
         Gadget gadget;
         UIGadget uiGadget;

         //TODO check the way we create the unique ID, is it really unique?
         try
         {
            String name = "gadget" + url.hashCode();
            gadget = GadgetUtil.toGadget(name, url, false);
            service.saveGadget(gadget);
            uiGadget = uiForm.createUIComponent(context, UIGadget.class, null, null);
            uiGadget.setState(new TransientApplicationState<org.exoplatform.portal.pom.spi.gadget.Gadget>(gadget.getName()));
         }
         catch (Exception e)
         {
            try
            {
               URI uri = URI.create(url);
               RSSParser parser = new RSSParser();
               RSSDocument<DefaultRSSChannel, DefaultRSSItem> doc = parser.createDocument(uri, "UTF-8");
               if (doc == null)
                  throw new Exception("Wrong url");
            }
            catch (Exception e1)
            {
               uiApplication.addMessage(new ApplicationMessage("UIDashboard.msg.notUrl", null));
               return;
            }

            String aggregatorId = uiDashboard.getAggregatorId();
            gadget = service.getGadget(aggregatorId);
            //TODO make sure it's an rss feed
            // TODO make sure that we did not add it already
            uiGadget = uiForm.createUIComponent(context, UIGadget.class, null, null);
            uiGadget.setState(new TransientApplicationState<org.exoplatform.portal.pom.spi.gadget.Gadget>(gadget.getName()));

            String params = "{'rssurl':'" + url + "'}";

            // Julien : I commented those 2 lines
            // we need to save the same way it is done in the UIGadget clas
View Full Code Here

            try {
                String gadgetName = urlPref.replaceFirst(LOCAL_STRING, "");
                ExoContainer container = ExoContainerContext.getCurrentContainer();
                GadgetRegistryService gadgetService = (GadgetRegistryService) container
                        .getComponentInstanceOfType(GadgetRegistryService.class);
                Gadget gadget = gadgetService.getGadget(gadgetName);
                if (gadget != null) {
                    url = GadgetUtil.reproduceUrl(gadget.getUrl(), gadget.isLocal());
                } else {
                    if (log.isWarnEnabled()) {
                        log.warn("The local gadget '" + gadgetName + "' was not found, nothing rendered");
                    }
                }
View Full Code Here

TOP

Related Classes of org.exoplatform.application.gadget.Gadget

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.