Package org.apache.wookie.beans

Examples of org.apache.wookie.beans.IWidgetInstance


  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 = new SharedContext(widgetInstance).getViewer(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())
      new SharedContext(widgetInstance).updateSharedData(key, map.get(key), false);
    Notifier.notifySiblings(widgetInstance);
    return "okay"; //$NON-NLS-1$
View Full Code Here

    int iPos = idKey_RedirectUri.indexOf('#');
    String idKey = idKey_RedirectUri.substring(0, iPos);
    String redirectUri = idKey_RedirectUri.substring(iPos + 1);
    if(idKey == null) return "invalid";   
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidgetInstance widgetInstance = persistenceManager.findWidgetInstanceByIdKey(idKey);
    if(widgetInstance==null) return "invalid";
   
    Collection<IStartFile> startFiles = widgetInstance.getWidget().getStartFiles();
    String startFileUrl = null;
    for(IStartFile startFile : startFiles) {
      iPos = redirectUri.indexOf(startFile.getUrl());
      if (iPos > -1) {
        startFileUrl = startFile.getUrl();
        break;
      }
    }
    if (startFileUrl != null) {
      redirectUri = redirectUri.substring(0, iPos + startFileUrl.length()) + "?idkey=" + idKey;
    }
   
    try {
      redirectUri = URLEncoder.encode(redirectUri, "UTF-8");
    } catch (UnsupportedEncodingException e) {
    }
   
    Collection<org.apache.wookie.beans.IFeature> widgetFeatures = widgetInstance.getWidget().getFeatures();
    org.apache.wookie.beans.IFeature oAuthFeature = null;
    for (org.apache.wookie.beans.IFeature aFeature : widgetFeatures) {
      if (getName().equals(aFeature.getFeatureName())) {
        oAuthFeature = aFeature;
        break;
View Full Code Here

  }
 
  public String queryToken(String idKey) {
    if(idKey == null) return "invalid";
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidgetInstance widgetInstance = persistenceManager.findWidgetInstanceByIdKey(idKey);
    if(widgetInstance==null) return "invalid";
   
    IOAuthToken oauthToken = persistenceManager.findOAuthToken(widgetInstance);
    if (oauthToken != null) {
      if (!oauthToken.isExpires())
View Full Code Here

  }
 
  public void invalidateToken(String idKey) {
    if(idKey == null) return;
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidgetInstance widgetInstance = persistenceManager.findWidgetInstanceByIdKey(idKey);
    if(widgetInstance==null) return;
   
    IOAuthToken oauthToken = persistenceManager.findOAuthToken(widgetInstance);
    if (oauthToken != null) {
      persistenceManager.delete(oauthToken);
View Full Code Here

  }
 
  public String getClientId(String idKey) {
    if(idKey == null) return "invalid";
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidgetInstance widgetInstance = persistenceManager.findWidgetInstanceByIdKey(idKey);
    if(widgetInstance==null) return "invalid";
    IOAuthToken oauthToken = persistenceManager.findOAuthToken(widgetInstance);
    if (oauthToken != null) {
      return oauthToken.getClientId();
    } else {
View Full Code Here

      if (iEqual < 0) continue;
      oAuthTokenBunch.put(fragment.substring(0, iEqual), fragment.substring(iEqual + 1));
    } 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$
View Full Code Here

    return oauthToken.getAccessToken();
  }
 
  private Map<String, String> queryOAuthParams(String idKey) {
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidgetInstance widgetInstance = persistenceManager.findWidgetInstanceByIdKey(idKey);
    if(widgetInstance==null) return null;
   
    Collection<org.apache.wookie.beans.IFeature> widgetFeatures = widgetInstance.getWidget().getFeatures();
    org.apache.wookie.beans.IFeature oAuthFeature = null;
    for (org.apache.wookie.beans.IFeature aFeature : widgetFeatures) {
      if (getName().equals(aFeature.getFeatureName())) {
        oAuthFeature = aFeature;
        break;
View Full Code Here

  /* (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();

      checkProxy(request);
      String url = getUrl(request, instance);
      String locale = request.getParameter("locale");//$NON-NLS-1$
      response.setStatus(HttpServletResponse.SC_OK);
View Full Code Here

   * 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

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.