Package org.apache.wookie.beans

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


                IPersistenceManager persistenceManager = getPersistenceManager();
                persistenceManager.begin();

                // Widget
                boolean initializing = true;
                IWidget widget = persistenceManager.findWidgetByGuid("http://notsupported");
                if (widget == null)
                {
                    // required: always create if not found
                    widget = persistenceManager.newInstance(IWidget.class);
                    widget.setHeight(350);
                    widget.setWidth(500);
                    widget.setIdentifier("http://notsupported");
                   
                    IAuthor author = persistenceManager.newInstance(IAuthor.class);
                    author.setAuthorName("Paul Sharples");
                    author.setEmail("p.sharples@bolton.ac.uk");
                    author.setHref("http://iec.bolton.ac.uk");
                    widget.setAuthor(author);
                    widget.setVersion("v1.0");
                    IName widgetName = persistenceManager.newInstance(IName.class);
                    widgetName.setName("Unsupported widget widget");
                    widgetName.setShort("Unsupported");
                    widget.getNames().add(widgetName);
                    IDescription widgetDescription = persistenceManager.newInstance(IDescription.class);
                    widgetDescription.setDescription("This widget is a placeholder for when no corresponding widget is found for a given type");
                    widget.getDescriptions().add(widgetDescription);
                    IContent widgetStartFile = persistenceManager.newInstance(IContent.class);
                    widgetStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/index.htm");
                    widget.getContentList().add(widgetStartFile);
                    IContent widgetBUStartFile = persistenceManager.newInstance(IContent.class);
                    widgetBUStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/locales/bu/index.htm");
                    widgetBUStartFile.setLang("bu");
                    widget.getContentList().add(widgetBUStartFile);
                    IContent widgetFRStartFile = persistenceManager.newInstance(IContent.class);
                    widgetFRStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/locales/fr/index.htm");
                    widgetFRStartFile.setLang("fr");
                    widget.getContentList().add(widgetFRStartFile);
                    IContent widgetENStartFile = persistenceManager.newInstance(IContent.class);
                    widgetENStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/locales/en/index.htm");
                    widgetENStartFile.setLang("en");
                    widget.getContentList().add(widgetENStartFile);
                    IIcon widgetIcon = persistenceManager.newInstance(IIcon.class);
                    widgetIcon.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/shared/images/defaultwidget.png");
                    widgetIcon.setHeight(80);
                    widgetIcon.setWidth(80);
                    widgetIcon.setLang("en");
                    widget.getIcons().add(widgetIcon);
                    persistenceManager.save(widget);
                }
                else
                {
                    initializing = false;
View Full Code Here


  protected void update(String resourceId, HttpServletRequest request, HttpServletResponse response)
      throws ResourceNotFoundException, InvalidParametersException,
      UnauthorizedAccessException {
   
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidget widget = persistenceManager.findWidgetByGuid(resourceId);
    // attempt to get specific widget by id
    if (widget == null) {
      persistenceManager = PersistenceManagerFactory.getPersistenceManager();
      widget = persistenceManager.findById(IWidget.class, resourceId);
    }
View Full Code Here

      HttpServletResponse response) throws ResourceNotFoundException,
      IOException {

    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    // attempt to get specific widget by URI
    IWidget widget = persistenceManager.findWidgetByGuid(resourceId);
    // attempt to get specific widget by id
    if (widget == null) {
      persistenceManager = PersistenceManagerFactory.getPersistenceManager();
      widget = persistenceManager.findById(IWidget.class, resourceId);
    }
View Full Code Here

   
    //
    // Identify the widget to delete
    //
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidget widget = persistenceManager.findWidgetByGuid(resourceId);
    // attempt to get specific widget by id
    if (widget == null) {
      persistenceManager = PersistenceManagerFactory.getPersistenceManager();
      widget = persistenceManager.findById(IWidget.class, resourceId);
    }
View Full Code Here

    String cloneSharedDataKey = request.getParameter("cloneshareddatakey");
    if (sharedDataKey == null || sharedDataKey.trim().equals("") || cloneSharedDataKey == null || cloneSharedDataKey.trim().equals("")){//$NON-NLS-1$ //$NON-NLS-2$
      throw new InvalidParametersException();
    }
    String cloneKey = SharedDataHelper.getInternalSharedDataKey(instance, cloneSharedDataKey);
        IWidget widget = instance.getWidget();
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    for (ISharedData sharedData : new SharedContext(instance).getSharedData())
    {
        ISharedData clone = persistenceManager.newInstance(ISharedData.class);
            clone.setDkey(sharedData.getDkey());
View Full Code Here

   * @param locale the locale of the widget instance
   * @return an XML representation of the Widget Instance as a String
   */
  public static String createXMLWidgetInstanceDocument(IWidgetInstance instance, String url, String locale){
    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>"+StringEscapeUtils.escapeXml(widget.getLocalName(locale))+"</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

   
    return xml;
  }
 
  public static String toJson(IWidgetInstance instance, String url, String locale) {
    IWidget widget = instance.getWidget();
    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();
    JSONObject json = new JSONObject();
    try {
      json.put("url", url);
      json.put("identifier", instance.getIdKey());
      json.put("title", widget.getLocalName(locale));
      json.put("height", height);
      json.put("width", width);
    } catch (JSONException e) {
      logger.error("Problem rendering instance using JSON",e);
    }
View Full Code Here

      HttpServletResponse response) throws ResourceNotFoundException,
      UnauthorizedAccessException, IOException {
    // attempt to get specific widget by id; note that this is the internal
    // widget integer ID and not the widget URI
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidget widget = persistenceManager.findById(IWidget.class, resourceId);
    if (widget == null) throw new ResourceNotFoundException();
    // redirect to the UDD
    if (widget.getUpdateLocation() ==  null) throw new ResourceNotFoundException();
    response.sendRedirect(widget.getUpdateLocation());
  }
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 (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

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.