Package org.apache.wookie.beans

Examples of org.apache.wookie.beans.IWidgetInstance


   * the locale if the user has changed it.
   * @param request
   * @return the widget instance
   */
  private static IWidgetInstance getLocalizedWidgetInstance(HttpServletRequest request){
    IWidgetInstance instance = WidgetInstancesController.findWidgetInstance(request);
    if (instance != null){
      String locale = request.getParameter("locale");//$NON-NLS-1$
      // If the requested locale is different to the saved locale, update the "lang" attribute
      // of the widget instance and save it
      if (
          (locale == null && instance.getLang()!=null) ||
          (locale != null && instance.getLang()==null) ||          
          (locale != null && !instance.getLang().equals(locale))
      ){
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
        instance.setLang(locale);
        persistenceManager.save(instance);
      }
    }
    return instance;
  }
View Full Code Here


   * even to the WidgetInstance ActiveRecord class.
   * @param request
   * @return
   */
  public static IWidgetInstance findWidgetInstance(HttpServletRequest request){
    IWidgetInstance instance;
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();

    // Try using the id_key parameter
    String id_key = request.getParameter("id_key"); //$NON-NLS-1$
    if (id_key != null & id_key != ""){
View Full Code Here

   * @param serviceType
   * @return the widget instance, or null if there is no matching instance
   * @throws UnsupportedEncodingException
   */
  public static IWidgetInstance findWidgetInstance(String apiKey, String userId, String sharedDataKey, String widgetId, String serviceType) throws UnsupportedEncodingException{
    IWidgetInstance instance;
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    if (widgetId != null){
      widgetId = URLDecoder.decode(widgetId, "UTF-8"); //$NON-NLS-1$
      _logger.debug("Looking for widget instance with widgetid of " + widgetId);
      instance = persistenceManager.findWidgetInstanceByGuid(apiKey, userId, sharedDataKey, widgetId);
View Full Code Here

      state.put("message", localizedMessages.getString("WidgetAPIImpl.0"));   //$NON-NLS-1$
      return state;
    }
    // check if instance is valid
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidgetInstance widgetInstance = persistenceManager.findWidgetInstanceByIdKey(id_key);
    if (widgetInstance == null){
      state.put("message", localizedMessages.getString("WidgetAPIImpl.0"));   //$NON-NLS-1$
      return state;     
    }
    //
View Full Code Here

  public String getParticipants(String id_key) {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    Messages localizedMessages = LocaleHandler.localizeMessages(request);
    if(id_key == null) return localizedMessages.getString("WidgetAPIImpl.0"); //$NON-NLS-1$
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidgetInstance widgetInstance = persistenceManager.findWidgetInstanceByIdKey(id_key);
    if(widgetInstance==null) return localizedMessages.getString("WidgetAPIImpl.0"); //$NON-NLS-1$
    IParticipant[] participants = persistenceManager.findParticipants(widgetInstance);
    return ParticipantHelper.createJSONParticipantsDocument(participants);
  }
View Full Code Here

  public String getViewer(String id_key) {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    Messages localizedMessages = LocaleHandler.localizeMessages(request);
    if(id_key == null) return localizedMessages.getString("WidgetAPIImpl.0"); //$NON-NLS-1$
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
        IWidgetInstance widgetInstance = persistenceManager.findWidgetInstanceByIdKey(id_key);
    if(widgetInstance == null) return localizedMessages.getString("WidgetAPIImpl.0"); //$NON-NLS-1$
        IParticipant participant = persistenceManager.findParticipantViewer(widgetInstance);
    if (participant != null) return ParticipantHelper.createJSONParticipantDocument(participant); //$NON-NLS-1$
    return null; // no viewer i.e. widget is anonymous
  }
View Full Code Here

   */
  public String submitDelta(String id_key, Map<String,String>map){
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    Messages localizedMessages = LocaleHandler.localizeMessages(request);
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
        IWidgetInstance widgetInstance = persistenceManager.findWidgetInstanceByIdKey(id_key);
    if(widgetInstance == null) return localizedMessages.getString("WidgetAPIImpl.0"); //$NON-NLS-1$
    if(widgetInstance.isLocked()) return localizedMessages.getString("WidgetAPIImpl.2"); //$NON-NLS-1$
    //
    for (String key: map.keySet())
       PropertiesController.updateSharedDataEntry(widgetInstance, key, map.get(key), false);
    Notifier.notifySiblings(widgetInstance);
    return "okay"; //$NON-NLS-1$
View Full Code Here

      //
      // Check that the request is coming from a valid widget
      //
      IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
      IWidgetInstance instance = persistenceManager.findWidgetInstanceByIdKey(request.getParameter("instanceid_key"))
      if(instance == null && !isDefaultGadget(request)){
        response.sendError(HttpServletResponse.SC_FORBIDDEN,"<error>"+UNAUTHORISED_MESSAGE+"</error>")
        return;
      }
View Full Code Here

  public List<IPreference> preferences(String id_key) {
    ArrayList<IPreference> prefs = new ArrayList<IPreference>();
    if(id_key == null) return prefs;
    // check if instance is valid
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidgetInstance widgetInstance = persistenceManager.findWidgetInstanceByIdKey(id_key);
    if(widgetInstance==null) return prefs;
    for(IPreference preference : widgetInstance.getPreferences()){
      prefs.add(new PreferenceDelegate(preference));
    }
    return prefs;
  }
View Full Code Here

    Map<String, String> map = new HashMap<String, String>();
    if(id_key == null) return map;
 
    // check if instance is valid
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
        IWidgetInstance widgetInstance = persistenceManager.findWidgetInstanceByIdKey(id_key);
    if(widgetInstance==null) return map;
   
    // Get i18n-enabled metadata for the Widget's locale and encode it using unicode control characters.
   
    String locales[] = {widgetInstance.getLang()};
    IWidget widget = widgetInstance.getWidget();
     
    String author = "";
        String email = "";
        String href = "";
    if (widget.getAuthor() != null){
View Full Code Here

TOP

Related Classes of org.apache.wookie.beans.IWidgetInstance

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.