Examples of IWidgetInstance


Examples of org.apache.wookie.beans.IWidgetInstance

   * Return the "default widget" instance
   * @return an IWidgetInstance for the default widget, typically the "unsupported widget widget"
   */
  public static IWidgetInstance defaultInstance(String locale){
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidgetInstance instance = persistenceManager.newInstance(IWidgetInstance.class);
    instance.setWidget(persistenceManager.findWidgetDefaultByType("unsupported")); //$NON-NLS-1$
    instance.setIdKey("0000");
    instance.setLang(locale);
    instance.setOpensocialToken("");
    return instance;
  }
View Full Code Here

Examples of org.apache.wookie.beans.IWidgetInstance

   * @return a new WidgetInstance, or null if the instance cannot be created
   */
  public IWidgetInstance newInstance(String apiKey, String userId, String sharedDataKey, String serviceType, String widgetId, String lang){
    try {
      IWidget widget;
      IWidgetInstance widgetInstance;
      // Widget ID or Widget Type?
          IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
      if (widgetId != null){
        widget = persistenceManager.findWidgetByGuid(widgetId);
      }
View Full Code Here

Examples of org.apache.wookie.beans.IWidgetInstance

   * @param idKey
   * @param properties
   * @return
   */
  private IWidgetInstance addNewWidgetInstance(IPersistenceManager persistenceManager, String api_key, String userId, String sharedDataKey, IWidget widget, String nonce, String idKey, Configuration properties, String lang) {   
    IWidgetInstance widgetInstance = persistenceManager.newInstance(IWidgetInstance.class);
    widgetInstance.setUserId(userId);
    widgetInstance.setSharedDataKey(sharedDataKey);
    widgetInstance.setIdKey(idKey);
    widgetInstance.setNonce(nonce);
    widgetInstance.setApiKey(api_key);
    if (LocalizationUtils.isValidLanguageTag(lang)) widgetInstance.setLang(lang);
    // set the defaults widget for this type     
    widgetInstance.setWidget(widget);           
    widgetInstance.setHidden(false);
    widgetInstance.setShown(true);
    widgetInstance.setUpdated(false);
    widgetInstance.setLocked(false);

    // Setup opensocial token if needed
    widgetInstance.setOpensocialToken(""); //$NON-NLS-1$
    if (properties.getBoolean("opensocial.enable")){ //$NON-NLS-1$
      try {
        if (properties.getString("opensocial.token").equals("secure")){ //$NON-NLS-1$ //$NON-NLS-2$
          widgetInstance.setOpensocialToken(OpenSocialUtils.createEncryptedToken(widgetInstance,properties.getString("opensocial.key"), localizedMessages)); //$NON-NLS-1$
        }
        else {
          widgetInstance.setOpensocialToken(OpenSocialUtils.createPlainToken(widgetInstance, localizedMessages));         
        }
      } catch (Exception e) {
        _logger.error(e.getMessage());
      }
    }
View Full Code Here

Examples of org.apache.wookie.beans.IWidgetInstance

    String legacySharedDataKey = getLegacySharedDataKey(sharedDataKey);

    //
    // Find widget instance
    //
    IWidgetInstance instance = WidgetInstancesController.findWidgetInstance(apiKey, userId, legacySharedDataKey, widgetId, serviceType);

    //
    // Match found, so migrate the instance as well as any sibling instances that use the same shared data key, and any shared data instances
    //
    if (instance != null){ 
View Full Code Here

Examples of org.apache.wookie.beans.IWidgetInstance

      //
      // 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;
      }

      //
      // Create the proxy bean for the request
      //
      ProxyURLBean bean;
      try {
        bean = new ProxyURLBean(request);
      } catch (MalformedURLException e) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
        return;
      }   

      //
      // should we filter urls?
      //
      if (properties.getBoolean("widget.proxy.usewhitelist") && !isAllowed(bean.getNewUrl().toURI(), instance)){
        response.sendError(HttpServletResponse.SC_FORBIDDEN,"<error>URL Blocked</error>");
        fLogger.warn("URL " + bean.getNewUrl().toExternalForm() + " Blocked for scope "+instance.getWidget().getGuid());
        return;
     

      //
      // Create a ProxyClient instance for the request
View Full Code Here

Examples of org.apache.wookie.beans.IWidgetInstance

  /* (non-Javadoc)
   * @see org.apache.wookie.controller.Controller#show(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  @Override
  protected void show(String resourceId, HttpServletRequest request, HttpServletResponse response) throws ResourceNotFoundException, UnauthorizedAccessException, IOException {
     IWidgetInstance instance = WidgetInstancesController.getLocalizedWidgetInstance(request);
     if (instance == null){
       throw new ResourceNotFoundException();
     } else {
       // Check the API key matches
       String apiKey = request.getParameter("api_key");
       if (!instance.getApiKey().equals(apiKey)) throw new UnauthorizedAccessException();
       // Return the response XML
       checkProxy(request);
       String url = getUrl(request, instance);
       String locale = request.getParameter("locale");//$NON-NLS-1$
       response.setContentType(CONTENT_TYPE);
View Full Code Here

Examples of org.apache.wookie.beans.IWidgetInstance

   * Locks a widget instance
   * @param request
   * @throws InvalidParametersException
   */
  public static void doStopWidget(HttpServletRequest request) throws InvalidParametersException{       
    IWidgetInstance instance = WidgetInstancesController.findWidgetInstance(request)
    if(instance!=null){
      lockWidgetInstance(instance);
      Notifier.notifyWidgets(request.getSession(), instance, Notifier.STATE_UPDATED);
    }else{
      throw new InvalidParametersException();
View Full Code Here

Examples of org.apache.wookie.beans.IWidgetInstance

   * UNlocks a widget insa
   * @param request
   * @throws InvalidParametersException
   */
  public static void doResumeWidget(HttpServletRequest request) throws InvalidParametersException{         
    IWidgetInstance instance = WidgetInstancesController.findWidgetInstance(request);
    if(instance!=null){
      unlockWidgetInstance(instance);
      Notifier.notifyWidgets(request.getSession(), instance, Notifier.STATE_UPDATED);
    }else{
      throw new InvalidParametersException();
View Full Code Here

Examples of org.apache.wookie.beans.IWidgetInstance

      return;
    }

    checkProxy(request);
   
    IWidgetInstance instance = WidgetInstancesController.getLocalizedWidgetInstance(request);
        String locale = request.getParameter("locale");//$NON-NLS-1$
   
    // Widget exists
    if(instance==null){
      instance = WidgetInstanceFactory.getWidgetFactory(session, localizedMessages).newInstance(apiKey, userId, sharedDataKey, serviceType, widgetId, locale);
View Full Code Here

Examples of org.apache.wookie.beans.IWidgetInstance

   * Create a clone of the instance
   * @param request
   * @throws InvalidParametersException
   */
  public static void cloneSharedData(HttpServletRequest request) throws InvalidParametersException{
    IWidgetInstance instance = WidgetInstancesController.findWidgetInstance(request)
    if (instance == null){
      throw new InvalidParametersException();   
    }
    String sharedDataKey = request.getParameter("shareddatakey");   //$NON-NLS-1$; 
    String cloneSharedDataKey = request.getParameter("cloneshareddatakey");
    if (sharedDataKey == null || sharedDataKey.trim().equals("") || cloneSharedDataKey == null || cloneSharedDataKey.trim().equals("")){//$NON-NLS-1$ //$NON-NLS-2$
      throw new InvalidParametersException();
    }
    String cloneKey = SharedDataHelper.getInternalSharedDataKey(instance, cloneSharedDataKey);
        IWidget widget = instance.getWidget();
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    for (ISharedData sharedData : new SharedContext(instance).getSharedData())
    {
        ISharedData clone = persistenceManager.newInstance(ISharedData.class);
            clone.setDkey(sharedData.getDkey());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.