Package org.apache.wookie

Examples of org.apache.wookie.Messages


    String userId = request.getParameter("userid"); //$NON-NLS-1$
    String sharedDataKey = getSharedDataKey(request)
    String serviceType = request.getParameter("servicetype"); //$NON-NLS-1$
    String widgetId = request.getParameter("widgetid"); //$NON-NLS-1$
    HttpSession session = request.getSession(true);           
    Messages localizedMessages = LocaleHandler.localizeMessages(request);

    try {           
      if(userId==null || sharedDataKey==null || (serviceType==null && widgetId==null)){
        throw new InvalidWidgetCallException();
      }
View Full Code Here


       /*
        * Initialise the locale handler
        */
       LocaleHandler.getInstance().initialize(configuration);
      final Locale locale = new Locale(configuration.getString("widget.default.locale"));
      final Messages localizedMessages = LocaleHandler.getInstance().getResourceBundle(locale);
      
       /*
       *  load the opensocial.properties file and put it into this context
       *  as an attribute 'opensocial' available to all resources
       */
      File localOpenSocialPropsFile = new File(System.getProperty("user.dir") + File.separator + "local.opensocial.properties");
            PropertiesConfiguration localOpenSocialConfiguration = new PropertiesConfiguration(localOpenSocialPropsFile);
            CompositeConfiguration opensocialConfiguration = new CompositeConfiguration();
            opensocialConfiguration.addConfiguration(localOpenSocialConfiguration);
            opensocialConfiguration.addConfiguration(new PropertiesConfiguration("opensocial.properties"));
      context.setAttribute("opensocial", (Configuration) opensocialConfiguration);
     
      /*
       * Load installed features
       */
      Features.loadFeatures(context);
     
      /*
       * Run diagnostics
       */
      Diagnostics.run(context, configuration);
     
      /*
       * Start hot-deploy widget watcher
       */
       if (configuration.getBoolean("widget.hot_deploy")) {
         startWatcher(context, configuration, localizedMessages);
       } else {
         _logger.info(localizedMessages.getString("WidgetHotDeploy.0"));
       }
    }
    catch (ConfigurationException ex) {
      _logger.error("ConfigurationException thrown: "+ ex.toString());
    }         
View Full Code Here

 
  private void initResourceBundles() {
    resourceBundles = new HashMap<Locale, Messages>();
    for (final Locale locale : getLocales()) {
      final ResourceBundle rb = ResourceBundle.getBundle(BUNDLE_NAME, locale);
      resourceBundles.put(locale, new Messages(rb));
    }
  }
View Full Code Here

      resourceBundles.put(locale, new Messages(rb));
    }
  }

  public Messages getResourceBundle(final Locale locale) {
    Messages bundle = resourceBundles.get(locale);
    if (bundle == null) {
      bundle = resourceBundles.get(new Locale(DEFAULT_LANGUGE));     
    }       
    return bundle;
  }
View Full Code Here

   * Sets localized messages within the session
   * @param request
   */
  public static Messages localizeMessages(HttpServletRequest request){
    HttpSession session = request.getSession(true)
    Messages localizedMessages = (Messages)session.getAttribute(Messages.class.getName());
    if(localizedMessages == null){
      Locale locale = request.getLocale();
      localizedMessages = LocaleHandler.getInstance().getResourceBundle(locale);
      session.setAttribute(Messages.class.getName(), localizedMessages);     
    }
View Full Code Here

    final String UPLOADFOLDER = getServletContext().getRealPath(properties.getString("widget.useruploadfolder"));//$NON-NLS-1$

    //
    // Get localized messages so we can return errors
    //
    Messages localizedMessages = LocaleHandler.localizeMessages(request);
   
    //
    // Try to obtain a zipfile from the request.
    //
    File zipFile;
    try {
      zipFile = WidgetFileUtils.upload(UPLOADFOLDER, request);
    } catch (Exception ex) {
      throw new InvalidParametersException(localizedMessages.getString("widgets.invalid-config-xml") + "\n" + ex.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
    }
   
    //
    // No file uploaded
    //
    if(zipFile == null || !zipFile.exists()){
      throw new InvalidParametersException(localizedMessages.getString("widgets.no-widget-file-uploaded")); //$NON-NLS-1$
    }
   
    try {

        //
        // 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;
         
        }
       
        //
        // Catch specific parsing and validation errors and throw exception with error message
        //
    } catch (InvalidStartFileException ex) {
      _logger.error(ex);
      throw new InvalidParametersException(
          localizedMessages.getString("widgets.no-start-file") + "\n" + ex.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$    
    } catch (BadManifestException ex) {
      _logger.error(ex);
      String message = ex.getMessage();
      if (ex.getMessage() == null || ex.getMessage().equals(""))message = localizedMessages.getString("widgets.invalid-config-xml"); //$NON-NLS-1$
      if (ex instanceof InvalidContentTypeException)
        message = localizedMessages.getString("widgets.unsupported-content-type");//$NON-NLS-1$
      throw new InvalidParametersException(message);
    } catch (BadWidgetZipFileException ex) {
      _logger.error(ex);
      String message = ex.getMessage();
      if (ex.getMessage() == null || ex.getMessage().equals(""))message = localizedMessages.getString("widgets.bad-zip-file"); //$NON-NLS-1$
      throw new InvalidParametersException(message);
    } catch (Exception ex) {
      _logger.error(ex);
      throw new InvalidParametersException(
          localizedMessages.getString("widgets.cant-parse-config-xml") + "\n" + ex.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }

  }
View Full Code Here

    String apiKey = request.getParameter("api_key"); //$NON-NLS-1$
    String serviceType = request.getParameter("servicetype"); //$NON-NLS-1$
    String widgetId = request.getParameter("widgetid"); //$NON-NLS-1$
    sharedDataKey = SharedDataHelper.getInternalSharedDataKey(apiKey, widgetId, sharedDataKey);
    HttpSession session = request.getSession(true);           
    Messages localizedMessages = LocaleHandler.localizeMessages(request);
         
    if(userId==null || sharedDataKey==null || (serviceType==null && widgetId==null)){
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      return;
    }
View Full Code Here

    } while (iOffset < tokenBunch.length());
   
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidgetInstance widgetInstance = persistenceManager.findWidgetInstanceByIdKey(idKey);
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    Messages localizedMessages = LocaleHandler.localizeMessages(request);   

    if(widgetInstance==null) {
      return localizedMessages.getString("WidgetAPIImpl.0"); //$NON-NLS-1$
    }

    Map<String, String> oAuthParams = queryOAuthParams(idKey);
    if (oAuthParams == null) {
      return localizedMessages.getString("WidgetAPIImpl.0"); //$NON-NLS-1$     
    }
   
    IOAuthToken oauthToken = persistenceManager.findOAuthToken(widgetInstance);
    if (oauthToken == null) oauthToken = persistenceManager.newInstance(IOAuthToken.class);
    oauthToken.setAccessToken(oAuthTokenBunch.get("access_token"));
View Full Code Here

       /*
        * Initialise the locale handler
        */
       LocaleHandler.getInstance().initialize(configuration);
      final Locale locale = new Locale(configuration.getString("widget.default.locale"));
      final Messages localizedMessages = LocaleHandler.getInstance().getResourceBundle(locale);
      
       /*
       *  load the opensocial.properties file and put it into this context
       *  as an attribute 'opensocial' available to all resources
       */
      PropertiesConfiguration opensocialConfiguration;
      File localOpenSocialPropsFile = new File(System.getProperty("user.dir") + File.separator + "local.opensocial.properties");
      if (localOpenSocialPropsFile.exists()) {
        opensocialConfiguration = new PropertiesConfiguration(localOpenSocialPropsFile);
        _logger.info("Using local open social properties file: " + localOpenSocialPropsFile.toString());
      } else {
        opensocialConfiguration = new PropertiesConfiguration("opensocial.properties");
        opensocialConfiguration.setFile(localOpenSocialPropsFile);
        opensocialConfiguration.save();
        _logger.info("Using default open social properties, configure your local server using: " + localOpenSocialPropsFile.toString());
      }
      context.setAttribute("opensocial", (Configuration) opensocialConfiguration);
     
      /*
       * Load installed features
       */
      PropertiesConfiguration featuresConfiguration;
      File localFeaturesPropsFile = new File(System.getProperty("user.dir") + File.separator + "local.features.properties");
      if (localFeaturesPropsFile.exists()) {
        featuresConfiguration = new PropertiesConfiguration(localFeaturesPropsFile);
        _logger.info("Loading local features file: " + localOpenSocialPropsFile.toString());
      } else {
        featuresConfiguration = new PropertiesConfiguration("features.properties");
        featuresConfiguration.setFile(localFeaturesPropsFile);
        featuresConfiguration.save();
        _logger.info("Loading default features, configure your local server using: " + localFeaturesPropsFile.toString());
      }
      FeatureLoader.loadFeatures(featuresConfiguration);
     
      /*
       * Run diagnostics
       */
      Diagnostics.run(context, configuration);
     
      /*
       * Start hot-deploy widget watcher
       */
       if (configuration.getBoolean("widget.hot_deploy")) {
         startWatcher(context, configuration, localizedMessages);
       } else {
         _logger.info(localizedMessages.getString("WidgetHotDeploy.0"));
       }
    }
    catch (ConfigurationException ex) {
      _logger.error("ConfigurationException thrown: "+ ex.toString());
    }         
View Full Code Here

 
  private void initResourceBundles() {
    resourceBundles = new HashMap<Locale, Messages>();
    for (final Locale locale : getLocales()) {
      final ResourceBundle rb = ResourceBundle.getBundle(BUNDLE_NAME, locale);
      resourceBundles.put(locale, new Messages(rb));
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.wookie.Messages

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.