Package org.apache.wookie.beans

Examples of org.apache.wookie.beans.IWidget$Utilities


    if (localized == null) {

      //
      // Get the Widget this resource request is related to
      //
      IWidget widget = getWidgetFromRequest(request);

      //
      // Only if we have a valid instance and a resource which has no
      // localization parameter do we start the locale algorithm
      //
View Full Code Here


  protected void update(String resourceId, HttpServletRequest request, HttpServletResponse response)
      throws ResourceNotFoundException, InvalidParametersException,
      UnauthorizedAccessException {
      // attempt to get specific widget by id
      IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
      IWidget widget = persistenceManager.findById(IWidget.class, resourceId);
      if (widget == null) throw new ResourceNotFoundException();
      // FIXME localize error messages
      try {
        W3CWidgetFactory factory  = getFactory(request.getSession().getServletContext());
        installUpdate(factory, widget, false);
View Full Code Here

    if(widgetInstance==null) return map;
   
    // Get i18n-enabled metadata for the Widget's locale and encode it using unicode control characters.
   
    String locales[] = {widgetInstance.getLang()};
    IWidget widget = widgetInstance.getWidget();
     
    String author = "";
        String email = "";
        String href = "";
    if (widget.getAuthor() != null){
            if (widget.getAuthor().getAuthor() != null) author = WidgetFormattingUtils.getEncoded(widget.getAuthor().getDir(), widget.getAuthor().getAuthor());
          if (widget.getAuthor().getEmail() != null) email = widget.getAuthor().getEmail();
          if (widget.getAuthor().getHref() != null) href = widget.getAuthor().getHref();
    }

    String name = "";
    IName iname = (IName)LocalizationUtils.getLocalizedElement(widget.getNames().toArray(new IName[widget.getNames().size()]), locales, widget.getDefaultLocale());
    if (iname != null && iname.getName() != null) name = WidgetFormattingUtils.getEncoded(iname.getDir(), iname.getName());
    String shortName = "";
    if (iname != null && iname.getShortName() != null) shortName = WidgetFormattingUtils.getEncoded(iname.getDir(), iname.getShortName());
   
    String description = "";
    IDescription idescription = (IDescription)LocalizationUtils.getLocalizedElement(widget.getDescriptions().toArray(new IDescription[widget.getDescriptions().size()]), locales, widget.getDefaultLocale());
    if (idescription != null && idescription.getContent() != null) description = WidgetFormattingUtils.getEncoded(idescription.getDir(), idescription.getContent());
   
    String version = "";
    if (widget.getVersion() != null) version = WidgetFormattingUtils.getEncoded(widget.getDir(), widget.getVersion());
   
    String width = "0";
    if (widget.getWidth() != null) width = String.valueOf(widget.getWidth());
   
    String height = "0";
    if (widget.getHeight() != null) height = String.valueOf(widget.getHeight());
   
    // Add in metadata

    map.put("id", String.valueOf(widget.getGuid()))//$NON-NLS-1$
    map.put("author", author)//$NON-NLS-1$
    map.put("authorEmail", email);//$NON-NLS-1$
    map.put("authorHref", href);//$NON-NLS-1$
    map.put("name", name);//$NON-NLS-1$
    map.put("description", description);//$NON-NLS-1$ 
View Full Code Here

   * @param grantAccessRequests whether to grant access requests created for the widget
   * @return the widget
   */
  public static IWidget addNewWidget(W3CWidget model, String[] widgetTypes, boolean grantAccessRequests) {
      IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidget widget = createWidget(persistenceManager, model);
    createTypes(persistenceManager, widgetTypes, widget);
    createStartFiles(persistenceManager, model,widget);
    createNames(persistenceManager, model,widget);
    createDescriptions(persistenceManager, model,widget);
    createIcons(persistenceManager, model, widget);
View Full Code Here

    createAccessRequests(persistenceManager, model, widget, grantAccessRequests);
    return widget;        
  }

  private static IWidget createWidget(IPersistenceManager persistenceManager, W3CWidget model){
    IWidget widget;
    widget = persistenceManager.newInstance(IWidget.class);   
    if (model.getAuthor() != null){
      widget.setWidgetAuthor(model.getAuthor().getAuthorName());
      widget.setWidgetAuthorEmail(model.getAuthor().getEmail());
      widget.setWidgetAuthorHref(model.getAuthor().getHref());
    }
    widget.setGuid(model.getIdentifier());
    widget.setHeight(model.getHeight());
    widget.setWidth(model.getWidth());
    widget.setVersion(model.getVersion());
    return widget;
  }
View Full Code Here

   * @param id the id of the widget
   * @return true if the widget is destroyed successfully
   */
  public static boolean destroy(Object id){
      IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidget widget = persistenceManager.findById(IWidget.class, id);
    return destroy(widget);
  }
View Full Code Here

        if ((apiKey != null) && (userId != null) && (sharedDataKey != null) && (widgetGuid != null))
        {
            try
            {
                // find widget by GUID
                IWidget widget = findWidgetByGuid(widgetGuid);
                if (widget != null)
                {
                    // get matching widget instance for widget
                    Map<String, Object> values = new HashMap<String, Object>();
                    values.put("apiKey", apiKey);
View Full Code Here

   * @param urlWidgetProxyServer the local URL of the proxy service
   * @return
   */
  public static String createXMLWidgetInstanceDocument(IWidgetInstance instance, String url){
    String xml = XMLDECLARATION;
    IWidget widget = instance.getWidget();
   
    // Return a default width and height where the original value is either not provided
    // or of an invalid range (<0)
    String width = String.valueOf(IW3CXMLConfiguration.DEFAULT_WIDTH_LARGE);
    String height = String.valueOf(IW3CXMLConfiguration.DEFAULT_HEIGHT_LARGE);
    if (widget.getWidth()!=null && widget.getWidth()>0) width = widget.getWidth().toString();
    if (widget.getHeight()!=null && widget.getHeight()>0) height = widget.getHeight().toString();
       
    xml += "<widgetdata>"; //$NON-NLS-1$
    xml += "\t<url>"+url+"</url>"; //$NON-NLS-1$ //$NON-NLS-2$
    xml += "\t<identifier>"+instance.getIdKey()+"</identifier>\n"; //$NON-NLS-1$ //$NON-NLS-2$
    xml += "\t<title>"+widget.getWidgetTitle()+"</title>\n"; //$NON-NLS-1$ //$NON-NLS-2$
    xml += "\t<height>"+height+"</height>\n"; //$NON-NLS-1$ //$NON-NLS-2$
    xml += "\t<width>"+width+"</width>\n"; //$NON-NLS-1$ //$NON-NLS-2$
    xml += "</widgetdata>"; //$NON-NLS-1$
   
    return xml;
View Full Code Here

      index(resourceId, request, response);
      return;
    }
    // attempt to get specific widget by id
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidget widget = persistenceManager.findById(IWidget.class, resourceId);
    // support queries by type
    if (widget == null) {
      IWidgetService[] services = persistenceManager.findByValue(IWidgetService.class, "serviceName", resourceId);
        if (services != null && services.length == 1) {
          IWidget[] widgets = persistenceManager.findWidgetsByType(resourceId);
View Full Code Here

   * @throws ServletException
   * @throws IOException
   */
  private void index(String resourceId, HttpServletRequest request,
      HttpServletResponse response) throws IOException {
    IWidget widget = null;
    IWidget[] widgets;
   
    // If the request has the parameter ?all, return all widgets.
    // If the request contains a String resource identifier
    // such as "/chat", return all matching widgets
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    if (request.getParameter("all") != null
        || (resourceId != null && !resourceId.equals(""))) {
      if (resourceId != null && !resourceId.equals("")) {
        widgets = persistenceManager.findWidgetsByType(resourceId);
      } else {
        widgets = persistenceManager.findAll(IWidget.class);
      }
      // Otherwise, return default widgets for the defined services. In
      // future we may want
      // to move this into the Services controller.
    } else {
      ArrayList<IWidget> widgetsarr = new ArrayList<IWidget>();
      for (IWidgetDefault widgetDefault : persistenceManager.findAll(IWidgetDefault.class)) {
        widget = widgetDefault.getWidget();
        if (!widget.getGuid().equals("http://notsupported")) {
          widgetsarr.add(widget);
        }
      }
      widgets = (IWidget[])widgetsarr.toArray(new IWidget[widgetsarr.size()]);
    }
View Full Code Here

TOP

Related Classes of org.apache.wookie.beans.IWidget$Utilities

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.