Package org.apache.wookie.w3c

Examples of org.apache.wookie.w3c.W3CWidget


    if (download.exists()) download.delete();
    if (output.exists()) output.delete();
    output.mkdir();
    fac.setOutputDirectory(output.getAbsolutePath());
    File widgetFile = WidgetUploader.downloadWidget("http://dev.w3.org/2006/waf/widgets/test-suite/test-cases/ta-RRZxvvTFHx/001/b6.wgt");
    W3CWidget widget = fac.parse(widgetFile);
   
    IName name = widget.getNames().get(0);
    name.setName("Re-Modified Widget");
    WidgetOutputter outputter = new WidgetOutputter();
    outputter.setWidgetFolder("/widgets");
   
    // Save the config.xml
    File widgetFolder = new File(output.getPath()+"/b6");
    File configXml = new File(widgetFolder, "config.xml");
    outputter.outputXML(widget, configXml);
   
    // Pack up the widget
    File zip = File.createTempFile("wookie-output", ".wgt");
    WidgetPackageUtils.repackZip(widgetFolder, zip);
   
    // Reload the widget but using a new path
    fac.setLocalPath("/zaphod.bee.ble/brox");
    widget = fac.parse(zip);
    assertEquals("Re-Modified Widget", widget.getLocalName("en"));
    // Check the content is now pointing to the new location
    assertEquals("/zaphod.bee.ble/brox/b6/index.html", widget.getContentList().get(0).getSrc());
  }
View Full Code Here


    // Check the content is now pointing to the new location
    assertEquals("/zaphod.bee.ble/brox/b6/index.html", widget.getContentList().get(0).getSrc());
  }
  private W3CWidget load(File file) throws BadWidgetZipFileException, BadManifestException, Exception{
    W3CWidgetFactory fac = getFactory();
    W3CWidget widget = fac.parse(file);
    return widget;   
  }
View Full Code Here

  }

  private void registerOperation(HttpServletRequest request, Configuration properties){
    Messages localizedMessages = LocaleHandler.localizeMessages(request);
    try {
      W3CWidget widgetModel = GadgetUtils.createWidget(request);
          IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
      if(persistenceManager.findWidgetByGuid(widgetModel.getIdentifier()) == null){
        WidgetFactory.addNewWidget(widgetModel);
        request.setAttribute("message_value", widgetModel.getLocalName("en")+": "+localizedMessages.getString("WidgetAdminServlet.16")); //$NON-NLS-1$ //$NON-NLS-2$
      } else {
        request.setAttribute("message_value", widgetModel.getLocalName("en")+": "+localizedMessages.getString("WidgetAdminServlet.17")); //$NON-NLS-1$ //$NON-NLS-2$       
      }
    } catch (Exception e1) {
      e1.printStackTrace();
      request.setAttribute("error_value", localizedMessages.getString("WidgetAdminServlet.18")); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here

        fac.setLocales(locales);
        fac.setLocalPath(getServletContext().getContextPath()+properties.getString("widget.widgetfolder"));
        fac.setOutputDirectory(WIDGETFOLDER);
        fac.setFeatures(Features.getFeatureNames());
        fac.setStartPageProcessor(new StartPageProcessor());
        W3CWidget widgetModel = fac.parse(zipFile);
        WidgetJavascriptSyntaxAnalyzer jsa = new WidgetJavascriptSyntaxAnalyzer(fac.getUnzippedWidgetDirectory());       
              if(persistenceManager.findWidgetByGuid(widgetModel.getIdentifier()) == null){
          // ADD
          IWidget widget = WidgetFactory.addNewWidget(widgetModel, null, zipFile, false);
          Object dbkey = widget.getId();
          // widget added
          request.setAttribute("message_value", "'"+ widgetModel.getLocalName("en") +"' - " + localizedMessages.getString("WidgetAdminServlet.19")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$         
          retrieveServices(request);
          request.setAttribute("hasValidated", Boolean.valueOf(true));                                   //$NON-NLS-1$
          request.setAttribute("dbkey", dbkey); //$NON-NLS-1$
       
        else{
          // UPDATE
          // Update the widget metadata and configuration details
          WidgetFactory.update(widgetModel, persistenceManager.findWidgetByGuid(widgetModel.getIdentifier()), false, zipFile);
          request.setAttribute("message_value", "'"+ widgetModel.getLocalName("en") +"' - " + localizedMessages.getString("WidgetAdminServlet.20")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$         
        }
      }
      else{
        // no file found to be uploaded - shouldn't happen
        request.setAttribute("error_value", localizedMessages.getString("WidgetAdminServlet.24")); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

   * @throws BadWidgetZipFileException
   * @throws InvalidContentTypeException
   */
  // FIXME localize messages
  private void installUpdate(W3CWidgetFactory factory, IWidget widget, boolean onlyUseHttps) throws InvalidContentTypeException, BadWidgetZipFileException, BadManifestException, IOException, Exception{
    W3CWidget updatedWidget = UpdateUtils.getUpdate(factory, widget.getGuid(), widget.getUpdateLocation(), widget.getVersion(), onlyUseHttps);
    if (updatedWidget != null){
      WidgetFactory.update(updatedWidget, widget, false, null);
      _logger.info("Successfully updated "+widget.getGuid()+" to version "+updatedWidget.getVersion());
      FlashMessage.getInstance().message("Successfully updated "+widget.getGuid()+" to version "+updatedWidget.getVersion());
    }
  }
View Full Code Here

               fac.setLocales(locales);
               fac.setLocalPath(contextPath+localWidgetFolderPath);
               fac.setOutputDirectory(WIDGETFOLDER);
               fac.setFeatures(Features.getFeatureNames());
               fac.setStartPageProcessor(new StartPageProcessor());
               W3CWidget model = fac.parse(upload);
               WidgetJavascriptSyntaxAnalyzer jsa = new WidgetJavascriptSyntaxAnalyzer(fac.getUnzippedWidgetDirectory());
               if(persistenceManager.findWidgetByGuid(model.getIdentifier()) == null) {
                 WidgetFactory.addNewWidget(model, null, upload, true)
                 String message = model.getLocalName("en") +"' - " + localizedMessages.getString("WidgetAdminServlet.19");
                 _logger.info(message);
                 FlashMessage.getInstance().message(message);
               } else {
                 String message = model.getLocalName("en") +"' - " + localizedMessages.getString("WidgetAdminServlet.20");
                 WidgetFactory.update(model, persistenceManager.findWidgetByGuid(model.getIdentifier()), true, upload);
                 _logger.info(message);
                 FlashMessage.getInstance().message(message);
               }
               persistenceManager.commit();
             } catch (IOException e) {
View Full Code Here

  public boolean createGadget(HttpServletRequest request, String gadgetUrl) throws InvalidParametersException{

    //
    // Create a new widget from the gadget URL
    //
    W3CWidget widget;
    try {
      widget = GadgetUtils.createWidget(request);
    } catch (Exception e) {
      throw new InvalidParametersException();
    }

    //
    // If the gadget is not already registered, add it
    //
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    if(persistenceManager.findWidgetByGuid(widget.getIdentifier()) == null){
      WidgetFactory.addNewWidget(widget);
      return true;
    } else {
      return false;
    }
View Full Code Here

 
    //
    // Test it works!
    //
    System.out.println(file.getAbsolutePath());
    W3CWidget fpWidget = fac.parse(file);
    assertNotNull(fpWidget);
   
  }
View Full Code Here

 
    //
    // Test it works!
    //
    System.out.println(file.getAbsolutePath());
    W3CWidget fpWidget = fac.parse(file);
    assertNotNull(fpWidget);
   
  }
View Full Code Here

 
    //
    // Test it works!
    //
    System.out.println("createFeatureFlatpackUsingDefaults: "+file.getAbsolutePath());
    W3CWidget fpWidget = fac.parse(file);
    assertNotNull(fpWidget);
   
    //
    // The JQM feature should have been removed from config.xml
    //
    assertEquals(0, fpWidget.getFeatures().size());
   
  }
View Full Code Here

TOP

Related Classes of org.apache.wookie.w3c.W3CWidget

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.