Package org.apache.wookie.w3c

Examples of org.apache.wookie.w3c.W3CWidgetFactory


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


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

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

    fac.parse(wgt);   
  }
 
  @Test
  public void testSetLocales() throws Exception{
    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setLocales(new String[]{"en"});
    fac.setOutputDirectory(testfolder.getPath());
    fac.parse(wgt);
  }
View Full Code Here

    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

  /*
   * Construct a standard W3CWidgetFactory parser for testing
   */
  private static W3CWidgetFactory createDefaultParser() {
    W3CWidgetFactory fac = new W3CWidgetFactory();
    //
    // Set the local path to the default value
    //
    fac.setLocalPath(DEFAULT_LOCAL_PATH);
    //
    // Set the features to all locally installed features
    //
    fac.setFeatures(Features.getFeatureNames());
    //
    // Set UTF-8 encoding
    //
    try {
      fac.setEncodings(new String[] { "UTF-8" });
    } catch (Exception e) {
      _logger.error("Problem setting character encoding when creating default parser: ", e);
    }

    return fac;
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(persistenceManager.findServerFeatureNames());
               fac.setStartPageProcessor(new StartPageProcessor());
               W3CWidget model = fac.parse(upload);
               WidgetJavascriptSyntaxAnalyzer jsa = new WidgetJavascriptSyntaxAnalyzer(fac.getUnzippedWidgetDirectory());
               if(persistenceManager.findWidgetByGuid(model.getIdentifier()) == null) {
                 WidgetFactory.addNewWidget(model, true)
                 String message = model.getLocalName("en") +"' - " + localizedMessages.getString("WidgetAdminServlet.19");
                 _logger.info(message);
                 FlashMessage.getInstance().message(message);
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.