Package org.apache.wookie.w3c

Examples of org.apache.wookie.w3c.W3CWidgetFactory


    fac.parse(wgt);
  }
 
  @Test
  public void testSetStartPageProcessorNull() throws Exception{
    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setStartPageProcessor(null);
    fac.setOutputDirectory(testfolder.getPath());
    fac.parse(wgt);
  }
View Full Code Here


    fac.parse(wgt);
  }
 
   @Test
    public void testGetUnzipped() throws Exception{
      W3CWidgetFactory fac = new W3CWidgetFactory();
      fac.setStartPageProcessor(null);
      fac.setOutputDirectory(testfolder.getPath());
      fac.parse(wgt);
      File file = fac.getUnzippedWidgetDirectory();
      assertEquals("parser/java/test/www.getwookie.org/widgets/test", file.getPath());
      assertTrue(file.isDirectory());
    }
View Full Code Here

    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(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
View Full Code Here

      if (!onlyUseHttps) _logger.warn("checking for updates using non-secure method");
      // Get all installed widgets
      IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
      IWidget[] widgets = persistenceManager.findAll(IWidget.class);
      // Create a W3CWidget factory for the current context
      W3CWidgetFactory factory  = getFactory(request.getSession().getServletContext());
      // Iterate over the widgets and attempt to install updates
      for (IWidget widget: widgets){
        try {
          installUpdate(factory, widget, onlyUseHttps);
        } catch (Exception e) {
View Full Code Here

      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);
      } catch (IOException e) {
        _logger.warn("Problem updating "+resourceId+": widget couldn't be downloaded");
        throw new InvalidParametersException();
      } catch (InvalidContentTypeException e) {
View Full Code Here

   * @return the factory
   * @throws IOException
   */
  private W3CWidgetFactory getFactory(ServletContext context){
    Configuration properties = (Configuration) context.getAttribute("properties"); //$NON-NLS-1$
    W3CWidgetFactory factory = new W3CWidgetFactory();
    final String[] locales = properties.getStringArray("widget.locales");
    factory.setLocales(locales);
    factory.setLocalPath(context.getContextPath()+properties.getString("widget.widgetfolder"));
    final String WIDGETFOLDER = context.getRealPath(properties.getString("widget.widgetfolder"));//$NON-NLS-1$
    try {
      factory.setOutputDirectory(WIDGETFOLDER);
    } catch (IOException e) {
      _logger.error(e);
    }
    // Configure the widget factory with the installed feature set
    factory.setFeatures(Features.getFeatureNames());
    factory.setStartPageProcessor(new StartPageProcessor());
    return factory;
  }
View Full Code Here

                 // get persistence manager for this thread
                        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
             try{
               persistenceManager.begin();
               File upload = WidgetFileUtils.dealWithDroppedFile(UPLOADFOLDER, f);
               W3CWidgetFactory fac = new W3CWidgetFactory();
               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);
View Full Code Here

  @Test
  public void createBasicFlatpackUsingDefaults() throws Exception{
    //
    // upload a new widget to test with
    //
    W3CWidgetFactory fac = getFactory();
    File testWidget = new File("build/widgets/bubbles.wgt");
    fac.parse(testWidget);
    download = fac.getUnzippedWidgetDirectory(); //download is where we unzipped the widget
   
    //
    // Create an instance of it
    //
    IWidgetInstance instance = new WidgetInstanceMock();
   
    //
    // Flatpack it
    //
    FlatpackFactory flatfac = new FlatpackFactory(instance);
    flatfac.setInputWidget(testWidget); // this is the original .wgt
    File file = flatfac.pack(); // Get the new .wgt file
 
    //
    // Test it works!
    //
    System.out.println(file.getAbsolutePath());
    W3CWidget fpWidget = fac.parse(file);
    assertNotNull(fpWidget);
   
  }
View Full Code Here

  @Test
  public void createBasicFlatpack() throws Exception{
    //
    // upload a new widget to test with
    //
    W3CWidgetFactory fac = getFactory();
    File testWidget = new File("build/widgets/bubbles.wgt");
    fac.parse(testWidget);
    download = fac.getUnzippedWidgetDirectory(); //download is where we unzipped the widget
   
    //
    // Create an instance of it
    //
    IWidgetInstance instance = new WidgetInstanceMock();
   
    //
    // Flatpack it
    //
    FlatpackFactory flatfac = new FlatpackFactory(instance);
    flatfac.setParser(fac);
    flatfac.setInputWidget(testWidget); // this is the original .wgt
    flatfac.setFlatpackFolder(flatpack); // flatpack is our new temp folder. This would probably be "/flatpack" or similar in deployment
    File file = flatfac.pack(); // Get the new .wgt file
 
    //
    // Test it works!
    //
    System.out.println(file.getAbsolutePath());
    W3CWidget fpWidget = fac.parse(file);
    assertNotNull(fpWidget);
   
  }
View Full Code Here

  public void createFeatureFlatpackUsingDefaults() throws Exception{
   
    //
    // upload a new widget to test with
    //
    W3CWidgetFactory fac = getFactory();
    fac.setFeatures(Features.getFeatureNames());
    File testWidget = new File("build/widgets/freeder.wgt");
    fac.parse(testWidget);
   
    //
    //download is where we unzipped the widget
    //
    download = fac.getUnzippedWidgetDirectory();
   
    //
    // Create an instance of it
    //
    IWidgetInstance instance = new WidgetInstanceMock();
   
    //
    // Flatpack it
    //
    FlatpackFactory flatfac = new FlatpackFactory(instance);
    flatfac.setInputWidget(testWidget); // this is the original .wgt
    File file = flatfac.pack(); // Get the new .wgt file
 
    //
    // 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
    //
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.