Package org.apache.wookie.w3c

Examples of org.apache.wookie.w3c.W3CWidgetFactory


        //
        // Parse and validate the zip as a widget
        //
        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);
        new WidgetJavascriptSyntaxAnalyzer(fac.getUnzippedWidgetDirectory());
       // File f = new File();
        //
        // Check if the widget model corresponds to an existing installed widget
        //
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
        if (persistenceManager.findWidgetByGuid(widgetModel.getIdentifier()) == null) {
         
          //
          // A new widget was created, so return 201
          //
          WidgetFactory.addNewWidget(widgetModel, zipFile,false);
          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(widgetModel.getIdentifier()),false, zipFile);
          returnXml(WidgetImportHelper.createXMLWidgetDocument(widgetModel, new File(fac.getUnzippedWidgetDirectory(), "config.xml"), getWookieServerURL(request, "").toString(), true), response);
          return false;
         
        }
       
        //
View Full Code Here


  }
 
  @Test
  public void testCreateFactory(){
    try {
      @SuppressWarnings("unused")
      W3CWidgetFactory fac = new W3CWidgetFactory();
    } catch (Exception e) {
      fail();
    }
  }
View Full Code Here

    }
  }
 
  @Test(expected = NullPointerException.class)
  public void testSetOutputDirectoryNull() throws Exception{
    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setOutputDirectory(null);
  }
View Full Code Here

    fac.setOutputDirectory(null);
  }
 
  @Test(expected = IOException.class)
  public void testSetOutputDirectoryInvalid() throws Exception{
    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setOutputDirectory("FAIL");
  }
View Full Code Here

    fac.setOutputDirectory("FAIL");
  }
 
  @Test(expected = IOException.class)
  public void testSetOutputDirectoryReadOnly() throws Exception{
    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setOutputDirectory(testfolderreadonly.getPath());
  }
View Full Code Here

    fac.setOutputDirectory(testfolderreadonly.getPath());
  }
 
  @Test(expected = IOException.class)
  public void testSetOutputDirectoryInvalidType() throws Exception{
    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setOutputDirectory(wgt.getPath());
  }
View Full Code Here

    fac.setOutputDirectory(wgt.getPath());
  }
 
  @Test(expected = Exception.class)
  public void testDontSetOutputDirectory() throws Exception{
    W3CWidgetFactory fac = new W3CWidgetFactory();   
    fac.parse(wgt);
  }
View Full Code Here

    fac.parse(wgt);
  }
 
  @Test(expected = NullPointerException.class)
  public void testSetNullEncodings() throws Exception{
    W3CWidgetFactory fac = new W3CWidgetFactory()
    fac.setEncodings(null);
  }
View Full Code Here

    fac.setEncodings(null);
  }
 
  @Test(expected = Exception.class)
  public void testSetNoEncodings() throws Exception{
    W3CWidgetFactory fac = new W3CWidgetFactory();   
    fac.setEncodings(new String[]{});
  }
View Full Code Here

    fac.setEncodings(new String[]{});
  }
 
  @Test
  public void testSetFeaturesNull() throws Exception{
    W3CWidgetFactory fac = new W3CWidgetFactory()
    fac.setOutputDirectory(testfolder.getPath());
    fac.setFeatures(null);
    fac.parse(wgt);
  }
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.