Package org.apache.wookie.w3c

Examples of org.apache.wookie.w3c.W3CWidgetFactory


    try
      if(zipFile.exists()){
                IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
        final String[] locales = properties.getStringArray("widget.locales");
        W3CWidgetFactory fac = new W3CWidgetFactory();
        fac.setLocales(locales);
        fac.setLocalPath(getServletContext().getContextPath()+properties.getString("widget.widgetfolder"));
        fac.setOutputDirectory(WIDGETFOLDER);
        fac.setFeatures(persistenceManager.findServerFeatureNames());
        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);
          Object dbkey = widget.getId();
          // widget added
View Full Code Here


  //
  // Test that a request to get an update over HTTP fails when HTTPSOnly = true
  //
  @Test
  public void testHttpsOnly() throws InvalidContentTypeException, BadWidgetZipFileException, BadManifestException, IOException, Exception{
      W3CWidget updatedWidget = UpdateUtils.getUpdate(new W3CWidgetFactory(), "test", "http://people.opera.com/harig/wupdres/resources/out.php?udd-pass", "1.0", true);
      assertNull(updatedWidget);
  }
View Full Code Here

  @Test
  public void loadModifySaveReload() throws Exception{

    // Load the widget
    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setLocalPath("/widgets");
    fac.setFeatures(new String[]{"feature:a9bb79c1"});
    fac.setEncodings(new String[]{"UTF-8", "ISO-8859-1","Windows-1252"});
    if (download.exists()) download.delete();
    if (output.exists()) output.delete();
    output.mkdir();
    fac.setOutputDirectory(output.getAbsolutePath());
    W3CWidget widget = fac.parse(new URL("http://dev.w3.org/2006/waf/widgets/test-suite/test-cases/ta-RRZxvvTFHx/001/b6.wgt"));
   
    INameEntity 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

    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());
  }
  private W3CWidget load(File file) throws BadWidgetZipFileException, BadManifestException, Exception{
    W3CWidgetFactory fac = getFactory();
    W3CWidget widget = fac.parse(file);
    return widget;   
  }
View Full Code Here

  }
 
  private W3CWidgetFactory getFactory() throws Exception{
    String outputPath = "/widgets";
    // Load the widget
    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setLocalPath(outputPath);
    fac.setFeatures(new String[]{"feature:a9bb79c1","http://wave.google.com", "http://incubator.apache.org/wookie/ext"});
    fac.setEncodings(new String[]{"UTF-8", "ISO-8859-1","Windows-1252"});
    if (download.exists()) download.delete();
    if (output.exists()) output.delete();
    output.mkdir();
    fac.setOutputDirectory(output.getAbsolutePath());
    return fac;
  }
View Full Code Here

    outputFolder.delete();
    outputFolder.mkdir();

    System.out.println(outputFolder.getPath());

    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setOutputDirectory(outputFolder.getPath());
    W3CWidget widget = fac.parse(file);
    assertEquals("Unsupported widget widget", widget.getLocalName("en"));
  }
View Full Code Here

      get.releaseConnection();

      //
      // check the downloaded file
      //
      W3CWidgetFactory fac = new W3CWidgetFactory();
      fac.setStartPageProcessor(null);
      File outputDir = new File("src/test" + File.separatorChar + "resources" + File.separatorChar + "widgets");
      outputDir.mkdirs();
      fac.setOutputDirectory("src/test" + File.separatorChar + "resources" + File.separatorChar + "widgets");
      W3CWidget widget = fac.parse(downloadedFile);
     
      //
      // Cleanup
      //
      FileUtils.deleteQuietly(downloadedFile);
View Full Code Here

    out.flush();
    out.close();
    get.releaseConnection();

    // check the downloaded file
    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setStartPageProcessor(null);
    File outputDir = new File("src"+File.separatorChar+"test" + File.separatorChar + "resources" + File.separatorChar + "widgets");
    outputDir.mkdirs();
    fac.setOutputDirectory("src" + File.separatorChar + "test" + File.separatorChar + "resources" + File.separatorChar + "widgets");
    W3CWidget widget = fac.parse(downloadedFile);
    File file = fac.getUnzippedWidgetDirectory();
    assertEquals("src"  + File.separatorChar + "test" + File.separatorChar + "testdata"
        + File.separatorChar + "widgets" + File.separatorChar
        + "www.getwookie.org" + File.separatorChar + "widgets"
        + File.separatorChar + "weather", file.getPath());
    assertTrue(file.isDirectory());
View Full Code Here

        final boolean REJECTINVALID= configuration.getBoolean("widget.deployment.rejectinvalidsignatures");
        final boolean REJECTUNTRUSTED= configuration.getBoolean("widget.deployment.rejectuntrustedsignatures");
        final String PASSWORD = configuration.getString("widget.deployment.trustedkeystore.password");
        final String KEYSTORE = configuration.getString("widget.deployment.trustedkeystore");//$NON-NLS-1$
       
        W3CWidgetFactory fac = new W3CWidgetFactory();
        fac.setLocales(locales);
        fac.setLocalPath(contextPath+localWidgetFolderPath);
        fac.setOutputDirectory(WIDGETFOLDER);
        fac.setFeatures(Features.getFeatureNames());
        fac.setStartPageProcessor(new StartPageProcessor());
        if (VERIFYSIGNATURE) {
            KeyStore keyStore = KeyStore.getInstance("JKS");
            String digSigSchema = context
                    .getRealPath("/WEB-INF/classes/org/apache/wookie/util/digitalsignature/xmldsig-core-schema.xsd");
            InputStream stream = context.getResourceAsStream("/WEB-INF/classes/" + KEYSTORE);
            if (stream == null) {
                stream = context.getResourceAsStream("/WEB-INF/classes/" + "generated-" + KEYSTORE);
            }
            if (stream == null) {
                FileOutputStream fos = new FileOutputStream(context
                        .getRealPath("/WEB-INF/classes") + File.separatorChar + "generated-" + KEYSTORE);
                keyStore.load(null, PASSWORD.toCharArray());
                keyStore.store(fos, PASSWORD.toCharArray());
                fos.close();
                fac.setDigitalSignatureParser(new DigitalSignatureProcessor(keyStore,
                        digSigSchema, REJECTINVALID, REJECTUNTRUSTED));
                logger.info(localizedMessages.getString("WidgetHotDeploy.4"));
            } else {
                keyStore.load(stream, PASSWORD.toCharArray());
                stream.close();
                fac.setDigitalSignatureParser(new DigitalSignatureProcessor(keyStore,
                        digSigSchema, REJECTINVALID, REJECTUNTRUSTED));
            }
        }
        return fac;
  }
View Full Code Here

    try {

        //
        // Parse and validate the zip as a widget
        //
        W3CWidgetFactory fac = W3CWidgetFactoryUtils.createW3CWidgetFactory(getServletContext(), properties, localizedMessages);       
        W3CWidget widgetModel = fac.parse(zipFile);
       
        String widgetId = widgetModel.getIdentifier();
       
        //
        // If we have a generated ID and resourceId, use the resourceId to override the generated widget identifier. This is a fix for WOOKIE-383
        //
        if (widgetModel.getIdentifier().startsWith("http://incubator.apache.org/wookie/generated/") && resourceId != null){
          widgetId = resourceId;
        }
               
        new WidgetJavascriptSyntaxAnalyzer(fac.getUnzippedWidgetDirectory());
       
        //
        // Check if the widget model corresponds to an existing installed widget
        //
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
        if (persistenceManager.findWidgetByGuid(widgetId) == null) {

            //
            // A new widget was created, so return 201
            //
            WidgetFactory.addNewWidget(widgetModel, zipFile, true);
            NewWidgetBroadcaster.broadcast(properties, widgetModel.getIdentifier());
            returnXml(WidgetImportHelper.createXMLWidgetDocument(widgetModel, new File(fac.getUnzippedWidgetDirectory(), "config.xml"), getWookieServerURL(request, "").toString(), true), response);
            return true;

        } else {

            //
            // Widget already exists, so update the widget metadata and configuration details
            // and return 200
            //
            WidgetFactory.update(widgetModel,persistenceManager.findWidgetByGuid(widgetId), true, zipFile);
            returnXml(WidgetImportHelper.createXMLWidgetDocument(widgetModel, new File(fac.getUnzippedWidgetDirectory(), "config.xml"), getWookieServerURL(request, "").toString(), true), response);
            return false;

        }

        //
View Full Code Here

TOP

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

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.